0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef __ARCH_SPARC_CMPXCHG__
0013 #define __ARCH_SPARC_CMPXCHG__
0014
0015 unsigned long __xchg_u32(volatile u32 *m, u32 new);
0016 void __xchg_called_with_bad_pointer(void);
0017
0018 static inline unsigned long __xchg(unsigned long x, __volatile__ void * ptr, int size)
0019 {
0020 switch (size) {
0021 case 4:
0022 return __xchg_u32(ptr, x);
0023 }
0024 __xchg_called_with_bad_pointer();
0025 return x;
0026 }
0027
0028 #define arch_xchg(ptr,x) ({(__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)));})
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 void __cmpxchg_called_with_bad_pointer(void);
0041
0042 unsigned long __cmpxchg_u32(volatile u32 *m, u32 old, u32 new_);
0043
0044
0045 static inline unsigned long
0046 __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)
0047 {
0048 switch (size) {
0049 case 4:
0050 return __cmpxchg_u32((u32 *)ptr, (u32)old, (u32)new_);
0051 default:
0052 __cmpxchg_called_with_bad_pointer();
0053 break;
0054 }
0055 return old;
0056 }
0057
0058 #define arch_cmpxchg(ptr, o, n) \
0059 ({ \
0060 __typeof__(*(ptr)) _o_ = (o); \
0061 __typeof__(*(ptr)) _n_ = (n); \
0062 (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
0063 (unsigned long)_n_, sizeof(*(ptr))); \
0064 })
0065
0066 u64 __cmpxchg_u64(u64 *ptr, u64 old, u64 new);
0067 #define arch_cmpxchg64(ptr, old, new) __cmpxchg_u64(ptr, old, new)
0068
0069 #include <asm-generic/cmpxchg-local.h>
0070
0071
0072
0073
0074
0075 #define arch_cmpxchg_local(ptr, o, n) \
0076 ((__typeof__(*(ptr)))__generic_cmpxchg_local((ptr), (unsigned long)(o),\
0077 (unsigned long)(n), sizeof(*(ptr))))
0078 #define arch_cmpxchg64_local(ptr, o, n) __generic_cmpxchg64_local((ptr), (o), (n))
0079
0080 #endif