This source file includes following definitions.
- opal_atomic_mb
- opal_atomic_rmb
- opal_atomic_wmb
- opal_atomic_compare_exchange_strong_32
- opal_atomic_fetch_add_32
- opal_atomic_fetch_and_32
- opal_atomic_fetch_or_32
- opal_atomic_fetch_xor_32
- opal_atomic_fetch_sub_32
- opal_atomic_compare_exchange_strong_64
- opal_atomic_fetch_add_64
- opal_atomic_fetch_and_64
- opal_atomic_fetch_or_64
- opal_atomic_fetch_xor_64
- opal_atomic_fetch_sub_64
- opal_atomic_compare_exchange_strong_128
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 #ifndef OPAL_SYS_ARCH_ATOMIC_H
26 #define OPAL_SYS_ARCH_ATOMIC_H 1
27
28
29
30
31
32
33 #define OPAL_HAVE_ATOMIC_MEM_BARRIER 1
34
35 static inline void opal_atomic_mb(void)
36 {
37 __sync_synchronize();
38 }
39
40 static inline void opal_atomic_rmb(void)
41 {
42 __sync_synchronize();
43 }
44
45 static inline void opal_atomic_wmb(void)
46 {
47 __sync_synchronize();
48 }
49
50 #define MB() opal_atomic_mb()
51
52
53
54
55
56
57
58 #define OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_32 1
59
60 static inline bool opal_atomic_compare_exchange_strong_32 (opal_atomic_int32_t *addr, int32_t *oldval, int32_t newval)
61 {
62 int32_t prev = __sync_val_compare_and_swap (addr, *oldval, newval);
63 bool ret = prev == *oldval;
64 *oldval = prev;
65 return ret;
66 }
67
68 #define opal_atomic_compare_exchange_strong_acq_32 opal_atomic_compare_exchange_strong_32
69 #define opal_atomic_compare_exchange_strong_rel_32 opal_atomic_compare_exchange_strong_32
70
71 #define OPAL_HAVE_ATOMIC_MATH_32 1
72
73 #define OPAL_HAVE_ATOMIC_ADD_32 1
74 static inline int32_t opal_atomic_fetch_add_32(opal_atomic_int32_t *addr, int32_t delta)
75 {
76 return __sync_fetch_and_add(addr, delta);
77 }
78
79 #define OPAL_HAVE_ATOMIC_AND_32 1
80 static inline int32_t opal_atomic_fetch_and_32(opal_atomic_int32_t *addr, int32_t value)
81 {
82 return __sync_fetch_and_and(addr, value);
83 }
84
85 #define OPAL_HAVE_ATOMIC_OR_32 1
86 static inline int32_t opal_atomic_fetch_or_32(opal_atomic_int32_t *addr, int32_t value)
87 {
88 return __sync_fetch_and_or(addr, value);
89 }
90
91 #define OPAL_HAVE_ATOMIC_XOR_32 1
92 static inline int32_t opal_atomic_fetch_xor_32(opal_atomic_int32_t *addr, int32_t value)
93 {
94 return __sync_fetch_and_xor(addr, value);
95 }
96
97 #define OPAL_HAVE_ATOMIC_SUB_32 1
98 static inline int32_t opal_atomic_fetch_sub_32(opal_atomic_int32_t *addr, int32_t delta)
99 {
100 return __sync_fetch_and_sub(addr, delta);
101 }
102
103 #if OPAL_ASM_SYNC_HAVE_64BIT
104
105 #define OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_64 1
106
107 static inline bool opal_atomic_compare_exchange_strong_64 (opal_atomic_int64_t *addr, int64_t *oldval, int64_t newval)
108 {
109 int64_t prev = __sync_val_compare_and_swap (addr, *oldval, newval);
110 bool ret = prev == *oldval;
111 *oldval = prev;
112 return ret;
113 }
114
115 #define opal_atomic_compare_exchange_strong_acq_64 opal_atomic_compare_exchange_strong_64
116 #define opal_atomic_compare_exchange_strong_rel_64 opal_atomic_compare_exchange_strong_64
117
118 #define OPAL_HAVE_ATOMIC_MATH_64 1
119 #define OPAL_HAVE_ATOMIC_ADD_64 1
120 static inline int64_t opal_atomic_fetch_add_64(opal_atomic_int64_t *addr, int64_t delta)
121 {
122 return __sync_fetch_and_add(addr, delta);
123 }
124
125 #define OPAL_HAVE_ATOMIC_AND_64 1
126 static inline int64_t opal_atomic_fetch_and_64(opal_atomic_int64_t *addr, int64_t value)
127 {
128 return __sync_fetch_and_and(addr, value);
129 }
130
131 #define OPAL_HAVE_ATOMIC_OR_64 1
132 static inline int64_t opal_atomic_fetch_or_64(opal_atomic_int64_t *addr, int64_t value)
133 {
134 return __sync_fetch_and_or(addr, value);
135 }
136
137 #define OPAL_HAVE_ATOMIC_XOR_64 1
138 static inline int64_t opal_atomic_fetch_xor_64(opal_atomic_int64_t *addr, int64_t value)
139 {
140 return __sync_fetch_and_xor(addr, value);
141 }
142
143 #define OPAL_HAVE_ATOMIC_SUB_64 1
144 static inline int64_t opal_atomic_fetch_sub_64(opal_atomic_int64_t *addr, int64_t delta)
145 {
146 return __sync_fetch_and_sub(addr, delta);
147 }
148
149 #endif
150
151 #if OPAL_HAVE_SYNC_BUILTIN_CSWAP_INT128
152 static inline bool opal_atomic_compare_exchange_strong_128 (opal_atomic_int128_t *addr,
153 opal_int128_t *oldval, opal_int128_t newval)
154 {
155 opal_int128_t prev = __sync_val_compare_and_swap (addr, *oldval, newval);
156 bool ret = prev == *oldval;
157 *oldval = prev;
158 return ret;
159 }
160
161 #define OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_128 1
162
163 #endif
164
165 #endif