3 // ``unsafe'' stands for no safety according to the size of the given type.
4 // There are type safe versions of the cas operations in the architecture
5 // independent part of atomic that use the unsafe versions and make a type
10 cas_unsafe (Mword *ptr, Mword oldval, Mword newval)
15 ("lock; cmpxchgl %1,%2"
17 : "r" (newval), "m" (*ptr), "0" (oldval)
25 cas2_unsafe (Mword *ptr, Mword *oldval, Mword *newval)
29 ("lock; cmpxchg8b %3 ; sete %%cl"
49 ("xchg %0,%1" : "=r" (tmp) : "m" (*l), "0" (1) : "memory");
54 template <typename T> inline
55 atomic_and (Mword *l, Mword bits)
59 while (!cas (p, old, old & value));
62 template <typename T> inline
63 atomic_or (Mword *l, Mword bits)
67 while (!cas (p, old, old | value));
70 template <typename T> inline
71 void atomic_change(T *p, T mask, T bits)
75 while (!cas (p, old, (old & mask) | bits));