Warning, /include/c++/v1/atomic is written in an unsupported language. File is not indexed.
0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009
0010 #ifndef _LIBCPP_ATOMIC
0011 #define _LIBCPP_ATOMIC
0012
0013 /*
0014 atomic synopsis
0015
0016 namespace std
0017 {
0018
0019 // feature test macro [version.syn]
0020
0021 #define __cpp_lib_atomic_is_always_lock_free
0022 #define __cpp_lib_atomic_flag_test
0023 #define __cpp_lib_atomic_lock_free_type_aliases
0024 #define __cpp_lib_atomic_wait
0025
0026 // order and consistency
0027
0028 enum memory_order: unspecified // enum class in C++20
0029 {
0030 relaxed,
0031 consume, // load-consume
0032 acquire, // load-acquire
0033 release, // store-release
0034 acq_rel, // store-release load-acquire
0035 seq_cst // store-release load-acquire
0036 };
0037
0038 inline constexpr auto memory_order_relaxed = memory_order::relaxed;
0039 inline constexpr auto memory_order_consume = memory_order::consume;
0040 inline constexpr auto memory_order_acquire = memory_order::acquire;
0041 inline constexpr auto memory_order_release = memory_order::release;
0042 inline constexpr auto memory_order_acq_rel = memory_order::acq_rel;
0043 inline constexpr auto memory_order_seq_cst = memory_order::seq_cst;
0044
0045 template <class T> T kill_dependency(T y) noexcept;
0046
0047 // lock-free property
0048
0049 #define ATOMIC_BOOL_LOCK_FREE unspecified
0050 #define ATOMIC_CHAR_LOCK_FREE unspecified
0051 #define ATOMIC_CHAR8_T_LOCK_FREE unspecified // C++20
0052 #define ATOMIC_CHAR16_T_LOCK_FREE unspecified
0053 #define ATOMIC_CHAR32_T_LOCK_FREE unspecified
0054 #define ATOMIC_WCHAR_T_LOCK_FREE unspecified
0055 #define ATOMIC_SHORT_LOCK_FREE unspecified
0056 #define ATOMIC_INT_LOCK_FREE unspecified
0057 #define ATOMIC_LONG_LOCK_FREE unspecified
0058 #define ATOMIC_LLONG_LOCK_FREE unspecified
0059 #define ATOMIC_POINTER_LOCK_FREE unspecified
0060
0061 template <class T>
0062 struct atomic
0063 {
0064 using value_type = T;
0065
0066 static constexpr bool is_always_lock_free;
0067 bool is_lock_free() const volatile noexcept;
0068 bool is_lock_free() const noexcept;
0069
0070 atomic() noexcept = default; // until C++20
0071 constexpr atomic() noexcept(is_nothrow_default_constructible_v<T>); // since C++20
0072 constexpr atomic(T desr) noexcept;
0073 atomic(const atomic&) = delete;
0074 atomic& operator=(const atomic&) = delete;
0075 atomic& operator=(const atomic&) volatile = delete;
0076
0077 T load(memory_order m = memory_order_seq_cst) const volatile noexcept;
0078 T load(memory_order m = memory_order_seq_cst) const noexcept;
0079 operator T() const volatile noexcept;
0080 operator T() const noexcept;
0081 void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
0082 void store(T desr, memory_order m = memory_order_seq_cst) noexcept;
0083 T operator=(T) volatile noexcept;
0084 T operator=(T) noexcept;
0085
0086 T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
0087 T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept;
0088 bool compare_exchange_weak(T& expc, T desr,
0089 memory_order s, memory_order f) volatile noexcept;
0090 bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept;
0091 bool compare_exchange_strong(T& expc, T desr,
0092 memory_order s, memory_order f) volatile noexcept;
0093 bool compare_exchange_strong(T& expc, T desr,
0094 memory_order s, memory_order f) noexcept;
0095 bool compare_exchange_weak(T& expc, T desr,
0096 memory_order m = memory_order_seq_cst) volatile noexcept;
0097 bool compare_exchange_weak(T& expc, T desr,
0098 memory_order m = memory_order_seq_cst) noexcept;
0099 bool compare_exchange_strong(T& expc, T desr,
0100 memory_order m = memory_order_seq_cst) volatile noexcept;
0101 bool compare_exchange_strong(T& expc, T desr,
0102 memory_order m = memory_order_seq_cst) noexcept;
0103
0104 void wait(T, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
0105 void wait(T, memory_order = memory_order::seq_cst) const noexcept; // since C++20
0106 void notify_one() volatile noexcept; // since C++20
0107 void notify_one() noexcept; // since C++20
0108 void notify_all() volatile noexcept; // since C++20
0109 void notify_all() noexcept; // since C++20
0110 };
0111
0112 template <>
0113 struct atomic<integral>
0114 {
0115 using value_type = integral;
0116 using difference_type = value_type;
0117
0118 static constexpr bool is_always_lock_free;
0119 bool is_lock_free() const volatile noexcept;
0120 bool is_lock_free() const noexcept;
0121
0122 atomic() noexcept = default;
0123 constexpr atomic(integral desr) noexcept;
0124 atomic(const atomic&) = delete;
0125 atomic& operator=(const atomic&) = delete;
0126 atomic& operator=(const atomic&) volatile = delete;
0127
0128 integral load(memory_order m = memory_order_seq_cst) const volatile noexcept;
0129 integral load(memory_order m = memory_order_seq_cst) const noexcept;
0130 operator integral() const volatile noexcept;
0131 operator integral() const noexcept;
0132 void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept;
0133 void store(integral desr, memory_order m = memory_order_seq_cst) noexcept;
0134 integral operator=(integral desr) volatile noexcept;
0135 integral operator=(integral desr) noexcept;
0136
0137 integral exchange(integral desr,
0138 memory_order m = memory_order_seq_cst) volatile noexcept;
0139 integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept;
0140 bool compare_exchange_weak(integral& expc, integral desr,
0141 memory_order s, memory_order f) volatile noexcept;
0142 bool compare_exchange_weak(integral& expc, integral desr,
0143 memory_order s, memory_order f) noexcept;
0144 bool compare_exchange_strong(integral& expc, integral desr,
0145 memory_order s, memory_order f) volatile noexcept;
0146 bool compare_exchange_strong(integral& expc, integral desr,
0147 memory_order s, memory_order f) noexcept;
0148 bool compare_exchange_weak(integral& expc, integral desr,
0149 memory_order m = memory_order_seq_cst) volatile noexcept;
0150 bool compare_exchange_weak(integral& expc, integral desr,
0151 memory_order m = memory_order_seq_cst) noexcept;
0152 bool compare_exchange_strong(integral& expc, integral desr,
0153 memory_order m = memory_order_seq_cst) volatile noexcept;
0154 bool compare_exchange_strong(integral& expc, integral desr,
0155 memory_order m = memory_order_seq_cst) noexcept;
0156
0157 integral fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
0158 integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept;
0159 integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
0160 integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept;
0161 integral fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
0162 integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept;
0163 integral fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
0164 integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept;
0165 integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
0166 integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept;
0167
0168 integral operator++(int) volatile noexcept;
0169 integral operator++(int) noexcept;
0170 integral operator--(int) volatile noexcept;
0171 integral operator--(int) noexcept;
0172 integral operator++() volatile noexcept;
0173 integral operator++() noexcept;
0174 integral operator--() volatile noexcept;
0175 integral operator--() noexcept;
0176 integral operator+=(integral op) volatile noexcept;
0177 integral operator+=(integral op) noexcept;
0178 integral operator-=(integral op) volatile noexcept;
0179 integral operator-=(integral op) noexcept;
0180 integral operator&=(integral op) volatile noexcept;
0181 integral operator&=(integral op) noexcept;
0182 integral operator|=(integral op) volatile noexcept;
0183 integral operator|=(integral op) noexcept;
0184 integral operator^=(integral op) volatile noexcept;
0185 integral operator^=(integral op) noexcept;
0186
0187 void wait(integral, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
0188 void wait(integral, memory_order = memory_order::seq_cst) const noexcept; // since C++20
0189 void notify_one() volatile noexcept; // since C++20
0190 void notify_one() noexcept; // since C++20
0191 void notify_all() volatile noexcept; // since C++20
0192 void notify_all() noexcept; // since C++20
0193 };
0194
0195 template <class T>
0196 struct atomic<T*>
0197 {
0198 using value_type = T*;
0199 using difference_type = ptrdiff_t;
0200
0201 static constexpr bool is_always_lock_free;
0202 bool is_lock_free() const volatile noexcept;
0203 bool is_lock_free() const noexcept;
0204
0205 atomic() noexcept = default; // until C++20
0206 constexpr atomic() noexcept; // since C++20
0207 constexpr atomic(T* desr) noexcept;
0208 atomic(const atomic&) = delete;
0209 atomic& operator=(const atomic&) = delete;
0210 atomic& operator=(const atomic&) volatile = delete;
0211
0212 T* load(memory_order m = memory_order_seq_cst) const volatile noexcept;
0213 T* load(memory_order m = memory_order_seq_cst) const noexcept;
0214 operator T*() const volatile noexcept;
0215 operator T*() const noexcept;
0216 void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
0217 void store(T* desr, memory_order m = memory_order_seq_cst) noexcept;
0218 T* operator=(T*) volatile noexcept;
0219 T* operator=(T*) noexcept;
0220
0221 T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
0222 T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept;
0223 bool compare_exchange_weak(T*& expc, T* desr,
0224 memory_order s, memory_order f) volatile noexcept;
0225 bool compare_exchange_weak(T*& expc, T* desr,
0226 memory_order s, memory_order f) noexcept;
0227 bool compare_exchange_strong(T*& expc, T* desr,
0228 memory_order s, memory_order f) volatile noexcept;
0229 bool compare_exchange_strong(T*& expc, T* desr,
0230 memory_order s, memory_order f) noexcept;
0231 bool compare_exchange_weak(T*& expc, T* desr,
0232 memory_order m = memory_order_seq_cst) volatile noexcept;
0233 bool compare_exchange_weak(T*& expc, T* desr,
0234 memory_order m = memory_order_seq_cst) noexcept;
0235 bool compare_exchange_strong(T*& expc, T* desr,
0236 memory_order m = memory_order_seq_cst) volatile noexcept;
0237 bool compare_exchange_strong(T*& expc, T* desr,
0238 memory_order m = memory_order_seq_cst) noexcept;
0239 T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
0240 T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
0241 T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
0242 T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
0243
0244 T* operator++(int) volatile noexcept;
0245 T* operator++(int) noexcept;
0246 T* operator--(int) volatile noexcept;
0247 T* operator--(int) noexcept;
0248 T* operator++() volatile noexcept;
0249 T* operator++() noexcept;
0250 T* operator--() volatile noexcept;
0251 T* operator--() noexcept;
0252 T* operator+=(ptrdiff_t op) volatile noexcept;
0253 T* operator+=(ptrdiff_t op) noexcept;
0254 T* operator-=(ptrdiff_t op) volatile noexcept;
0255 T* operator-=(ptrdiff_t op) noexcept;
0256
0257 void wait(T*, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
0258 void wait(T*, memory_order = memory_order::seq_cst) const noexcept; // since C++20
0259 void notify_one() volatile noexcept; // since C++20
0260 void notify_one() noexcept; // since C++20
0261 void notify_all() volatile noexcept; // since C++20
0262 void notify_all() noexcept; // since C++20
0263 };
0264
0265 template<>
0266 struct atomic<floating-point-type> { // since C++20
0267 using value_type = floating-point-type;
0268 using difference_type = value_type;
0269
0270 static constexpr bool is_always_lock_free = implementation-defined;
0271 bool is_lock_free() const volatile noexcept;
0272 bool is_lock_free() const noexcept;
0273
0274 constexpr atomic() noexcept;
0275 constexpr atomic(floating-point-type) noexcept;
0276 atomic(const atomic&) = delete;
0277 atomic& operator=(const atomic&) = delete;
0278 atomic& operator=(const atomic&) volatile = delete;
0279
0280 void store(floating-point-type, memory_order = memory_order::seq_cst) volatile noexcept;
0281 void store(floating-point-type, memory_order = memory_order::seq_cst) noexcept;
0282 floating-point-type operator=(floating-point-type) volatile noexcept;
0283 floating-point-type operator=(floating-point-type) noexcept;
0284 floating-point-type load(memory_order = memory_order::seq_cst) volatile noexcept;
0285 floating-point-type load(memory_order = memory_order::seq_cst) noexcept;
0286 operator floating-point-type() volatile noexcept;
0287 operator floating-point-type() noexcept;
0288
0289 floating-point-type exchange(floating-point-type,
0290 memory_order = memory_order::seq_cst) volatile noexcept;
0291 floating-point-type exchange(floating-point-type,
0292 memory_order = memory_order::seq_cst) noexcept;
0293 bool compare_exchange_weak(floating-point-type&, floating-point-type,
0294 memory_order, memory_order) volatile noexcept;
0295 bool compare_exchange_weak(floating-point-type&, floating-point-type,
0296 memory_order, memory_order) noexcept;
0297 bool compare_exchange_strong(floating-point-type&, floating-point-type,
0298 memory_order, memory_order) volatile noexcept;
0299 bool compare_exchange_strong(floating-point-type&, floating-point-type,
0300 memory_order, memory_order) noexcept;
0301 bool compare_exchange_weak(floating-point-type&, floating-point-type,
0302 memory_order = memory_order::seq_cst) volatile noexcept;
0303 bool compare_exchange_weak(floating-point-type&, floating-point-type,
0304 memory_order = memory_order::seq_cst) noexcept;
0305 bool compare_exchange_strong(floating-point-type&, floating-point-type,
0306 memory_order = memory_order::seq_cst) volatile noexcept;
0307 bool compare_exchange_strong(floating-point-type&, floating-point-type,
0308 memory_order = memory_order::seq_cst) noexcept;
0309
0310 floating-point-type fetch_add(floating-point-type,
0311 memory_order = memory_order::seq_cst) volatile noexcept;
0312 floating-point-type fetch_add(floating-point-type,
0313 memory_order = memory_order::seq_cst) noexcept;
0314 floating-point-type fetch_sub(floating-point-type,
0315 memory_order = memory_order::seq_cst) volatile noexcept;
0316 floating-point-type fetch_sub(floating-point-type,
0317 memory_order = memory_order::seq_cst) noexcept;
0318
0319 floating-point-type operator+=(floating-point-type) volatile noexcept;
0320 floating-point-type operator+=(floating-point-type) noexcept;
0321 floating-point-type operator-=(floating-point-type) volatile noexcept;
0322 floating-point-type operator-=(floating-point-type) noexcept;
0323
0324 void wait(floating-point-type, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
0325 void wait(floating-point-type, memory_order = memory_order::seq_cst) const noexcept; // since C++20
0326 void notify_one() volatile noexcept; // since C++20
0327 void notify_one() noexcept; // since C++20
0328 void notify_all() volatile noexcept; // since C++20
0329 void notify_all() noexcept; // since C++20
0330 };
0331
0332 // [atomics.nonmembers], non-member functions
0333 template<class T>
0334 bool atomic_is_lock_free(const volatile atomic<T>*) noexcept;
0335 template<class T>
0336 bool atomic_is_lock_free(const atomic<T>*) noexcept;
0337 template<class T>
0338 void atomic_store(volatile atomic<T>*, atomic<T>::value_type) noexcept;
0339 template<class T>
0340 void atomic_store(atomic<T>*, atomic<T>::value_type) noexcept;
0341 template<class T>
0342 void atomic_store_explicit(volatile atomic<T>*, atomic<T>::value_type,
0343 memory_order) noexcept;
0344 template<class T>
0345 void atomic_store_explicit(atomic<T>*, atomic<T>::value_type,
0346 memory_order) noexcept;
0347 template<class T>
0348 T atomic_load(const volatile atomic<T>*) noexcept;
0349 template<class T>
0350 T atomic_load(const atomic<T>*) noexcept;
0351 template<class T>
0352 T atomic_load_explicit(const volatile atomic<T>*, memory_order) noexcept;
0353 template<class T>
0354 T atomic_load_explicit(const atomic<T>*, memory_order) noexcept;
0355 template<class T>
0356 T atomic_exchange(volatile atomic<T>*, atomic<T>::value_type) noexcept;
0357 template<class T>
0358 T atomic_exchange(atomic<T>*, atomic<T>::value_type) noexcept;
0359 template<class T>
0360 T atomic_exchange_explicit(volatile atomic<T>*, atomic<T>::value_type,
0361 memory_order) noexcept;
0362 template<class T>
0363 T atomic_exchange_explicit(atomic<T>*, atomic<T>::value_type,
0364 memory_order) noexcept;
0365 template<class T>
0366 bool atomic_compare_exchange_weak(volatile atomic<T>*, atomic<T>::value_type*,
0367 atomic<T>::value_type) noexcept;
0368 template<class T>
0369 bool atomic_compare_exchange_weak(atomic<T>*, atomic<T>::value_type*,
0370 atomic<T>::value_type) noexcept;
0371 template<class T>
0372 bool atomic_compare_exchange_strong(volatile atomic<T>*, atomic<T>::value_type*,
0373 atomic<T>::value_type) noexcept;
0374 template<class T>
0375 bool atomic_compare_exchange_strong(atomic<T>*, atomic<T>::value_type*,
0376 atomic<T>::value_type) noexcept;
0377 template<class T>
0378 bool atomic_compare_exchange_weak_explicit(volatile atomic<T>*, atomic<T>::value_type*,
0379 atomic<T>::value_type,
0380 memory_order, memory_order) noexcept;
0381 template<class T>
0382 bool atomic_compare_exchange_weak_explicit(atomic<T>*, atomic<T>::value_type*,
0383 atomic<T>::value_type,
0384 memory_order, memory_order) noexcept;
0385 template<class T>
0386 bool atomic_compare_exchange_strong_explicit(volatile atomic<T>*, atomic<T>::value_type*,
0387 atomic<T>::value_type,
0388 memory_order, memory_order) noexcept;
0389 template<class T>
0390 bool atomic_compare_exchange_strong_explicit(atomic<T>*, atomic<T>::value_type*,
0391 atomic<T>::value_type,
0392 memory_order, memory_order) noexcept;
0393
0394 template<class T>
0395 T atomic_fetch_add(volatile atomic<T>*, atomic<T>::difference_type) noexcept;
0396 template<class T>
0397 T atomic_fetch_add(atomic<T>*, atomic<T>::difference_type) noexcept;
0398 template<class T>
0399 T atomic_fetch_add_explicit(volatile atomic<T>*, atomic<T>::difference_type,
0400 memory_order) noexcept;
0401 template<class T>
0402 T atomic_fetch_add_explicit(atomic<T>*, atomic<T>::difference_type,
0403 memory_order) noexcept;
0404 template<class T>
0405 T atomic_fetch_sub(volatile atomic<T>*, atomic<T>::difference_type) noexcept;
0406 template<class T>
0407 T atomic_fetch_sub(atomic<T>*, atomic<T>::difference_type) noexcept;
0408 template<class T>
0409 T atomic_fetch_sub_explicit(volatile atomic<T>*, atomic<T>::difference_type,
0410 memory_order) noexcept;
0411 template<class T>
0412 T atomic_fetch_sub_explicit(atomic<T>*, atomic<T>::difference_type,
0413 memory_order) noexcept;
0414 template<class T>
0415 T atomic_fetch_and(volatile atomic<T>*, atomic<T>::value_type) noexcept;
0416 template<class T>
0417 T atomic_fetch_and(atomic<T>*, atomic<T>::value_type) noexcept;
0418 template<class T>
0419 T atomic_fetch_and_explicit(volatile atomic<T>*, atomic<T>::value_type,
0420 memory_order) noexcept;
0421 template<class T>
0422 T atomic_fetch_and_explicit(atomic<T>*, atomic<T>::value_type,
0423 memory_order) noexcept;
0424 template<class T>
0425 T atomic_fetch_or(volatile atomic<T>*, atomic<T>::value_type) noexcept;
0426 template<class T>
0427 T atomic_fetch_or(atomic<T>*, atomic<T>::value_type) noexcept;
0428 template<class T>
0429 T atomic_fetch_or_explicit(volatile atomic<T>*, atomic<T>::value_type,
0430 memory_order) noexcept;
0431 template<class T>
0432 T atomic_fetch_or_explicit(atomic<T>*, atomic<T>::value_type,
0433 memory_order) noexcept;
0434 template<class T>
0435 T atomic_fetch_xor(volatile atomic<T>*, atomic<T>::value_type) noexcept;
0436 template<class T>
0437 T atomic_fetch_xor(atomic<T>*, atomic<T>::value_type) noexcept;
0438 template<class T>
0439 T atomic_fetch_xor_explicit(volatile atomic<T>*, atomic<T>::value_type,
0440 memory_order) noexcept;
0441 template<class T>
0442 T atomic_fetch_xor_explicit(atomic<T>*, atomic<T>::value_type,
0443 memory_order) noexcept;
0444
0445 template<class T>
0446 void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type) noexcept; // since C++20
0447 template<class T>
0448 void atomic_wait(const atomic<T>*, atomic<T>::value_type) noexcept; // since C++20
0449 template<class T>
0450 void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type, // since C++20
0451 memory_order) noexcept;
0452 template<class T>
0453 void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type, // since C++20
0454 memory_order) noexcept;
0455 template<class T>
0456 void atomic_notify_one(volatile atomic<T>*) noexcept; // since C++20
0457 template<class T>
0458 void atomic_notify_one(atomic<T>*) noexcept; // since C++20
0459 template<class T>
0460 void atomic_notify_all(volatile atomic<T>*) noexcept; // since C++20
0461 template<class T>
0462 void atomic_notify_all(atomic<T>*) noexcept; // since C++20
0463
0464 // Atomics for standard typedef types
0465
0466 typedef atomic<bool> atomic_bool;
0467 typedef atomic<char> atomic_char;
0468 typedef atomic<signed char> atomic_schar;
0469 typedef atomic<unsigned char> atomic_uchar;
0470 typedef atomic<short> atomic_short;
0471 typedef atomic<unsigned short> atomic_ushort;
0472 typedef atomic<int> atomic_int;
0473 typedef atomic<unsigned int> atomic_uint;
0474 typedef atomic<long> atomic_long;
0475 typedef atomic<unsigned long> atomic_ulong;
0476 typedef atomic<long long> atomic_llong;
0477 typedef atomic<unsigned long long> atomic_ullong;
0478 typedef atomic<char8_t> atomic_char8_t; // C++20
0479 typedef atomic<char16_t> atomic_char16_t;
0480 typedef atomic<char32_t> atomic_char32_t;
0481 typedef atomic<wchar_t> atomic_wchar_t;
0482
0483 typedef atomic<int_least8_t> atomic_int_least8_t;
0484 typedef atomic<uint_least8_t> atomic_uint_least8_t;
0485 typedef atomic<int_least16_t> atomic_int_least16_t;
0486 typedef atomic<uint_least16_t> atomic_uint_least16_t;
0487 typedef atomic<int_least32_t> atomic_int_least32_t;
0488 typedef atomic<uint_least32_t> atomic_uint_least32_t;
0489 typedef atomic<int_least64_t> atomic_int_least64_t;
0490 typedef atomic<uint_least64_t> atomic_uint_least64_t;
0491
0492 typedef atomic<int_fast8_t> atomic_int_fast8_t;
0493 typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
0494 typedef atomic<int_fast16_t> atomic_int_fast16_t;
0495 typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
0496 typedef atomic<int_fast32_t> atomic_int_fast32_t;
0497 typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
0498 typedef atomic<int_fast64_t> atomic_int_fast64_t;
0499 typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
0500
0501 typedef atomic<int8_t> atomic_int8_t;
0502 typedef atomic<uint8_t> atomic_uint8_t;
0503 typedef atomic<int16_t> atomic_int16_t;
0504 typedef atomic<uint16_t> atomic_uint16_t;
0505 typedef atomic<int32_t> atomic_int32_t;
0506 typedef atomic<uint32_t> atomic_uint32_t;
0507 typedef atomic<int64_t> atomic_int64_t;
0508 typedef atomic<uint64_t> atomic_uint64_t;
0509
0510 typedef atomic<intptr_t> atomic_intptr_t;
0511 typedef atomic<uintptr_t> atomic_uintptr_t;
0512 typedef atomic<size_t> atomic_size_t;
0513 typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
0514 typedef atomic<intmax_t> atomic_intmax_t;
0515 typedef atomic<uintmax_t> atomic_uintmax_t;
0516
0517 typedef see-below atomic_signed_lock_free; // since C++20
0518 typedef see-below atomic_unsigned_lock_free; // since C++20
0519
0520 // flag type and operations
0521
0522 typedef struct atomic_flag
0523 {
0524 atomic_flag() noexcept = default; // until C++20
0525 constexpr atomic_flag() noexcept; // since C++20
0526 atomic_flag(const atomic_flag&) = delete;
0527 atomic_flag& operator=(const atomic_flag&) = delete;
0528 atomic_flag& operator=(const atomic_flag&) volatile = delete;
0529
0530 bool test(memory_order m = memory_order_seq_cst) volatile noexcept;
0531 bool test(memory_order m = memory_order_seq_cst) noexcept;
0532 bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept;
0533 bool test_and_set(memory_order m = memory_order_seq_cst) noexcept;
0534 void clear(memory_order m = memory_order_seq_cst) volatile noexcept;
0535 void clear(memory_order m = memory_order_seq_cst) noexcept;
0536
0537 void wait(bool, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
0538 void wait(bool, memory_order = memory_order::seq_cst) const noexcept; // since C++20
0539 void notify_one() volatile noexcept; // since C++20
0540 void notify_one() noexcept; // since C++20
0541 void notify_all() volatile noexcept; // since C++20
0542 void notify_all() noexcept; // since C++20
0543 } atomic_flag;
0544
0545 bool atomic_flag_test(volatile atomic_flag* obj) noexcept;
0546 bool atomic_flag_test(atomic_flag* obj) noexcept;
0547 bool atomic_flag_test_explicit(volatile atomic_flag* obj,
0548 memory_order m) noexcept;
0549 bool atomic_flag_test_explicit(atomic_flag* obj, memory_order m) noexcept;
0550 bool atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept;
0551 bool atomic_flag_test_and_set(atomic_flag* obj) noexcept;
0552 bool atomic_flag_test_and_set_explicit(volatile atomic_flag* obj,
0553 memory_order m) noexcept;
0554 bool atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept;
0555 void atomic_flag_clear(volatile atomic_flag* obj) noexcept;
0556 void atomic_flag_clear(atomic_flag* obj) noexcept;
0557 void atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept;
0558 void atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept;
0559
0560 void atomic_wait(const volatile atomic_flag* obj, T old) noexcept; // since C++20
0561 void atomic_wait(const atomic_flag* obj, T old) noexcept; // since C++20
0562 void atomic_wait_explicit(const volatile atomic_flag* obj, T old, memory_order m) noexcept; // since C++20
0563 void atomic_wait_explicit(const atomic_flag* obj, T old, memory_order m) noexcept; // since C++20
0564 void atomic_one(volatile atomic_flag* obj) noexcept; // since C++20
0565 void atomic_one(atomic_flag* obj) noexcept; // since C++20
0566 void atomic_all(volatile atomic_flag* obj) noexcept; // since C++20
0567 void atomic_all(atomic_flag* obj) noexcept; // since C++20
0568
0569 // fences
0570
0571 void atomic_thread_fence(memory_order m) noexcept;
0572 void atomic_signal_fence(memory_order m) noexcept;
0573
0574 // deprecated
0575
0576 template <class T>
0577 void atomic_init(volatile atomic<T>* obj, atomic<T>::value_type desr) noexcept;
0578
0579 template <class T>
0580 void atomic_init(atomic<T>* obj, atomic<T>::value_type desr) noexcept;
0581
0582 #define ATOMIC_VAR_INIT(value) see below
0583
0584 #define ATOMIC_FLAG_INIT see below
0585
0586 } // std
0587
0588 */
0589
0590 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0591 # include <__cxx03/atomic>
0592 #else
0593 # include <__config>
0594
0595 # if defined(_LIBCPP_STDATOMIC_H) || defined(kill_dependency) || defined(atomic_load)
0596 # define _LIBCPP_STDATOMIC_H_HAS_DEFINITELY_BEEN_INCLUDED 1
0597 # else
0598 # define _LIBCPP_STDATOMIC_H_HAS_DEFINITELY_BEEN_INCLUDED 0
0599 # endif
0600
0601 # if _LIBCPP_STD_VER < 23 && _LIBCPP_STDATOMIC_H_HAS_DEFINITELY_BEEN_INCLUDED
0602 # error <atomic> is incompatible with <stdatomic.h> before C++23. Please compile with -std=c++23.
0603 # endif
0604
0605 # include <__atomic/aliases.h>
0606 # include <__atomic/atomic.h>
0607 # include <__atomic/atomic_flag.h>
0608 # include <__atomic/atomic_init.h>
0609 # include <__atomic/atomic_lock_free.h>
0610 # include <__atomic/atomic_sync.h>
0611 # include <__atomic/check_memory_order.h>
0612 # include <__atomic/contention_t.h>
0613 # include <__atomic/fence.h>
0614 # include <__atomic/is_always_lock_free.h>
0615 # include <__atomic/kill_dependency.h>
0616 # include <__atomic/memory_order.h>
0617 # include <version>
0618
0619 # if _LIBCPP_STD_VER >= 20
0620 # include <__atomic/atomic_ref.h>
0621 # endif
0622
0623 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0624 # pragma GCC system_header
0625 # endif
0626
0627 # if !_LIBCPP_HAS_ATOMIC_HEADER
0628 # error <atomic> is not implemented
0629 # endif
0630
0631 # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
0632 # include <cmath>
0633 # include <compare>
0634 # include <cstddef>
0635 # include <cstdlib>
0636 # include <cstring>
0637 # include <type_traits>
0638 # endif
0639 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0640
0641 #endif // _LIBCPP_ATOMIC