]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/csky/atomic-machine.h
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / csky / atomic-machine.h
1 /* Atomic operations. C-SKY version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
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 <https://www.gnu.org/licenses/>. */
18
19 #ifndef __CSKY_ATOMIC_H_
20 #define __CSKY_ATOMIC_H_
21
22 #include <stdint.h>
23
24 typedef int32_t atomic32_t;
25 typedef uint32_t uatomic32_t;
26
27 typedef intptr_t atomicptr_t;
28 typedef uintptr_t uatomicptr_t;
29 typedef intmax_t atomic_max_t;
30 typedef uintmax_t uatomic_max_t;
31
32 #define __HAVE_64B_ATOMICS 0
33 #define USE_ATOMIC_COMPILER_BUILTINS 1
34 #define ATOMIC_EXCHANGE_USES_CAS 1
35
36 #define __arch_compare_and_exchange_bool_8_int(mem, newval, oldval, model) \
37 (abort (), 0)
38
39 #define __arch_compare_and_exchange_bool_16_int(mem, newval, oldval, model) \
40 (abort (), 0)
41
42 #define __arch_compare_and_exchange_bool_32_int(mem, newval, oldval, model) \
43 ({ \
44 typeof (*mem) __oldval = (oldval); \
45 !__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \
46 model, __ATOMIC_RELAXED); \
47 })
48
49 #define __arch_compare_and_exchange_bool_64_int(mem, newval, oldval, model) \
50 (abort (), 0)
51
52 #define __arch_compare_and_exchange_val_8_int(mem, newval, oldval, model) \
53 (abort (), (__typeof (*mem)) 0)
54
55 #define __arch_compare_and_exchange_val_16_int(mem, newval, oldval, model) \
56 (abort (), (__typeof (*mem)) 0)
57
58 #define __arch_compare_and_exchange_val_32_int(mem, newval, oldval, model) \
59 ({ \
60 typeof (*mem) __oldval = (oldval); \
61 __atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \
62 model, __ATOMIC_RELAXED); \
63 __oldval; \
64 })
65
66 #define __arch_compare_and_exchange_val_64_int(mem, newval, oldval, model) \
67 (abort (), (__typeof (*mem)) 0)
68
69 #define atomic_compare_and_exchange_bool_acq(mem, new, old) \
70 __atomic_bool_bysize (__arch_compare_and_exchange_bool, int, \
71 mem, new, old, __ATOMIC_ACQUIRE)
72
73 #define atomic_compare_and_exchange_val_acq(mem, new, old) \
74 __atomic_val_bysize (__arch_compare_and_exchange_val, int, \
75 mem, new, old, __ATOMIC_ACQUIRE)
76
77 #endif /* atomic-machine.h */