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_CONTENTION_T_H
10#define _LIBCPP___ATOMIC_CONTENTION_T_H
11
12#include <__atomic/support.h>
13#include <__config>
14#include <cstdint>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22// The original definition of `__cxx_contention_t` seemed a bit arbitrary.
23// When we enable the _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE ABI,
24// use definitions that are based on what the underlying platform supports
25// instead.
26#if defined(_LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE)
27
28# ifdef __linux__
29using __cxx_contention_t _LIBCPP_NODEBUG = int32_t;
30# elif defined(__APPLE__)
31using __cxx_contention_t _LIBCPP_NODEBUG = int64_t;
32# elif defined(__FreeBSD__) && __SIZEOF_LONG__ == 8
33using __cxx_contention_t _LIBCPP_NODEBUG = int64_t;
34# elif defined(_AIX) && !defined(__64BIT__)
35using __cxx_contention_t _LIBCPP_NODEBUG = int32_t;
36# elif defined(_WIN32)
37using __cxx_contention_t _LIBCPP_NODEBUG = int64_t;
38# else
39using __cxx_contention_t _LIBCPP_NODEBUG = int64_t;
40# endif // __linux__
41
42#else // _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE
43
44# if defined(__linux__) || (defined(_AIX) && !defined(__64BIT__))
45using __cxx_contention_t _LIBCPP_NODEBUG = int32_t;
46# else
47using __cxx_contention_t _LIBCPP_NODEBUG = int64_t;
48# endif // __linux__ || (_AIX && !__64BIT__)
49
50#endif // _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE
51
52using __cxx_atomic_contention_t _LIBCPP_NODEBUG = __cxx_atomic_impl<__cxx_contention_t>;
53
54_LIBCPP_END_NAMESPACE_STD
55
56#endif // _LIBCPP___ATOMIC_CONTENTION_T_H
57