xref: /freebsd-src/contrib/llvm-project/libcxx/include/__atomic/aliases.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1*06c3fb27SDimitry Andric //===----------------------------------------------------------------------===//
2*06c3fb27SDimitry Andric //
3*06c3fb27SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*06c3fb27SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*06c3fb27SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*06c3fb27SDimitry Andric //
7*06c3fb27SDimitry Andric //===----------------------------------------------------------------------===//
8*06c3fb27SDimitry Andric 
9*06c3fb27SDimitry Andric #ifndef _LIBCPP___ATOMIC_ALIASES_H
10*06c3fb27SDimitry Andric #define _LIBCPP___ATOMIC_ALIASES_H
11*06c3fb27SDimitry Andric 
12*06c3fb27SDimitry Andric #include <__atomic/atomic.h>
13*06c3fb27SDimitry Andric #include <__atomic/atomic_lock_free.h>
14*06c3fb27SDimitry Andric #include <__atomic/contention_t.h>
15*06c3fb27SDimitry Andric #include <__atomic/is_always_lock_free.h>
16*06c3fb27SDimitry Andric #include <__config>
17*06c3fb27SDimitry Andric #include <__type_traits/conditional.h>
18*06c3fb27SDimitry Andric #include <cstddef>
19*06c3fb27SDimitry Andric #include <cstdint>
20*06c3fb27SDimitry Andric #include <cstdlib>
21*06c3fb27SDimitry Andric 
22*06c3fb27SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23*06c3fb27SDimitry Andric #  pragma GCC system_header
24*06c3fb27SDimitry Andric #endif
25*06c3fb27SDimitry Andric 
26*06c3fb27SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
27*06c3fb27SDimitry Andric 
28*06c3fb27SDimitry Andric using atomic_bool   = atomic<bool>;
29*06c3fb27SDimitry Andric using atomic_char   = atomic<char>;
30*06c3fb27SDimitry Andric using atomic_schar  = atomic<signed char>;
31*06c3fb27SDimitry Andric using atomic_uchar  = atomic<unsigned char>;
32*06c3fb27SDimitry Andric using atomic_short  = atomic<short>;
33*06c3fb27SDimitry Andric using atomic_ushort = atomic<unsigned short>;
34*06c3fb27SDimitry Andric using atomic_int    = atomic<int>;
35*06c3fb27SDimitry Andric using atomic_uint   = atomic<unsigned int>;
36*06c3fb27SDimitry Andric using atomic_long   = atomic<long>;
37*06c3fb27SDimitry Andric using atomic_ulong  = atomic<unsigned long>;
38*06c3fb27SDimitry Andric using atomic_llong  = atomic<long long>;
39*06c3fb27SDimitry Andric using atomic_ullong = atomic<unsigned long long>;
40*06c3fb27SDimitry Andric #ifndef _LIBCPP_HAS_NO_CHAR8_T
41*06c3fb27SDimitry Andric using atomic_char8_t = atomic<char8_t>;
42*06c3fb27SDimitry Andric #endif
43*06c3fb27SDimitry Andric using atomic_char16_t = atomic<char16_t>;
44*06c3fb27SDimitry Andric using atomic_char32_t = atomic<char32_t>;
45*06c3fb27SDimitry Andric #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
46*06c3fb27SDimitry Andric using atomic_wchar_t = atomic<wchar_t>;
47*06c3fb27SDimitry Andric #endif
48*06c3fb27SDimitry Andric 
49*06c3fb27SDimitry Andric using atomic_int_least8_t   = atomic<int_least8_t>;
50*06c3fb27SDimitry Andric using atomic_uint_least8_t  = atomic<uint_least8_t>;
51*06c3fb27SDimitry Andric using atomic_int_least16_t  = atomic<int_least16_t>;
52*06c3fb27SDimitry Andric using atomic_uint_least16_t = atomic<uint_least16_t>;
53*06c3fb27SDimitry Andric using atomic_int_least32_t  = atomic<int_least32_t>;
54*06c3fb27SDimitry Andric using atomic_uint_least32_t = atomic<uint_least32_t>;
55*06c3fb27SDimitry Andric using atomic_int_least64_t  = atomic<int_least64_t>;
56*06c3fb27SDimitry Andric using atomic_uint_least64_t = atomic<uint_least64_t>;
57*06c3fb27SDimitry Andric 
58*06c3fb27SDimitry Andric using atomic_int_fast8_t   = atomic<int_fast8_t>;
59*06c3fb27SDimitry Andric using atomic_uint_fast8_t  = atomic<uint_fast8_t>;
60*06c3fb27SDimitry Andric using atomic_int_fast16_t  = atomic<int_fast16_t>;
61*06c3fb27SDimitry Andric using atomic_uint_fast16_t = atomic<uint_fast16_t>;
62*06c3fb27SDimitry Andric using atomic_int_fast32_t  = atomic<int_fast32_t>;
63*06c3fb27SDimitry Andric using atomic_uint_fast32_t = atomic<uint_fast32_t>;
64*06c3fb27SDimitry Andric using atomic_int_fast64_t  = atomic<int_fast64_t>;
65*06c3fb27SDimitry Andric using atomic_uint_fast64_t = atomic<uint_fast64_t>;
66*06c3fb27SDimitry Andric 
67*06c3fb27SDimitry Andric using atomic_int8_t   = atomic< int8_t>;
68*06c3fb27SDimitry Andric using atomic_uint8_t  = atomic<uint8_t>;
69*06c3fb27SDimitry Andric using atomic_int16_t  = atomic< int16_t>;
70*06c3fb27SDimitry Andric using atomic_uint16_t = atomic<uint16_t>;
71*06c3fb27SDimitry Andric using atomic_int32_t  = atomic< int32_t>;
72*06c3fb27SDimitry Andric using atomic_uint32_t = atomic<uint32_t>;
73*06c3fb27SDimitry Andric using atomic_int64_t  = atomic< int64_t>;
74*06c3fb27SDimitry Andric using atomic_uint64_t = atomic<uint64_t>;
75*06c3fb27SDimitry Andric 
76*06c3fb27SDimitry Andric using atomic_intptr_t  = atomic<intptr_t>;
77*06c3fb27SDimitry Andric using atomic_uintptr_t = atomic<uintptr_t>;
78*06c3fb27SDimitry Andric using atomic_size_t    = atomic<size_t>;
79*06c3fb27SDimitry Andric using atomic_ptrdiff_t = atomic<ptrdiff_t>;
80*06c3fb27SDimitry Andric using atomic_intmax_t  = atomic<intmax_t>;
81*06c3fb27SDimitry Andric using atomic_uintmax_t = atomic<uintmax_t>;
82*06c3fb27SDimitry Andric 
83*06c3fb27SDimitry Andric // atomic_*_lock_free : prefer the contention type most highly, then the largest lock-free type
84*06c3fb27SDimitry Andric 
85*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 17
86*06c3fb27SDimitry Andric #  define _LIBCPP_CONTENTION_LOCK_FREE ::std::__libcpp_is_always_lock_free<__cxx_contention_t>::__value
87*06c3fb27SDimitry Andric #else
88*06c3fb27SDimitry Andric #  define _LIBCPP_CONTENTION_LOCK_FREE false
89*06c3fb27SDimitry Andric #endif
90*06c3fb27SDimitry Andric 
91*06c3fb27SDimitry Andric #if ATOMIC_LLONG_LOCK_FREE == 2
92*06c3fb27SDimitry Andric using __libcpp_signed_lock_free = __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, long long>;
93*06c3fb27SDimitry Andric using __libcpp_unsigned_lock_free =
94*06c3fb27SDimitry Andric     __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned long long>;
95*06c3fb27SDimitry Andric #elif ATOMIC_INT_LOCK_FREE == 2
96*06c3fb27SDimitry Andric using __libcpp_signed_lock_free   = __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, int>;
97*06c3fb27SDimitry Andric using __libcpp_unsigned_lock_free = __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned int>;
98*06c3fb27SDimitry Andric #elif ATOMIC_SHORT_LOCK_FREE == 2
99*06c3fb27SDimitry Andric using __libcpp_signed_lock_free   = __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, short>;
100*06c3fb27SDimitry Andric using __libcpp_unsigned_lock_free = __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned short>;
101*06c3fb27SDimitry Andric #elif ATOMIC_CHAR_LOCK_FREE == 2
102*06c3fb27SDimitry Andric using __libcpp_signed_lock_free   = __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char>;
103*06c3fb27SDimitry Andric using __libcpp_unsigned_lock_free = __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char>;
104*06c3fb27SDimitry Andric #else
105*06c3fb27SDimitry Andric // No signed/unsigned lock-free types
106*06c3fb27SDimitry Andric #  define _LIBCPP_NO_LOCK_FREE_TYPES
107*06c3fb27SDimitry Andric #endif
108*06c3fb27SDimitry Andric 
109*06c3fb27SDimitry Andric #if !defined(_LIBCPP_NO_LOCK_FREE_TYPES)
110*06c3fb27SDimitry Andric using atomic_signed_lock_free   = atomic<__libcpp_signed_lock_free>;
111*06c3fb27SDimitry Andric using atomic_unsigned_lock_free = atomic<__libcpp_unsigned_lock_free>;
112*06c3fb27SDimitry Andric #endif
113*06c3fb27SDimitry Andric 
114*06c3fb27SDimitry Andric _LIBCPP_END_NAMESPACE_STD
115*06c3fb27SDimitry Andric 
116*06c3fb27SDimitry Andric #endif // _LIBCPP___ATOMIC_ALIASES_H
117