]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/nios2/atomic-machine.h
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / nios2 / atomic-machine.h
CommitLineData
522e6ee3 1/* Low-level functions for atomic operations. Nios II version.
04277e02 2 Copyright (C) 2012-2019 Free Software Foundation, Inc.
522e6ee3
CLT
3 This file is part of the GNU C Library.
4
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.
9
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.
14
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/>. */
18
de071d19
JM
19#ifndef _NIOS2_ATOMIC_MACHINE_H
20#define _NIOS2_ATOMIC_MACHINE_H 1
522e6ee3
CLT
21
22#include <stdint.h>
23
24typedef int32_t atomic32_t;
25typedef uint32_t uatomic32_t;
26typedef int_fast32_t atomic_fast32_t;
27typedef uint_fast32_t uatomic_fast32_t;
28
29typedef intptr_t atomicptr_t;
30typedef uintptr_t uatomicptr_t;
31typedef intmax_t atomic_max_t;
32typedef uintmax_t uatomic_max_t;
33
34#define __HAVE_64B_ATOMICS 0
35#define USE_ATOMIC_COMPILER_BUILTINS 0
36
12d2dd70
SL
37/* XXX Is this actually correct? */
38#define ATOMIC_EXCHANGE_USES_CAS 1
39
522e6ee3
CLT
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)
46
47#define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval) \
48 (abort (), 0)
49#define __arch_compare_and_exchange_bool_16_acq(mem, newval, oldval) \
50 (abort (), 0)
51#define __arch_compare_and_exchange_bool_64_acq(mem, newval, oldval) \
52 (abort (), 0)
53
54#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
55 ({ \
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; \
62 while (1) \
63 { \
64 r5 = *r4; \
65 if (r5 != orig_oldval) \
66 { \
67 retval = r5; \
68 break; \
69 } \
70 asm volatile ("callr %1\n" \
71 : "=r" (r2) \
72 : "r" (kernel_cmpxchg), "r" (r4), "r" (r5), "r" (r6) \
73 : "ra", "memory"); \
74 if (!r2) { retval = orig_oldval; break; } \
75 } \
76 (__typeof (*(mem))) retval; \
77 })
78
79#define __arch_compare_and_exchange_bool_32_acq(mem, newval, oldval) \
80 ({ \
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" \
87 : "=r" (r2) \
88 : "r" (kernel_cmpxchg), "r" (r4), "r" (r5), "r" (r6) \
89 : "ra", "memory"); \
90 r2; \
91 })
92
93#define atomic_full_barrier() ({ asm volatile ("sync"); })
94
de071d19 95#endif /* _NIOS2_ATOMIC_MACHINE_H */