]>
git.ipfire.org Git - thirdparty/glibc.git/blob - 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.
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 __CSKY_ATOMIC_H_
20 #define __CSKY_ATOMIC_H_
24 typedef int32_t atomic32_t
;
25 typedef uint32_t uatomic32_t
;
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
;
32 #define __HAVE_64B_ATOMICS 0
33 #define USE_ATOMIC_COMPILER_BUILTINS 1
34 #define ATOMIC_EXCHANGE_USES_CAS 1
36 #define __arch_compare_and_exchange_bool_8_int(mem, newval, oldval, model) \
39 #define __arch_compare_and_exchange_bool_16_int(mem, newval, oldval, model) \
42 #define __arch_compare_and_exchange_bool_32_int(mem, newval, oldval, model) \
44 typeof (*mem) __oldval = (oldval); \
45 !__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \
46 model, __ATOMIC_RELAXED); \
49 #define __arch_compare_and_exchange_bool_64_int(mem, newval, oldval, model) \
52 #define __arch_compare_and_exchange_val_8_int(mem, newval, oldval, model) \
53 (abort (), (__typeof (*mem)) 0)
55 #define __arch_compare_and_exchange_val_16_int(mem, newval, oldval, model) \
56 (abort (), (__typeof (*mem)) 0)
58 #define __arch_compare_and_exchange_val_32_int(mem, newval, oldval, model) \
60 typeof (*mem) __oldval = (oldval); \
61 __atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \
62 model, __ATOMIC_RELAXED); \
66 #define __arch_compare_and_exchange_val_64_int(mem, newval, oldval, model) \
67 (abort (), (__typeof (*mem)) 0)
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)
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)
77 #endif /* atomic-machine.h */