]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/m68k/coldfire/atomic-machine.h
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / m68k / coldfire / atomic-machine.h
1 /* Copyright (C) 2003-2016 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18 #ifndef _ATOMIC_MACHINE_H
19 #define _ATOMIC_MACHINE_H 1
20
21 #include <stdint.h>
22
23 /* Coldfire has no atomic compare-and-exchange operation, and the
24 kernel provides no userspace atomicity operations. Here we just
25 use generic non-atomic implementations instead. */
26
27 typedef int8_t atomic8_t;
28 typedef uint8_t uatomic8_t;
29 typedef int_fast8_t atomic_fast8_t;
30 typedef uint_fast8_t uatomic_fast8_t;
31
32 typedef int16_t atomic16_t;
33 typedef uint16_t uatomic16_t;
34 typedef int_fast16_t atomic_fast16_t;
35 typedef uint_fast16_t uatomic_fast16_t;
36
37 typedef int32_t atomic32_t;
38 typedef uint32_t uatomic32_t;
39 typedef int_fast32_t atomic_fast32_t;
40 typedef uint_fast32_t uatomic_fast32_t;
41
42 typedef int64_t atomic64_t;
43 typedef uint64_t uatomic64_t;
44 typedef int_fast64_t atomic_fast64_t;
45 typedef uint_fast64_t uatomic_fast64_t;
46
47 typedef intptr_t atomicptr_t;
48 typedef uintptr_t uatomicptr_t;
49 typedef intmax_t atomic_max_t;
50 typedef uintmax_t uatomic_max_t;
51
52 /* If we have just non-atomic operations, we can as well make them wide. */
53 #define __HAVE_64B_ATOMICS 1
54 #define USE_ATOMIC_COMPILER_BUILTINS 0
55
56 /* The only basic operation needed is compare and exchange. */
57 #define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
58 ({ __typeof (mem) __gmemp = (mem); \
59 __typeof (*mem) __gret = *__gmemp; \
60 __typeof (*mem) __gnewval = (newval); \
61 \
62 if (__gret == (oldval)) \
63 *__gmemp = __gnewval; \
64 __gret; })
65
66 #define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
67 ({ __typeof (mem) __gmemp = (mem); \
68 __typeof (*mem) __gnewval = (newval); \
69 \
70 *__gmemp == (oldval) ? (*__gmemp = __gnewval, 0) : 1; })
71
72 #endif