1 /* Copyright (C) 2003-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
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 <http://www.gnu.org/licenses/>. */
21 typedef int8_t atomic8_t;
22 typedef uint8_t uatomic8_t;
23 typedef int_fast8_t atomic_fast8_t;
24 typedef uint_fast8_t uatomic_fast8_t;
26 typedef int16_t atomic16_t;
27 typedef uint16_t uatomic16_t;
28 typedef int_fast16_t atomic_fast16_t;
29 typedef uint_fast16_t uatomic_fast16_t;
31 typedef int32_t atomic32_t;
32 typedef uint32_t uatomic32_t;
33 typedef int_fast32_t atomic_fast32_t;
34 typedef uint_fast32_t uatomic_fast32_t;
36 typedef int64_t atomic64_t;
37 typedef uint64_t uatomic64_t;
38 typedef int_fast64_t atomic_fast64_t;
39 typedef uint_fast64_t uatomic_fast64_t;
41 typedef intptr_t atomicptr_t;
42 typedef uintptr_t uatomicptr_t;
43 typedef intmax_t atomic_max_t;
44 typedef uintmax_t uatomic_max_t;
47 #define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
48 (abort (), (__typeof (*mem)) 0)
50 #define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
51 (abort (), (__typeof (*mem)) 0)
53 #define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
54 ({ __typeof (mem) __archmem = (mem); \
55 __typeof (*mem) __archold = (oldval); \
56 __asm __volatile ("cs %0,%2,%1" \
57 : "+d" (__archold), "=Q" (*__archmem) \
58 : "d" (newval), "m" (*__archmem) : "cc", "memory" ); \
62 # define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
63 ({ __typeof (mem) __archmem = (mem); \
64 __typeof (*mem) __archold = (oldval); \
65 __asm __volatile ("csg %0,%2,%1" \
66 : "+d" (__archold), "=Q" (*__archmem) \
67 : "d" ((long) (newval)), "m" (*__archmem) : "cc", "memory" ); \
70 /* For 31 bit we do not really need 64-bit compare-and-exchange. We can
71 implement them by use of the csd instruction. The straightforward
72 implementation causes warnings so we skip the definition for now. */
73 # define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
74 (abort (), (__typeof (*mem)) 0)