1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___ATOMIC_ALIASES_H
10 #define _LIBCPP___ATOMIC_ALIASES_H
12 #include <__atomic/atomic.h>
13 #include <__atomic/atomic_lock_free.h>
14 #include <__atomic/contention_t.h>
15 #include <__atomic/is_always_lock_free.h>
17 #include <__type_traits/conditional.h>
22 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23 # pragma GCC system_header
26 _LIBCPP_BEGIN_NAMESPACE_STD
28 using atomic_bool
= atomic
<bool>;
29 using atomic_char
= atomic
<char>;
30 using atomic_schar
= atomic
<signed char>;
31 using atomic_uchar
= atomic
<unsigned char>;
32 using atomic_short
= atomic
<short>;
33 using atomic_ushort
= atomic
<unsigned short>;
34 using atomic_int
= atomic
<int>;
35 using atomic_uint
= atomic
<unsigned int>;
36 using atomic_long
= atomic
<long>;
37 using atomic_ulong
= atomic
<unsigned long>;
38 using atomic_llong
= atomic
<long long>;
39 using atomic_ullong
= atomic
<unsigned long long>;
40 #ifndef _LIBCPP_HAS_NO_CHAR8_T
41 using atomic_char8_t
= atomic
<char8_t
>;
43 using atomic_char16_t
= atomic
<char16_t
>;
44 using atomic_char32_t
= atomic
<char32_t
>;
45 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
46 using atomic_wchar_t
= atomic
<wchar_t>;
49 using atomic_int_least8_t
= atomic
<int_least8_t>;
50 using atomic_uint_least8_t
= atomic
<uint_least8_t>;
51 using atomic_int_least16_t
= atomic
<int_least16_t>;
52 using atomic_uint_least16_t
= atomic
<uint_least16_t>;
53 using atomic_int_least32_t
= atomic
<int_least32_t>;
54 using atomic_uint_least32_t
= atomic
<uint_least32_t>;
55 using atomic_int_least64_t
= atomic
<int_least64_t>;
56 using atomic_uint_least64_t
= atomic
<uint_least64_t>;
58 using atomic_int_fast8_t
= atomic
<int_fast8_t>;
59 using atomic_uint_fast8_t
= atomic
<uint_fast8_t>;
60 using atomic_int_fast16_t
= atomic
<int_fast16_t>;
61 using atomic_uint_fast16_t
= atomic
<uint_fast16_t>;
62 using atomic_int_fast32_t
= atomic
<int_fast32_t>;
63 using atomic_uint_fast32_t
= atomic
<uint_fast32_t>;
64 using atomic_int_fast64_t
= atomic
<int_fast64_t>;
65 using atomic_uint_fast64_t
= atomic
<uint_fast64_t>;
67 using atomic_int8_t
= atomic
< int8_t>;
68 using atomic_uint8_t
= atomic
<uint8_t>;
69 using atomic_int16_t
= atomic
< int16_t>;
70 using atomic_uint16_t
= atomic
<uint16_t>;
71 using atomic_int32_t
= atomic
< int32_t>;
72 using atomic_uint32_t
= atomic
<uint32_t>;
73 using atomic_int64_t
= atomic
< int64_t>;
74 using atomic_uint64_t
= atomic
<uint64_t>;
76 using atomic_intptr_t
= atomic
<intptr_t>;
77 using atomic_uintptr_t
= atomic
<uintptr_t>;
78 using atomic_size_t
= atomic
<size_t>;
79 using atomic_ptrdiff_t
= atomic
<ptrdiff_t>;
80 using atomic_intmax_t
= atomic
<intmax_t>;
81 using atomic_uintmax_t
= atomic
<uintmax_t>;
83 // atomic_*_lock_free : prefer the contention type most highly, then the largest lock-free type
85 #if _LIBCPP_STD_VER >= 17
86 # define _LIBCPP_CONTENTION_LOCK_FREE ::std::__libcpp_is_always_lock_free<__cxx_contention_t>::__value
88 # define _LIBCPP_CONTENTION_LOCK_FREE false
91 #if ATOMIC_LLONG_LOCK_FREE == 2
92 using __libcpp_signed_lock_free
= __conditional_t
<_LIBCPP_CONTENTION_LOCK_FREE
, __cxx_contention_t
, long long>;
93 using __libcpp_unsigned_lock_free
=
94 __conditional_t
<_LIBCPP_CONTENTION_LOCK_FREE
, __cxx_contention_t
, unsigned long long>;
95 #elif ATOMIC_INT_LOCK_FREE == 2
96 using __libcpp_signed_lock_free
= __conditional_t
<_LIBCPP_CONTENTION_LOCK_FREE
, __cxx_contention_t
, int>;
97 using __libcpp_unsigned_lock_free
= __conditional_t
<_LIBCPP_CONTENTION_LOCK_FREE
, __cxx_contention_t
, unsigned int>;
98 #elif ATOMIC_SHORT_LOCK_FREE == 2
99 using __libcpp_signed_lock_free
= __conditional_t
<_LIBCPP_CONTENTION_LOCK_FREE
, __cxx_contention_t
, short>;
100 using __libcpp_unsigned_lock_free
= __conditional_t
<_LIBCPP_CONTENTION_LOCK_FREE
, __cxx_contention_t
, unsigned short>;
101 #elif ATOMIC_CHAR_LOCK_FREE == 2
102 using __libcpp_signed_lock_free
= __conditional_t
<_LIBCPP_CONTENTION_LOCK_FREE
, __cxx_contention_t
, char>;
103 using __libcpp_unsigned_lock_free
= __conditional_t
<_LIBCPP_CONTENTION_LOCK_FREE
, __cxx_contention_t
, unsigned char>;
105 // No signed/unsigned lock-free types
106 # define _LIBCPP_NO_LOCK_FREE_TYPES
109 #if !defined(_LIBCPP_NO_LOCK_FREE_TYPES)
110 using atomic_signed_lock_free
= atomic
<__libcpp_signed_lock_free
>;
111 using atomic_unsigned_lock_free
= atomic
<__libcpp_unsigned_lock_free
>;
114 _LIBCPP_END_NAMESPACE_STD
116 #endif // _LIBCPP___ATOMIC_ALIASES_H