xref: /freebsd-src/contrib/llvm-project/libcxx/include/__atomic/aliases.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
106c3fb27SDimitry Andric //===----------------------------------------------------------------------===//
206c3fb27SDimitry Andric //
306c3fb27SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
406c3fb27SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
506c3fb27SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
606c3fb27SDimitry Andric //
706c3fb27SDimitry Andric //===----------------------------------------------------------------------===//
806c3fb27SDimitry Andric 
906c3fb27SDimitry Andric #ifndef _LIBCPP___ATOMIC_ALIASES_H
1006c3fb27SDimitry Andric #define _LIBCPP___ATOMIC_ALIASES_H
1106c3fb27SDimitry Andric 
1206c3fb27SDimitry Andric #include <__atomic/atomic.h>
1306c3fb27SDimitry Andric #include <__atomic/atomic_lock_free.h>
1406c3fb27SDimitry Andric #include <__atomic/contention_t.h>
1506c3fb27SDimitry Andric #include <__atomic/is_always_lock_free.h>
1606c3fb27SDimitry Andric #include <__config>
1706c3fb27SDimitry Andric #include <__type_traits/conditional.h>
185f757f3fSDimitry Andric #include <__type_traits/make_unsigned.h>
1906c3fb27SDimitry Andric #include <cstddef>
2006c3fb27SDimitry Andric #include <cstdint>
2106c3fb27SDimitry Andric 
2206c3fb27SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2306c3fb27SDimitry Andric #  pragma GCC system_header
2406c3fb27SDimitry Andric #endif
2506c3fb27SDimitry Andric 
2606c3fb27SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
2706c3fb27SDimitry Andric 
2806c3fb27SDimitry Andric using atomic_bool   = atomic<bool>;
2906c3fb27SDimitry Andric using atomic_char   = atomic<char>;
3006c3fb27SDimitry Andric using atomic_schar  = atomic<signed char>;
3106c3fb27SDimitry Andric using atomic_uchar  = atomic<unsigned char>;
3206c3fb27SDimitry Andric using atomic_short  = atomic<short>;
3306c3fb27SDimitry Andric using atomic_ushort = atomic<unsigned short>;
3406c3fb27SDimitry Andric using atomic_int    = atomic<int>;
3506c3fb27SDimitry Andric using atomic_uint   = atomic<unsigned int>;
3606c3fb27SDimitry Andric using atomic_long   = atomic<long>;
3706c3fb27SDimitry Andric using atomic_ulong  = atomic<unsigned long>;
3806c3fb27SDimitry Andric using atomic_llong  = atomic<long long>;
3906c3fb27SDimitry Andric using atomic_ullong = atomic<unsigned long long>;
4006c3fb27SDimitry Andric #ifndef _LIBCPP_HAS_NO_CHAR8_T
4106c3fb27SDimitry Andric using atomic_char8_t = atomic<char8_t>;
4206c3fb27SDimitry Andric #endif
4306c3fb27SDimitry Andric using atomic_char16_t = atomic<char16_t>;
4406c3fb27SDimitry Andric using atomic_char32_t = atomic<char32_t>;
4506c3fb27SDimitry Andric #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
4606c3fb27SDimitry Andric using atomic_wchar_t = atomic<wchar_t>;
4706c3fb27SDimitry Andric #endif
4806c3fb27SDimitry Andric 
4906c3fb27SDimitry Andric using atomic_int_least8_t   = atomic<int_least8_t>;
5006c3fb27SDimitry Andric using atomic_uint_least8_t  = atomic<uint_least8_t>;
5106c3fb27SDimitry Andric using atomic_int_least16_t  = atomic<int_least16_t>;
5206c3fb27SDimitry Andric using atomic_uint_least16_t = atomic<uint_least16_t>;
5306c3fb27SDimitry Andric using atomic_int_least32_t  = atomic<int_least32_t>;
5406c3fb27SDimitry Andric using atomic_uint_least32_t = atomic<uint_least32_t>;
5506c3fb27SDimitry Andric using atomic_int_least64_t  = atomic<int_least64_t>;
5606c3fb27SDimitry Andric using atomic_uint_least64_t = atomic<uint_least64_t>;
5706c3fb27SDimitry Andric 
5806c3fb27SDimitry Andric using atomic_int_fast8_t   = atomic<int_fast8_t>;
5906c3fb27SDimitry Andric using atomic_uint_fast8_t  = atomic<uint_fast8_t>;
6006c3fb27SDimitry Andric using atomic_int_fast16_t  = atomic<int_fast16_t>;
6106c3fb27SDimitry Andric using atomic_uint_fast16_t = atomic<uint_fast16_t>;
6206c3fb27SDimitry Andric using atomic_int_fast32_t  = atomic<int_fast32_t>;
6306c3fb27SDimitry Andric using atomic_uint_fast32_t = atomic<uint_fast32_t>;
6406c3fb27SDimitry Andric using atomic_int_fast64_t  = atomic<int_fast64_t>;
6506c3fb27SDimitry Andric using atomic_uint_fast64_t = atomic<uint_fast64_t>;
6606c3fb27SDimitry Andric 
6706c3fb27SDimitry Andric using atomic_int8_t   = atomic< int8_t>;
6806c3fb27SDimitry Andric using atomic_uint8_t  = atomic<uint8_t>;
6906c3fb27SDimitry Andric using atomic_int16_t  = atomic< int16_t>;
7006c3fb27SDimitry Andric using atomic_uint16_t = atomic<uint16_t>;
7106c3fb27SDimitry Andric using atomic_int32_t  = atomic< int32_t>;
7206c3fb27SDimitry Andric using atomic_uint32_t = atomic<uint32_t>;
7306c3fb27SDimitry Andric using atomic_int64_t  = atomic< int64_t>;
7406c3fb27SDimitry Andric using atomic_uint64_t = atomic<uint64_t>;
7506c3fb27SDimitry Andric 
7606c3fb27SDimitry Andric using atomic_intptr_t  = atomic<intptr_t>;
7706c3fb27SDimitry Andric using atomic_uintptr_t = atomic<uintptr_t>;
7806c3fb27SDimitry Andric using atomic_size_t    = atomic<size_t>;
7906c3fb27SDimitry Andric using atomic_ptrdiff_t = atomic<ptrdiff_t>;
8006c3fb27SDimitry Andric using atomic_intmax_t  = atomic<intmax_t>;
8106c3fb27SDimitry Andric using atomic_uintmax_t = atomic<uintmax_t>;
8206c3fb27SDimitry Andric 
835f757f3fSDimitry Andric // C++20 atomic_{signed,unsigned}_lock_free: prefer the contention type most highly, then the largest lock-free type
845f757f3fSDimitry Andric #if _LIBCPP_STD_VER >= 20
8506c3fb27SDimitry Andric #  if ATOMIC_LLONG_LOCK_FREE == 2
865f757f3fSDimitry Andric using __largest_lock_free_type = long long;
8706c3fb27SDimitry Andric #  elif ATOMIC_INT_LOCK_FREE == 2
885f757f3fSDimitry Andric using __largest_lock_free_type = int;
8906c3fb27SDimitry Andric #  elif ATOMIC_SHORT_LOCK_FREE == 2
905f757f3fSDimitry Andric using __largest_lock_free_type = short;
9106c3fb27SDimitry Andric #  elif ATOMIC_CHAR_LOCK_FREE == 2
925f757f3fSDimitry Andric using __largest_lock_free_type = char;
9306c3fb27SDimitry Andric #  else
94*0fca6ea1SDimitry Andric #    define _LIBCPP_NO_LOCK_FREE_TYPES // There are no lockfree types (this can happen on unusual platforms)
9506c3fb27SDimitry Andric #  endif
9606c3fb27SDimitry Andric 
975f757f3fSDimitry Andric #  ifndef _LIBCPP_NO_LOCK_FREE_TYPES
985f757f3fSDimitry Andric using __contention_t_or_largest =
995f757f3fSDimitry Andric     __conditional_t<__libcpp_is_always_lock_free<__cxx_contention_t>::__value,
1005f757f3fSDimitry Andric                     __cxx_contention_t,
1015f757f3fSDimitry Andric                     __largest_lock_free_type>;
1025f757f3fSDimitry Andric 
1035f757f3fSDimitry Andric using atomic_signed_lock_free   = atomic<__contention_t_or_largest>;
1045f757f3fSDimitry Andric using atomic_unsigned_lock_free = atomic<make_unsigned_t<__contention_t_or_largest>>;
1055f757f3fSDimitry Andric #  endif // !_LIBCPP_NO_LOCK_FREE_TYPES
1065f757f3fSDimitry Andric #endif   // C++20
10706c3fb27SDimitry Andric 
10806c3fb27SDimitry Andric _LIBCPP_END_NAMESPACE_STD
10906c3fb27SDimitry Andric 
11006c3fb27SDimitry Andric #endif // _LIBCPP___ATOMIC_ALIASES_H
111