Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* Copyright (C) 2003-2019 Free Software Foundation, Inc.
2
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
19#ifndef _AARCH64_ATOMIC_MACHINE_H
20#define _AARCH64_ATOMIC_MACHINE_H 1
21
22#include <stdint.h>
23
24typedef int8_t atomic8_t;
25typedef int16_t atomic16_t;
26typedef int32_t atomic32_t;
27typedef int64_t atomic64_t;
28
29typedef uint8_t uatomic8_t;
30typedef uint16_t uatomic16_t;
31typedef uint32_t uatomic32_t;
32typedef uint64_t uatomic64_t;
33
34typedef intptr_t atomicptr_t;
35typedef uintptr_t uatomicptr_t;
36typedef intmax_t atomic_max_t;
37typedef uintmax_t uatomic_max_t;
38
39#define __HAVE_64B_ATOMICS 1
40#define USE_ATOMIC_COMPILER_BUILTINS 1
41#define ATOMIC_EXCHANGE_USES_CAS 0
42
43/* Compare and exchange.
44 For all "bool" routines, we return FALSE if exchange succesful. */
45
46# define __arch_compare_and_exchange_bool_8_int(mem, newval, oldval, model) \
47 ({ \
48 typeof (*mem) __oldval = (oldval); \
49 !__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \
50 model, __ATOMIC_RELAXED); \
51 })
52
53# define __arch_compare_and_exchange_bool_16_int(mem, newval, oldval, model) \
54 ({ \
55 typeof (*mem) __oldval = (oldval); \
56 !__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \
57 model, __ATOMIC_RELAXED); \
58 })
59
60# define __arch_compare_and_exchange_bool_32_int(mem, newval, oldval, model) \
61 ({ \
62 typeof (*mem) __oldval = (oldval); \
63 !__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \
64 model, __ATOMIC_RELAXED); \
65 })
66
67# define __arch_compare_and_exchange_bool_64_int(mem, newval, oldval, model) \
68 ({ \
69 typeof (*mem) __oldval = (oldval); \
70 !__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \
71 model, __ATOMIC_RELAXED); \
72 })
73
74# define __arch_compare_and_exchange_val_8_int(mem, newval, oldval, model) \
75 ({ \
76 typeof (*mem) __oldval = (oldval); \
77 __atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \
78 model, __ATOMIC_RELAXED); \
79 __oldval; \
80 })
81
82# define __arch_compare_and_exchange_val_16_int(mem, newval, oldval, model) \
83 ({ \
84 typeof (*mem) __oldval = (oldval); \
85 __atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \
86 model, __ATOMIC_RELAXED); \
87 __oldval; \
88 })
89
90# define __arch_compare_and_exchange_val_32_int(mem, newval, oldval, model) \
91 ({ \
92 typeof (*mem) __oldval = (oldval); \
93 __atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \
94 model, __ATOMIC_RELAXED); \
95 __oldval; \
96 })
97
98# define __arch_compare_and_exchange_val_64_int(mem, newval, oldval, model) \
99 ({ \
100 typeof (*mem) __oldval = (oldval); \
101 __atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \
102 model, __ATOMIC_RELAXED); \
103 __oldval; \
104 })
105
106
107/* Compare and exchange with "acquire" semantics, ie barrier after. */
108
109# define atomic_compare_and_exchange_bool_acq(mem, new, old) \
110 __atomic_bool_bysize (__arch_compare_and_exchange_bool, int, \
111 mem, new, old, __ATOMIC_ACQUIRE)
112
113# define atomic_compare_and_exchange_val_acq(mem, new, old) \
114 __atomic_val_bysize (__arch_compare_and_exchange_val, int, \
115 mem, new, old, __ATOMIC_ACQUIRE)
116
117/* Compare and exchange with "release" semantics, ie barrier before. */
118
119# define atomic_compare_and_exchange_val_rel(mem, new, old) \
120 __atomic_val_bysize (__arch_compare_and_exchange_val, int, \
121 mem, new, old, __ATOMIC_RELEASE)
122
123
124/* Atomic exchange (without compare). */
125
126# define __arch_exchange_8_int(mem, newval, model) \
127 __atomic_exchange_n (mem, newval, model)
128
129# define __arch_exchange_16_int(mem, newval, model) \
130 __atomic_exchange_n (mem, newval, model)
131
132# define __arch_exchange_32_int(mem, newval, model) \
133 __atomic_exchange_n (mem, newval, model)
134
135# define __arch_exchange_64_int(mem, newval, model) \
136 __atomic_exchange_n (mem, newval, model)
137
138# define atomic_exchange_acq(mem, value) \
139 __atomic_val_bysize (__arch_exchange, int, mem, value, __ATOMIC_ACQUIRE)
140
141# define atomic_exchange_rel(mem, value) \
142 __atomic_val_bysize (__arch_exchange, int, mem, value, __ATOMIC_RELEASE)
143
144
145/* Atomically add value and return the previous (unincremented) value. */
146
147# define __arch_exchange_and_add_8_int(mem, value, model) \
148 __atomic_fetch_add (mem, value, model)
149
150# define __arch_exchange_and_add_16_int(mem, value, model) \
151 __atomic_fetch_add (mem, value, model)
152
153# define __arch_exchange_and_add_32_int(mem, value, model) \
154 __atomic_fetch_add (mem, value, model)
155
156# define __arch_exchange_and_add_64_int(mem, value, model) \
157 __atomic_fetch_add (mem, value, model)
158
159# define atomic_exchange_and_add_acq(mem, value) \
160 __atomic_val_bysize (__arch_exchange_and_add, int, mem, value, \
161 __ATOMIC_ACQUIRE)
162
163# define atomic_exchange_and_add_rel(mem, value) \
164 __atomic_val_bysize (__arch_exchange_and_add, int, mem, value, \
165 __ATOMIC_RELEASE)
166
167/* Barrier macro. */
168#define atomic_full_barrier() __sync_synchronize()
169
170#endif
171

Warning: That file was not part of the compilation database. It may have many parsing errors.