ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
stdatomic.h
Go to the documentation of this file.
1/*===---- stdatomic.h - Standard header for atomic types and operations -----===
2 *
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 *
7 *===-----------------------------------------------------------------------===
8 */
9
10#ifndef __CLANG_STDATOMIC_H
11#define __CLANG_STDATOMIC_H
12
13/* If we're hosted, fall back to the system's stdatomic.h. FreeBSD, for
14 * example, already has a Clang-compatible stdatomic.h header.
15 */
16#if __STDC_HOSTED__ && __has_include_next(<stdatomic.h>)
17# include_next <stdatomic.h>
18#else
19
20#include <stddef.h>
21#include <stdint.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* 7.17.1 Introduction */
28
29#define ATOMIC_BOOL_LOCK_FREE __CLANG_ATOMIC_BOOL_LOCK_FREE
30#define ATOMIC_CHAR_LOCK_FREE __CLANG_ATOMIC_CHAR_LOCK_FREE
31#define ATOMIC_CHAR16_T_LOCK_FREE __CLANG_ATOMIC_CHAR16_T_LOCK_FREE
32#define ATOMIC_CHAR32_T_LOCK_FREE __CLANG_ATOMIC_CHAR32_T_LOCK_FREE
33#define ATOMIC_WCHAR_T_LOCK_FREE __CLANG_ATOMIC_WCHAR_T_LOCK_FREE
34#define ATOMIC_SHORT_LOCK_FREE __CLANG_ATOMIC_SHORT_LOCK_FREE
35#define ATOMIC_INT_LOCK_FREE __CLANG_ATOMIC_INT_LOCK_FREE
36#define ATOMIC_LONG_LOCK_FREE __CLANG_ATOMIC_LONG_LOCK_FREE
37#define ATOMIC_LLONG_LOCK_FREE __CLANG_ATOMIC_LLONG_LOCK_FREE
38#define ATOMIC_POINTER_LOCK_FREE __CLANG_ATOMIC_POINTER_LOCK_FREE
39
40/* 7.17.2 Initialization */
41
42#define ATOMIC_VAR_INIT(value) (value)
43#define atomic_init __c11_atomic_init
44
45/* 7.17.3 Order and consistency */
46
47typedef enum memory_order {
48 memory_order_relaxed = __ATOMIC_RELAXED,
49 memory_order_consume = __ATOMIC_CONSUME,
50 memory_order_acquire = __ATOMIC_ACQUIRE,
51 memory_order_release = __ATOMIC_RELEASE,
52 memory_order_acq_rel = __ATOMIC_ACQ_REL,
53 memory_order_seq_cst = __ATOMIC_SEQ_CST
55
56#define kill_dependency(y) (y)
57
58/* 7.17.4 Fences */
59
60/* These should be provided by the libc implementation. */
63
64#define atomic_thread_fence(order) __c11_atomic_thread_fence(order)
65#define atomic_signal_fence(order) __c11_atomic_signal_fence(order)
66
67/* 7.17.5 Lock-free property */
68
69#define atomic_is_lock_free(obj) __c11_atomic_is_lock_free(sizeof(*(obj)))
70
71/* 7.17.6 Atomic integer types */
72
73#ifdef __cplusplus
74typedef _Atomic(bool) atomic_bool;
75#else
76typedef _Atomic(_Bool) atomic_bool;
77#endif
78typedef _Atomic(char) atomic_char;
79typedef _Atomic(signed char) atomic_schar;
80typedef _Atomic(unsigned char) atomic_uchar;
81typedef _Atomic(short) atomic_short;
82typedef _Atomic(unsigned short) atomic_ushort;
83typedef _Atomic(int) atomic_int;
84typedef _Atomic(unsigned int) atomic_uint;
85typedef _Atomic(long) atomic_long;
86typedef _Atomic(unsigned long) atomic_ulong;
87typedef _Atomic(long long) atomic_llong;
88typedef _Atomic(unsigned long long) atomic_ullong;
89typedef _Atomic(uint_least16_t) atomic_char16_t;
90typedef _Atomic(uint_least32_t) atomic_char32_t;
91typedef _Atomic(wchar_t) atomic_wchar_t;
92typedef _Atomic(int_least8_t) atomic_int_least8_t;
93typedef _Atomic(uint_least8_t) atomic_uint_least8_t;
94typedef _Atomic(int_least16_t) atomic_int_least16_t;
95typedef _Atomic(uint_least16_t) atomic_uint_least16_t;
96typedef _Atomic(int_least32_t) atomic_int_least32_t;
97typedef _Atomic(uint_least32_t) atomic_uint_least32_t;
98typedef _Atomic(int_least64_t) atomic_int_least64_t;
99typedef _Atomic(uint_least64_t) atomic_uint_least64_t;
100typedef _Atomic(int_fast8_t) atomic_int_fast8_t;
101typedef _Atomic(uint_fast8_t) atomic_uint_fast8_t;
102typedef _Atomic(int_fast16_t) atomic_int_fast16_t;
103typedef _Atomic(uint_fast16_t) atomic_uint_fast16_t;
104typedef _Atomic(int_fast32_t) atomic_int_fast32_t;
105typedef _Atomic(uint_fast32_t) atomic_uint_fast32_t;
106typedef _Atomic(int_fast64_t) atomic_int_fast64_t;
107typedef _Atomic(uint_fast64_t) atomic_uint_fast64_t;
108typedef _Atomic(intptr_t) atomic_intptr_t;
109typedef _Atomic(uintptr_t) atomic_uintptr_t;
110typedef _Atomic(size_t) atomic_size_t;
111typedef _Atomic(ptrdiff_t) atomic_ptrdiff_t;
112typedef _Atomic(intmax_t) atomic_intmax_t;
113typedef _Atomic(uintmax_t) atomic_uintmax_t;
114
115/* 7.17.7 Operations on atomic types */
116
117#define atomic_store(object, desired) __c11_atomic_store(object, desired, __ATOMIC_SEQ_CST)
118#define atomic_store_explicit __c11_atomic_store
119
120#define atomic_load(object) __c11_atomic_load(object, __ATOMIC_SEQ_CST)
121#define atomic_load_explicit __c11_atomic_load
122
123#define atomic_exchange(object, desired) __c11_atomic_exchange(object, desired, __ATOMIC_SEQ_CST)
124#define atomic_exchange_explicit __c11_atomic_exchange
125
126#define atomic_compare_exchange_strong(object, expected, desired) __c11_atomic_compare_exchange_strong(object, expected, desired, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
127#define atomic_compare_exchange_strong_explicit __c11_atomic_compare_exchange_strong
128
129#define atomic_compare_exchange_weak(object, expected, desired) __c11_atomic_compare_exchange_weak(object, expected, desired, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
130#define atomic_compare_exchange_weak_explicit __c11_atomic_compare_exchange_weak
131
132#define atomic_fetch_add(object, operand) __c11_atomic_fetch_add(object, operand, __ATOMIC_SEQ_CST)
133#define atomic_fetch_add_explicit __c11_atomic_fetch_add
134
135#define atomic_fetch_sub(object, operand) __c11_atomic_fetch_sub(object, operand, __ATOMIC_SEQ_CST)
136#define atomic_fetch_sub_explicit __c11_atomic_fetch_sub
137
138#define atomic_fetch_or(object, operand) __c11_atomic_fetch_or(object, operand, __ATOMIC_SEQ_CST)
139#define atomic_fetch_or_explicit __c11_atomic_fetch_or
140
141#define atomic_fetch_xor(object, operand) __c11_atomic_fetch_xor(object, operand, __ATOMIC_SEQ_CST)
142#define atomic_fetch_xor_explicit __c11_atomic_fetch_xor
143
144#define atomic_fetch_and(object, operand) __c11_atomic_fetch_and(object, operand, __ATOMIC_SEQ_CST)
145#define atomic_fetch_and_explicit __c11_atomic_fetch_and
146
147/* 7.17.8 Atomic flag type and operations */
148
149typedef struct atomic_flag { atomic_bool _Value; } atomic_flag;
150
151#define ATOMIC_FLAG_INIT { 0 }
152
153/* These should be provided by the libc implementation. */
154#ifdef __cplusplus
157#else
160#endif
163
164#define atomic_flag_test_and_set(object) __c11_atomic_exchange(&(object)->_Value, 1, __ATOMIC_SEQ_CST)
165#define atomic_flag_test_and_set_explicit(object, order) __c11_atomic_exchange(&(object)->_Value, 1, order)
166
167#define atomic_flag_clear(object) __c11_atomic_store(&(object)->_Value, 0, __ATOMIC_SEQ_CST)
168#define atomic_flag_clear_explicit(object, order) __c11_atomic_store(&(object)->_Value, 0, order)
169
170#ifdef __cplusplus
171}
172#endif
173
174#endif /* __STDC_HOSTED__ */
175#endif /* __CLANG_STDATOMIC_H */
176
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type,...
memory_order
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
memory_order
Definition stdatomic.h:47
@ memory_order_consume
Definition stdatomic.h:49
@ memory_order_seq_cst
Definition stdatomic.h:53
@ memory_order_release
Definition stdatomic.h:51
@ memory_order_relaxed
Definition stdatomic.h:48
@ memory_order_acq_rel
Definition stdatomic.h:52
@ memory_order_acquire
Definition stdatomic.h:50
#define atomic_flag_clear(object)
Definition stdatomic.h:167
#define atomic_signal_fence(order)
Definition stdatomic.h:65
#define atomic_thread_fence(order)
Definition stdatomic.h:64
#define atomic_flag_test_and_set_explicit(object, order)
Definition stdatomic.h:165
#define atomic_flag_test_and_set(object)
Definition stdatomic.h:164
#define atomic_flag_clear_explicit(object, order)
Definition stdatomic.h:168
typedef _Atomic(_Bool) atomic_bool
__UINTMAX_TYPE__ uintmax_t
Definition stdint.h:263
__INTMAX_TYPE__ intmax_t
Definition stdint.h:262
atomic_bool _Value
Definition stdatomic.h:149