Warning: This file is not a C or C++ file. It does not have highlighting.
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___CXX03___ATOMIC_TO_GCC_ORDER_H |
10 | #define _LIBCPP___CXX03___ATOMIC_TO_GCC_ORDER_H |
11 | |
12 | #include <__cxx03/__atomic/memory_order.h> |
13 | #include <__cxx03/__config> |
14 | |
15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
16 | # pragma GCC system_header |
17 | #endif |
18 | |
19 | _LIBCPP_BEGIN_NAMESPACE_STD |
20 | |
21 | #if defined(__ATOMIC_RELAXED) && defined(__ATOMIC_CONSUME) && defined(__ATOMIC_ACQUIRE) && \ |
22 | defined(__ATOMIC_RELEASE) && defined(__ATOMIC_ACQ_REL) && defined(__ATOMIC_SEQ_CST) |
23 | |
24 | _LIBCPP_HIDE_FROM_ABI inline int __to_gcc_order(memory_order __order) { |
25 | // Avoid switch statement to make this a constexpr. |
26 | return __order == memory_order_relaxed |
27 | ? __ATOMIC_RELAXED |
28 | : (__order == memory_order_acquire |
29 | ? __ATOMIC_ACQUIRE |
30 | : (__order == memory_order_release |
31 | ? __ATOMIC_RELEASE |
32 | : (__order == memory_order_seq_cst |
33 | ? __ATOMIC_SEQ_CST |
34 | : (__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL : __ATOMIC_CONSUME)))); |
35 | } |
36 | |
37 | _LIBCPP_HIDE_FROM_ABI inline int __to_gcc_failure_order(memory_order __order) { |
38 | // Avoid switch statement to make this a constexpr. |
39 | return __order == memory_order_relaxed |
40 | ? __ATOMIC_RELAXED |
41 | : (__order == memory_order_acquire |
42 | ? __ATOMIC_ACQUIRE |
43 | : (__order == memory_order_release |
44 | ? __ATOMIC_RELAXED |
45 | : (__order == memory_order_seq_cst |
46 | ? __ATOMIC_SEQ_CST |
47 | : (__order == memory_order_acq_rel ? __ATOMIC_ACQUIRE : __ATOMIC_CONSUME)))); |
48 | } |
49 | |
50 | #endif |
51 | |
52 | _LIBCPP_END_NAMESPACE_STD |
53 | |
54 | #endif // _LIBCPP___CXX03___ATOMIC_TO_GCC_ORDER_H |
55 |
Warning: This file is not a C or C++ file. It does not have highlighting.