Deleted Added
full compact
atomic.h (88117) atomic.h (90515)
1/*-
2 * Copyright (c) 1998 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1998 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/i386/include/atomic.h 88117 2001-12-18 08:51:34Z jhb $
26 * $FreeBSD: head/sys/i386/include/atomic.h 90515 2002-02-11 03:41:59Z bde $
27 */
28#ifndef _MACHINE_ATOMIC_H_
29#define _MACHINE_ATOMIC_H_
30
31/*
32 * Various simple arithmetic on memory which is atomic in the presence
33 * of interrupts and multiple processors.
34 *

--- 40 unchanged lines hidden (view full) ---

75
76#else /* !KLD_MODULE */
77
78/*
79 * For userland, assume the SMP case and use lock prefixes so that
80 * the binaries will run on both types of systems.
81 */
82#if defined(SMP) || !defined(_KERNEL)
27 */
28#ifndef _MACHINE_ATOMIC_H_
29#define _MACHINE_ATOMIC_H_
30
31/*
32 * Various simple arithmetic on memory which is atomic in the presence
33 * of interrupts and multiple processors.
34 *

--- 40 unchanged lines hidden (view full) ---

75
76#else /* !KLD_MODULE */
77
78/*
79 * For userland, assume the SMP case and use lock prefixes so that
80 * the binaries will run on both types of systems.
81 */
82#if defined(SMP) || !defined(_KERNEL)
83#if defined(LOCORE)
84#define MPLOCKED lock ;
85#else /* !LOCORE */
86#define MPLOCKED "lock ; "
83#define MPLOCKED "lock ; "
87#endif /* LOCORE */
88#else /* SMP || !_KERNEL */
84#else
89#define MPLOCKED
85#define MPLOCKED
90#endif /* SMP || !_KERNEL */
86#endif
91
87
92#if !defined(LOCORE)
93/*
94 * The assembly is volatilized to demark potential before-and-after side
95 * effects if an interrupt or SMP collision were to occur.
96 */
97#define ATOMIC_ASM(NAME, TYPE, OP, CONS, V) \
98static __inline void \
99atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
100{ \

--- 99 unchanged lines hidden (view full) ---

200atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
201{ \
202 __asm __volatile(SOP \
203 : "+m" (*p), /* 0 */ \
204 "+r" (v) /* 1 */ \
205 : : "memory"); \
206}
207#endif /* defined(I386_CPU) */
88/*
89 * The assembly is volatilized to demark potential before-and-after side
90 * effects if an interrupt or SMP collision were to occur.
91 */
92#define ATOMIC_ASM(NAME, TYPE, OP, CONS, V) \
93static __inline void \
94atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
95{ \

--- 99 unchanged lines hidden (view full) ---

195atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
196{ \
197 __asm __volatile(SOP \
198 : "+m" (*p), /* 0 */ \
199 "+r" (v) /* 1 */ \
200 : : "memory"); \
201}
202#endif /* defined(I386_CPU) */
208#endif /* !defined(LOCORE) */
209#endif /* KLD_MODULE */
210
203#endif /* KLD_MODULE */
204
211#if !defined(LOCORE)
212ATOMIC_ASM(set, char, "orb %b1,%0", "iq", v)
213ATOMIC_ASM(clear, char, "andb %b1,%0", "iq", ~v)
214ATOMIC_ASM(add, char, "addb %b1,%0", "iq", v)
215ATOMIC_ASM(subtract, char, "subb %b1,%0", "iq", v)
216
217ATOMIC_ASM(set, short, "orw %w1,%0", "ir", v)
218ATOMIC_ASM(clear, short, "andw %w1,%0", "ir", ~v)
219ATOMIC_ASM(add, short, "addw %w1,%0", "ir", v)

--- 182 unchanged lines hidden (view full) ---

402 " xchgl %1,%0 ; "
403 "# atomic_readandclear_int"
404 : "=&r" (result) /* 0 (result) */
405 : "m" (*addr)); /* 1 (addr) */
406
407 return (result);
408}
409#endif /* !defined(WANT_FUNCTIONS) */
205ATOMIC_ASM(set, char, "orb %b1,%0", "iq", v)
206ATOMIC_ASM(clear, char, "andb %b1,%0", "iq", ~v)
207ATOMIC_ASM(add, char, "addb %b1,%0", "iq", v)
208ATOMIC_ASM(subtract, char, "subb %b1,%0", "iq", v)
209
210ATOMIC_ASM(set, short, "orw %w1,%0", "ir", v)
211ATOMIC_ASM(clear, short, "andw %w1,%0", "ir", ~v)
212ATOMIC_ASM(add, short, "addw %w1,%0", "ir", v)

--- 182 unchanged lines hidden (view full) ---

395 " xchgl %1,%0 ; "
396 "# atomic_readandclear_int"
397 : "=&r" (result) /* 0 (result) */
398 : "m" (*addr)); /* 1 (addr) */
399
400 return (result);
401}
402#endif /* !defined(WANT_FUNCTIONS) */
410#endif /* !defined(LOCORE) */
411#endif /* ! _MACHINE_ATOMIC_H_ */
403#endif /* ! _MACHINE_ATOMIC_H_ */