]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/nios2/atomic-machine.h
19c133343031ed8a40c04f6346df20f5c770e2fa
1 /* Low-level functions for atomic operations. Nios II version.
2 Copyright (C) 2012-2020 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/>. */
19 #ifndef _NIOS2_ATOMIC_MACHINE_H
20 #define _NIOS2_ATOMIC_MACHINE_H 1
24 typedef int32_t atomic32_t
;
25 typedef uint32_t uatomic32_t
;
26 typedef int_fast32_t atomic_fast32_t
;
27 typedef uint_fast32_t uatomic_fast32_t
;
29 typedef intptr_t atomicptr_t
;
30 typedef uintptr_t uatomicptr_t
;
31 typedef intmax_t atomic_max_t
;
32 typedef uintmax_t uatomic_max_t
;
34 #define __HAVE_64B_ATOMICS 0
35 #define USE_ATOMIC_COMPILER_BUILTINS 0
37 /* XXX Is this actually correct? */
38 #define ATOMIC_EXCHANGE_USES_CAS 1
40 #define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
41 (abort (), (__typeof (*mem)) 0)
42 #define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
43 (abort (), (__typeof (*mem)) 0)
44 #define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
45 (abort (), (__typeof (*mem)) 0)
47 #define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval) \
49 #define __arch_compare_and_exchange_bool_16_acq(mem, newval, oldval) \
51 #define __arch_compare_and_exchange_bool_64_acq(mem, newval, oldval) \
54 #define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
56 register int r2 asm ("r2"); \
57 register int* r4 asm ("r4") = (int*)(mem); \
58 register int r5 asm ("r5"); \
59 register int r6 asm ("r6") = (int)(newval); \
60 int retval, orig_oldval = (int)(oldval); \
61 long kernel_cmpxchg = 0x1004; \
65 if (r5 != orig_oldval) \
70 asm volatile ("callr %1\n" \
72 : "r" (kernel_cmpxchg), "r" (r4), "r" (r5), "r" (r6) \
74 if (!r2) { retval = orig_oldval; break; } \
76 (__typeof (*(mem))) retval; \
79 #define __arch_compare_and_exchange_bool_32_acq(mem, newval, oldval) \
81 register int r2 asm ("r2"); \
82 register int *r4 asm ("r4") = (int*)(mem); \
83 register int r5 asm ("r5") = (int)(oldval); \
84 register int r6 asm ("r6") = (int)(newval); \
85 long kernel_cmpxchg = 0x1004; \
86 asm volatile ("callr %1\n" \
88 : "r" (kernel_cmpxchg), "r" (r4), "r" (r5), "r" (r6) \
93 #define atomic_full_barrier() ({ asm volatile ("sync"); })
95 #endif /* _NIOS2_ATOMIC_MACHINE_H */