This source file includes following definitions.
- __xchg
- __cmpxchg
1
2
3
4
5
6
7
8
9
10
11
12 #ifndef __ARCH_SPARC_CMPXCHG__
13 #define __ARCH_SPARC_CMPXCHG__
14
15 unsigned long __xchg_u32(volatile u32 *m, u32 new);
16 void __xchg_called_with_bad_pointer(void);
17
18 static inline unsigned long __xchg(unsigned long x, __volatile__ void * ptr, int size)
19 {
20 switch (size) {
21 case 4:
22 return __xchg_u32(ptr, x);
23 }
24 __xchg_called_with_bad_pointer();
25 return x;
26 }
27
28 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
29
30
31
32
33
34
35
36
37
38
39
40 void __cmpxchg_called_with_bad_pointer(void);
41
42 unsigned long __cmpxchg_u32(volatile u32 *m, u32 old, u32 new_);
43
44
45 static inline unsigned long
46 __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)
47 {
48 switch (size) {
49 case 4:
50 return __cmpxchg_u32((u32 *)ptr, (u32)old, (u32)new_);
51 default:
52 __cmpxchg_called_with_bad_pointer();
53 break;
54 }
55 return old;
56 }
57
58 #define cmpxchg(ptr, o, n) \
59 ({ \
60 __typeof__(*(ptr)) _o_ = (o); \
61 __typeof__(*(ptr)) _n_ = (n); \
62 (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
63 (unsigned long)_n_, sizeof(*(ptr))); \
64 })
65
66 u64 __cmpxchg_u64(u64 *ptr, u64 old, u64 new);
67 #define cmpxchg64(ptr, old, new) __cmpxchg_u64(ptr, old, new)
68
69 #include <asm-generic/cmpxchg-local.h>
70
71
72
73
74
75 #define cmpxchg_local(ptr, o, n) \
76 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
77 (unsigned long)(n), sizeof(*(ptr))))
78 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
79
80 #endif