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