]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/sparc/sparc32/sparcv9/atomic-machine.h
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / sparc / sparc32 / sparcv9 / atomic-machine.h
CommitLineData
0a9d1b3b 1/* Atomic operations. sparcv9 version.
04277e02 2 Copyright (C) 2003-2019 Free Software Foundation, Inc.
0a9d1b3b
RM
3 This file is part of the GNU C Library.
4 Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
0a9d1b3b
RM
19
20#include <stdint.h>
21
22typedef int8_t atomic8_t;
23typedef uint8_t uatomic8_t;
24typedef int_fast8_t atomic_fast8_t;
25typedef uint_fast8_t uatomic_fast8_t;
26
27typedef int16_t atomic16_t;
28typedef uint16_t uatomic16_t;
29typedef int_fast16_t atomic_fast16_t;
30typedef uint_fast16_t uatomic_fast16_t;
31
32typedef int32_t atomic32_t;
33typedef uint32_t uatomic32_t;
34typedef int_fast32_t atomic_fast32_t;
35typedef uint_fast32_t uatomic_fast32_t;
36
37typedef int64_t atomic64_t;
38typedef uint64_t uatomic64_t;
39typedef int_fast64_t atomic_fast64_t;
40typedef uint_fast64_t uatomic_fast64_t;
41
42typedef intptr_t atomicptr_t;
43typedef uintptr_t uatomicptr_t;
44typedef intmax_t atomic_max_t;
45typedef uintmax_t uatomic_max_t;
46
1ea339b6
TR
47#define __HAVE_64B_ATOMICS 0
48#define USE_ATOMIC_COMPILER_BUILTINS 0
49
12d2dd70
SL
50/* XXX Is this actually correct? */
51#define ATOMIC_EXCHANGE_USES_CAS 0
52
0a9d1b3b
RM
53
54#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
4661a153 55 (abort (), (__typeof (*mem)) 0)
0a9d1b3b
RM
56
57#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
4661a153 58 (abort (), (__typeof (*mem)) 0)
0a9d1b3b
RM
59
60#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
61({ \
62 __typeof (*(mem)) __acev_tmp; \
63 __typeof (mem) __acev_mem = (mem); \
bae8e7f5
DM
64 if (__builtin_constant_p (oldval) && (oldval) == 0) \
65 __asm __volatile ("cas [%3], %%g0, %0" \
66 : "=r" (__acev_tmp), "=m" (*__acev_mem) \
67 : "m" (*__acev_mem), "r" (__acev_mem), \
68 "0" (newval) : "memory"); \
69 else \
70 __asm __volatile ("cas [%4], %2, %0" \
71 : "=r" (__acev_tmp), "=m" (*__acev_mem) \
72 : "r" (oldval), "m" (*__acev_mem), "r" (__acev_mem), \
73 "0" (newval) : "memory"); \
0a9d1b3b
RM
74 __acev_tmp; })
75
76/* This can be implemented if needed. */
77#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
4661a153 78 (abort (), (__typeof (*mem)) 0)
0a9d1b3b 79
949ec764 80#define atomic_exchange_acq(mem, newvalue) \
0a9d1b3b
RM
81 ({ __typeof (*(mem)) __oldval; \
82 __typeof (mem) __memp = (mem); \
83 __typeof (*(mem)) __value = (newvalue); \
84 \
85 if (sizeof (*(mem)) == 4) \
86 __asm ("swap %0, %1" \
87 : "=m" (*__memp), "=r" (__oldval) \
c8e82b4a 88 : "m" (*__memp), "1" (__value) : "memory"); \
0a9d1b3b
RM
89 else \
90 abort (); \
91 __oldval; })
92
b01fe5f7
UD
93#define atomic_compare_and_exchange_val_24_acq(mem, newval, oldval) \
94 atomic_compare_and_exchange_val_acq (mem, newval, oldval)
95
96#define atomic_exchange_24_rel(mem, newval) \
97 atomic_exchange_rel (mem, newval)
98
0a9d1b3b
RM
99#define atomic_full_barrier() \
100 __asm __volatile ("membar #LoadLoad | #LoadStore" \
101 " | #StoreLoad | #StoreStore" : : : "memory")
102#define atomic_read_barrier() \
103 __asm __volatile ("membar #LoadLoad | #LoadStore" : : : "memory")
104#define atomic_write_barrier() \
ff9dbdc0 105 __asm __volatile ("membar #LoadStore | #StoreStore" : : : "memory")
4eb984d3
TR
106
107extern void __cpu_relax (void);
c59f721c 108#define atomic_spin_nop() __cpu_relax ()