]>
Commit | Line | Data |
---|---|---|
0a9d1b3b | 1 | /* Atomic operations. sparcv9 version. |
b01fe5f7 | 2 | Copyright (C) 2003, 2006 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 | |
17 | License along with the GNU C Library; if not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
19 | 02111-1307 USA. */ | |
20 | ||
21 | #include <stdint.h> | |
22 | ||
23 | typedef int8_t atomic8_t; | |
24 | typedef uint8_t uatomic8_t; | |
25 | typedef int_fast8_t atomic_fast8_t; | |
26 | typedef uint_fast8_t uatomic_fast8_t; | |
27 | ||
28 | typedef int16_t atomic16_t; | |
29 | typedef uint16_t uatomic16_t; | |
30 | typedef int_fast16_t atomic_fast16_t; | |
31 | typedef uint_fast16_t uatomic_fast16_t; | |
32 | ||
33 | typedef int32_t atomic32_t; | |
34 | typedef uint32_t uatomic32_t; | |
35 | typedef int_fast32_t atomic_fast32_t; | |
36 | typedef uint_fast32_t uatomic_fast32_t; | |
37 | ||
38 | typedef int64_t atomic64_t; | |
39 | typedef uint64_t uatomic64_t; | |
40 | typedef int_fast64_t atomic_fast64_t; | |
41 | typedef uint_fast64_t uatomic_fast64_t; | |
42 | ||
43 | typedef intptr_t atomicptr_t; | |
44 | typedef uintptr_t uatomicptr_t; | |
45 | typedef intmax_t atomic_max_t; | |
46 | typedef uintmax_t uatomic_max_t; | |
47 | ||
48 | ||
49 | #define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \ | |
4661a153 | 50 | (abort (), (__typeof (*mem)) 0) |
0a9d1b3b RM |
51 | |
52 | #define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \ | |
4661a153 | 53 | (abort (), (__typeof (*mem)) 0) |
0a9d1b3b RM |
54 | |
55 | #define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \ | |
56 | ({ \ | |
57 | __typeof (*(mem)) __acev_tmp; \ | |
58 | __typeof (mem) __acev_mem = (mem); \ | |
59 | __asm __volatile ("cas [%4], %2, %0" \ | |
60 | : "=r" (__acev_tmp), "=m" (*__acev_mem) \ | |
61 | : "r" (oldval), "m" (*__acev_mem), "r" (__acev_mem), \ | |
c8e82b4a | 62 | "0" (newval) : "memory"); \ |
0a9d1b3b RM |
63 | __acev_tmp; }) |
64 | ||
65 | /* This can be implemented if needed. */ | |
66 | #define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \ | |
4661a153 | 67 | (abort (), (__typeof (*mem)) 0) |
0a9d1b3b | 68 | |
949ec764 | 69 | #define atomic_exchange_acq(mem, newvalue) \ |
0a9d1b3b RM |
70 | ({ __typeof (*(mem)) __oldval; \ |
71 | __typeof (mem) __memp = (mem); \ | |
72 | __typeof (*(mem)) __value = (newvalue); \ | |
73 | \ | |
74 | if (sizeof (*(mem)) == 4) \ | |
75 | __asm ("swap %0, %1" \ | |
76 | : "=m" (*__memp), "=r" (__oldval) \ | |
c8e82b4a | 77 | : "m" (*__memp), "1" (__value) : "memory"); \ |
0a9d1b3b RM |
78 | else \ |
79 | abort (); \ | |
80 | __oldval; }) | |
81 | ||
b01fe5f7 UD |
82 | #define atomic_compare_and_exchange_val_24_acq(mem, newval, oldval) \ |
83 | atomic_compare_and_exchange_val_acq (mem, newval, oldval) | |
84 | ||
85 | #define atomic_exchange_24_rel(mem, newval) \ | |
86 | atomic_exchange_rel (mem, newval) | |
87 | ||
0a9d1b3b RM |
88 | #define atomic_full_barrier() \ |
89 | __asm __volatile ("membar #LoadLoad | #LoadStore" \ | |
90 | " | #StoreLoad | #StoreStore" : : : "memory") | |
91 | #define atomic_read_barrier() \ | |
92 | __asm __volatile ("membar #LoadLoad | #LoadStore" : : : "memory") | |
93 | #define atomic_write_barrier() \ | |
94 | __asm __volatile ("membar #StoreLoad | #StoreStore" : : : "memory") |