1 #ifndef __ARCH_H8300_CMPXCHG__
2 #define __ARCH_H8300_CMPXCHG__
4 #include <linux/irqflags.h>
6 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
8 struct __xchg_dummy
{ unsigned long a
[100]; };
9 #define __xg(x) ((volatile struct __xchg_dummy *)(x))
11 static inline unsigned long __xchg(unsigned long x
, volatile void * ptr
, int size
)
13 unsigned long tmp
, flags
;
15 local_irq_save(flags
);
22 : "=&r" (tmp
) : "r" (x
), "m" (*__xg(ptr
)) : "memory");
28 : "=&r" (tmp
) : "r" (x
), "m" (*__xg(ptr
)) : "memory");
34 : "=&r" (tmp
) : "r" (x
), "m" (*__xg(ptr
)) : "memory");
39 local_irq_restore(flags
);
43 #include <asm-generic/cmpxchg-local.h>
46 * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
49 #define cmpxchg_local(ptr, o, n) \
50 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
51 (unsigned long)(n), sizeof(*(ptr))))
52 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
55 #include <asm-generic/cmpxchg.h>
58 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
60 #endif /* __ARCH_H8300_CMPXCHG__ */