]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/microblaze/atomic-machine.h
1 /* Copyright (C) 2003-2017 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 <http://www.gnu.org/licenses/>. */
23 typedef int8_t atomic8_t
;
24 typedef uint8_t uatomic8_t
;
25 typedef int_fast8_t atomic_fast8_t
;
26 typedef uint_fast8_t uatomic_fast8_t
;
28 typedef int32_t atomic32_t
;
29 typedef uint32_t uatomic32_t
;
30 typedef int_fast32_t atomic_fast32_t
;
31 typedef uint_fast32_t uatomic_fast32_t
;
33 typedef intptr_t atomicptr_t
;
34 typedef uintptr_t uatomicptr_t
;
35 typedef intmax_t atomic_max_t
;
36 typedef uintmax_t uatomic_max_t
;
38 #define __HAVE_64B_ATOMICS 0
39 #define USE_ATOMIC_COMPILER_BUILTINS 0
42 /* Microblaze does not have byte and halfword forms of load and reserve and
43 store conditional. So for microblaze we stub out the 8- and 16-bit forms. */
44 #define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval) \
47 #define __arch_compare_and_exchange_bool_16_acq(mem, newval, oldval) \
50 #define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
52 __typeof (*(mem)) __tmp; \
53 __typeof (mem) __memp = (mem); \
57 "1: lwx %0, %3, r0;" \
76 #define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
77 (abort (), (__typeof (*mem)) 0)
79 #define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
81 __typeof (*(mem)) __result; \
82 if (sizeof (*mem) == 4) \
83 __result = __arch_compare_and_exchange_val_32_acq (mem, newval, oldval); \
84 else if (sizeof (*mem) == 8) \
85 __result = __arch_compare_and_exchange_val_64_acq (mem, newval, oldval); \
91 #define atomic_compare_and_exchange_val_rel(mem, newval, oldval) \
93 __typeof (*(mem)) __result; \
94 if (sizeof (*mem) == 4) \
95 __result = __arch_compare_and_exchange_val_32_acq (mem, newval, oldval); \
96 else if (sizeof (*mem) == 8) \
97 __result = __arch_compare_and_exchange_val_64_acq (mem, newval, oldval); \
103 #define __arch_atomic_exchange_32_acq(mem, value) \
105 __typeof (*(mem)) __tmp; \
106 __typeof (mem) __memp = (mem); \
109 " addc r0, r0, r0;" \
110 "1: lwx %0, %4, r0;" \
111 " addic %1, r0, 0;" \
114 " addic %1, r0, 0;" \
125 #define __arch_atomic_exchange_64_acq(mem, newval) \
126 (abort (), (__typeof (*mem)) 0)
128 #define atomic_exchange_acq(mem, value) \
130 __typeof (*(mem)) __result; \
131 if (sizeof (*mem) == 4) \
132 __result = __arch_atomic_exchange_32_acq (mem, value); \
133 else if (sizeof (*mem) == 8) \
134 __result = __arch_atomic_exchange_64_acq (mem, value); \
140 #define atomic_exchange_rel(mem, value) \
142 __typeof (*(mem)) __result; \
143 if (sizeof (*mem) == 4) \
144 __result = __arch_atomic_exchange_32_acq (mem, value); \
145 else if (sizeof (*mem) == 8) \
146 __result = __arch_atomic_exchange_64_acq (mem, value); \
152 #define __arch_atomic_exchange_and_add_32(mem, value) \
154 __typeof (*(mem)) __tmp; \
155 __typeof (mem) __memp = (mem); \
158 " addc r0, r0, r0;" \
159 "1: lwx %0, %4, r0;" \
160 " addic %1, r0, 0;" \
164 " addic %1, r0, 0;" \
175 #define __arch_atomic_exchange_and_add_64(mem, value) \
176 (abort (), (__typeof (*mem)) 0)
178 #define atomic_exchange_and_add(mem, value) \
180 __typeof (*(mem)) __result; \
181 if (sizeof (*mem) == 4) \
182 __result = __arch_atomic_exchange_and_add_32 (mem, value); \
183 else if (sizeof (*mem) == 8) \
184 __result = __arch_atomic_exchange_and_add_64 (mem, value); \
190 #define __arch_atomic_increment_val_32(mem) \
192 __typeof (*(mem)) __val; \
195 " addc r0, r0, r0;" \
196 "1: lwx %0, %3, r0;" \
197 " addic %1, r0, 0;" \
201 " addic %1, r0, 0;" \
212 #define __arch_atomic_increment_val_64(mem) \
213 (abort (), (__typeof (*mem)) 0)
215 #define atomic_increment_val(mem) \
217 __typeof (*(mem)) __result; \
218 if (sizeof (*(mem)) == 4) \
219 __result = __arch_atomic_increment_val_32 (mem); \
220 else if (sizeof (*(mem)) == 8) \
221 __result = __arch_atomic_increment_val_64 (mem); \
227 #define atomic_increment(mem) ({ atomic_increment_val (mem); (void) 0; })
229 #define __arch_atomic_decrement_val_32(mem) \
231 __typeof (*(mem)) __val; \
234 " addc r0, r0, r0;" \
235 "1: lwx %0, %3, r0;" \
236 " addic %1, r0, 0;" \
238 " rsubi %0, %0, 1;" \
240 " addic %1, r0, 0;" \
251 #define __arch_atomic_decrement_val_64(mem) \
252 (abort (), (__typeof (*mem)) 0)
254 #define atomic_decrement_val(mem) \
256 __typeof (*(mem)) __result; \
257 if (sizeof (*(mem)) == 4) \
258 __result = __arch_atomic_decrement_val_32 (mem); \
259 else if (sizeof (*(mem)) == 8) \
260 __result = __arch_atomic_decrement_val_64 (mem); \
266 #define atomic_decrement(mem) ({ atomic_decrement_val (mem); (void) 0; })