3 // Copyright (C) 2008, 2009
4 // Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // Under Section 7 of GPL version 3, you are granted additional
18 // permissions described in the GCC Runtime Library Exception, version
19 // 3.1, as published by the Free Software Foundation.
21 // You should have received a copy of the GNU General Public License and
22 // a copy of the GCC Runtime Library Exception along with this program;
23 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 // <http://www.gnu.org/licenses/>.
26 /** @file bits/atomicfwd_c.h
27 * This is an internal header file, included by other library headers.
28 * You should not attempt to use it directly.
33 #define _ATOMIC_MEMBER_ ((__a)->_M_i)
35 // POD base classes for atomic intgral types.
36 struct __atomic_bool_base
41 struct __atomic_char_base
46 struct __atomic_schar_base
51 struct __atomic_uchar_base
56 struct __atomic_short_base
61 struct __atomic_ushort_base
66 struct __atomic_int_base
71 struct __atomic_uint_base
76 struct __atomic_long_base
81 struct __atomic_ulong_base
86 struct __atomic_llong_base
91 struct __atomic_ullong_base
93 unsigned long long _M_i;
96 struct __atomic_wchar_t_base
101 typedef struct __atomic_flag_base atomic_flag;
102 typedef struct __atomic_address_base atomic_address;
103 typedef struct __atomic_bool_base atomic_bool;
104 typedef struct __atomic_char_base atomic_char;
105 typedef struct __atomic_schar_base atomic_schar;
106 typedef struct __atomic_uchar_base atomic_uchar;
107 typedef struct __atomic_short_base atomic_short;
108 typedef struct __atomic_ushort_base atomic_ushort;
109 typedef struct __atomic_int_base atomic_int;
110 typedef struct __atomic_uint_base atomic_uint;
111 typedef struct __atomic_long_base atomic_long;
112 typedef struct __atomic_ulong_base atomic_ulong;
113 typedef struct __atomic_llong_base atomic_llong;
114 typedef struct __atomic_ullong_base atomic_ullong;
115 typedef struct __atomic_wchar_t_base atomic_wchar_t;
116 typedef struct __atomic_short_base atomic_char16_t;
117 typedef struct __atomic_int_base atomic_char32_t;
119 #define atomic_is_lock_free(__a) \
122 #define atomic_load_explicit(__a, __x) \
123 _ATOMIC_LOAD_(__a, __x)
125 #define atomic_load(__a) \
126 atomic_load_explicit(__a, memory_order_seq_cst)
128 #define atomic_store_explicit(__a, __m, __x) \
129 _ATOMIC_STORE_(__a, __m, __x)
131 #define atomic_store(__a, __m) \
132 atomic_store_explicit(__a, __m, memory_order_seq_cst)
134 #define atomic_exchange_explicit(__a, __m, __x) \
135 _ATOMIC_MODIFY_(__a, =, __m, __x)
137 #define atomic_exchange(__a, __m) \
138 atomic_exchange_explicit(__a, __m, memory_order_seq_cst)
140 #define atomic_compare_exchange_explicit(__a, __e, __m, __x, __y) \
141 _ATOMIC_CMPEXCHNG_(__a, __e, __m, __x)
143 #define atomic_compare_exchange(__a, __e, __m) \
144 _ATOMIC_CMPEXCHNG_(__a, __e, __m, memory_order_seq_cst)
146 #define atomic_fetch_add_explicit(__a, __m, __x) \
147 _ATOMIC_MODIFY_(__a, +=, __m, __x)
149 #define atomic_fetch_add(__a, __m) \
150 atomic_fetch_add_explicit(__a, __m, memory_order_seq_cst)
152 #define atomic_fetch_sub_explicit(__a, __m, __x) \
153 _ATOMIC_MODIFY_(__a, -=, __m, __x)
155 #define atomic_fetch_sub(__a, __m) \
156 atomic_fetch_sub_explicit(__a, __m, memory_order_seq_cst)
158 #define atomic_fetch_and_explicit(__a, __m, __x) \
159 _ATOMIC_MODIFY_(__a, &=, __m, __x)
161 #define atomic_fetch_and(__a, __m) \
162 atomic_fetch_and_explicit(__a, __m, memory_order_seq_cst)
164 #define atomic_fetch_or_explicit(__a, __m, __x) \
165 _ATOMIC_MODIFY_(__a, |=, __m, __x)
167 #define atomic_fetch_or(__a, __m) \
168 atomic_fetch_or_explicit(__a, __m, memory_order_seq_cst)
170 #define atomic_fetch_xor_explicit(__a, __m, __x) \
171 _ATOMIC_MODIFY_(__a, ^=, __m, __x)
173 #define atomic_fetch_xor(__a, __m) \
174 atomic_fetch_xor_explicit(__a, __m, memory_order_seq_cst)