]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/microblaze/atomic-machine.h
1 /* Copyright (C) 2003-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <https://www.gnu.org/licenses/>. */
21 #define __HAVE_64B_ATOMICS 0
22 #define USE_ATOMIC_COMPILER_BUILTINS 0
24 /* XXX Is this actually correct? */
25 #define ATOMIC_EXCHANGE_USES_CAS 1
28 /* Microblaze does not have byte and halfword forms of load and reserve and
29 store conditional. So for microblaze we stub out the 8- and 16-bit forms. */
30 #define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval) \
33 #define __arch_compare_and_exchange_bool_16_acq(mem, newval, oldval) \
36 #define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
38 __typeof (*(mem)) __tmp; \
39 __typeof (mem) __memp = (mem); \
43 "1: lwx %0, %3, r0;" \
62 #define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
63 (abort (), (__typeof (*mem)) 0)
65 #define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
67 __typeof (*(mem)) __result; \
68 if (sizeof (*mem) == 4) \
69 __result = __arch_compare_and_exchange_val_32_acq (mem, newval, oldval); \
70 else if (sizeof (*mem) == 8) \
71 __result = __arch_compare_and_exchange_val_64_acq (mem, newval, oldval); \
77 #define atomic_compare_and_exchange_val_rel(mem, newval, oldval) \
79 __typeof (*(mem)) __result; \
80 if (sizeof (*mem) == 4) \
81 __result = __arch_compare_and_exchange_val_32_acq (mem, newval, oldval); \
82 else if (sizeof (*mem) == 8) \
83 __result = __arch_compare_and_exchange_val_64_acq (mem, newval, oldval); \
89 #define __arch_atomic_exchange_32_acq(mem, value) \
91 __typeof (*(mem)) __tmp; \
92 __typeof (mem) __memp = (mem); \
96 "1: lwx %0, %4, r0;" \
100 " addic %1, r0, 0;" \
111 #define __arch_atomic_exchange_64_acq(mem, newval) \
112 (abort (), (__typeof (*mem)) 0)
114 #define atomic_exchange_acq(mem, value) \
116 __typeof (*(mem)) __result; \
117 if (sizeof (*mem) == 4) \
118 __result = __arch_atomic_exchange_32_acq (mem, value); \
119 else if (sizeof (*mem) == 8) \
120 __result = __arch_atomic_exchange_64_acq (mem, value); \
126 #define atomic_exchange_rel(mem, value) \
128 __typeof (*(mem)) __result; \
129 if (sizeof (*mem) == 4) \
130 __result = __arch_atomic_exchange_32_acq (mem, value); \
131 else if (sizeof (*mem) == 8) \
132 __result = __arch_atomic_exchange_64_acq (mem, value); \
138 #define __arch_atomic_exchange_and_add_32(mem, value) \
140 __typeof (*(mem)) __tmp; \
141 __typeof (mem) __memp = (mem); \
144 " addc r0, r0, r0;" \
145 "1: lwx %0, %4, r0;" \
146 " addic %1, r0, 0;" \
150 " addic %1, r0, 0;" \
161 #define __arch_atomic_exchange_and_add_64(mem, value) \
162 (abort (), (__typeof (*mem)) 0)
164 #define atomic_exchange_and_add(mem, value) \
166 __typeof (*(mem)) __result; \
167 if (sizeof (*mem) == 4) \
168 __result = __arch_atomic_exchange_and_add_32 (mem, value); \
169 else if (sizeof (*mem) == 8) \
170 __result = __arch_atomic_exchange_and_add_64 (mem, value); \
176 #define __arch_atomic_increment_val_32(mem) \
178 __typeof (*(mem)) __val; \
181 " addc r0, r0, r0;" \
182 "1: lwx %0, %3, r0;" \
183 " addic %1, r0, 0;" \
187 " addic %1, r0, 0;" \
198 #define __arch_atomic_increment_val_64(mem) \
199 (abort (), (__typeof (*mem)) 0)
201 #define atomic_increment_val(mem) \
203 __typeof (*(mem)) __result; \
204 if (sizeof (*(mem)) == 4) \
205 __result = __arch_atomic_increment_val_32 (mem); \
206 else if (sizeof (*(mem)) == 8) \
207 __result = __arch_atomic_increment_val_64 (mem); \
213 #define atomic_increment(mem) ({ atomic_increment_val (mem); (void) 0; })
215 #define __arch_atomic_decrement_val_32(mem) \
217 __typeof (*(mem)) __val; \
220 " addc r0, r0, r0;" \
221 "1: lwx %0, %3, r0;" \
222 " addic %1, r0, 0;" \
224 " rsubi %0, %0, 1;" \
226 " addic %1, r0, 0;" \
237 #define __arch_atomic_decrement_val_64(mem) \
238 (abort (), (__typeof (*mem)) 0)
240 #define atomic_decrement_val(mem) \
242 __typeof (*(mem)) __result; \
243 if (sizeof (*(mem)) == 4) \
244 __result = __arch_atomic_decrement_val_32 (mem); \
245 else if (sizeof (*(mem)) == 8) \
246 __result = __arch_atomic_decrement_val_64 (mem); \
252 #define atomic_decrement(mem) ({ atomic_decrement_val (mem); (void) 0; })