]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/ia64/bits/atomic.h
Update.
[thirdparty/glibc.git] / sysdeps / ia64 / bits / atomic.h
CommitLineData
b33e6163
RM
1/* Copyright (C) 2003 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, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
18
19#include <stdint.h>
20#include <ia64intrin.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
47
48#define __arch_compare_and_exchange_8_acq(mem, newval, oldval) \
49 (abort (), 0)
50
51#define __arch_compare_and_exchange_16_acq(mem, newval, oldval) \
52 (abort (), 0)
53
54#define __arch_compare_and_exchange_32_acq(mem, newval, oldval) \
55 (!__sync_bool_compare_and_swap_si ((int *) (mem), (int) (long) (oldval), \
56 (int) (long) (newval)))
57
58# define __arch_compare_and_exchange_64_acq(mem, newval, oldval) \
59 (!__sync_bool_compare_and_swap_di ((long *) (mem), (long) (oldval), \
60 (long) (newval)))
61
62#define __arch_compare_and_exchange_32_val_acq(mem, newval, oldval) \
63 __sync_val_compare_and_swap_si ((int *) (mem), (int) (long) (oldval), \
64 (int) (long) (newval))
65
66# define __arch_compare_and_exchange_64_val_acq(mem, newval, oldval) \
67 __sync_val_compare_and_swap_di ((long *) (mem), (long) (oldval), \
68 (long) (newval))
69
70# define atomic_exchange_and_add(mem, value) \
71 ({ \
72 __typeof (*mem) __oldval, __val; \
73 __typeof (mem) __memp = (mem); \
74 __typeof (*mem) __value = (value); \
75 \
76 __val = *__memp; \
77 if (sizeof (*mem) == 4) \
78 do \
bd0fa4ce
UD
79 { \
80 __oldval = __val; \
81 __val = __arch_compare_and_exchange_32_val_acq (__memp, \
82 __oldval + __value, \
83 __oldval); \
84 } \
85 while (__builtin_expect (__val != __oldval, 0)); \
b33e6163
RM
86 else if (sizeof (*mem) == 8) \
87 do \
bd0fa4ce
UD
88 { \
89 __oldval = __val; \
90 __val = __arch_compare_and_exchange_64_val_acq (__memp, \
91 __oldval + __value, \
92 __oldval); \
93 } \
94 while (__builtin_expect (__val != __oldval, 0)); \
b33e6163
RM
95 else \
96 abort (); \
97 __oldval + __value; })