]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/nios2/bits/atomic.h
1 /* Low-level functions for atomic operations. Nios II version.
2 Copyright (C) 2012-2015 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/>. */
19 #ifndef _NIOS2_BITS_ATOMIC_H
20 #define _NIOS2_BITS_ATOMIC_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 #define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
38 (abort (), (__typeof (*mem)) 0)
39 #define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
40 (abort (), (__typeof (*mem)) 0)
41 #define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
42 (abort (), (__typeof (*mem)) 0)
44 #define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval) \
46 #define __arch_compare_and_exchange_bool_16_acq(mem, newval, oldval) \
48 #define __arch_compare_and_exchange_bool_64_acq(mem, newval, oldval) \
51 #define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
53 register int r2 asm ("r2"); \
54 register int* r4 asm ("r4") = (int*)(mem); \
55 register int r5 asm ("r5"); \
56 register int r6 asm ("r6") = (int)(newval); \
57 int retval, orig_oldval = (int)(oldval); \
58 long kernel_cmpxchg = 0x1004; \
62 if (r5 != orig_oldval) \
67 asm volatile ("callr %1\n" \
69 : "r" (kernel_cmpxchg), "r" (r4), "r" (r5), "r" (r6) \
71 if (!r2) { retval = orig_oldval; break; } \
73 (__typeof (*(mem))) retval; \
76 #define __arch_compare_and_exchange_bool_32_acq(mem, newval, oldval) \
78 register int r2 asm ("r2"); \
79 register int *r4 asm ("r4") = (int*)(mem); \
80 register int r5 asm ("r5") = (int)(oldval); \
81 register int r6 asm ("r6") = (int)(newval); \
82 long kernel_cmpxchg = 0x1004; \
83 asm volatile ("callr %1\n" \
85 : "r" (kernel_cmpxchg), "r" (r4), "r" (r5), "r" (r6) \
90 #define atomic_full_barrier() ({ asm volatile ("sync"); })
92 #endif /* _NIOS2_BITS_ATOMIC_H */