1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___ATOMIC_TO_GCC_ORDER_H
10 #define _LIBCPP___ATOMIC_TO_GCC_ORDER_H
12 #include <__atomic/memory_order.h>
15 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16 # pragma GCC system_header
19 _LIBCPP_BEGIN_NAMESPACE_STD
21 #if defined(__ATOMIC_RELAXED) && defined(__ATOMIC_CONSUME) && defined(__ATOMIC_ACQUIRE) && \
22 defined(__ATOMIC_RELEASE) && defined(__ATOMIC_ACQ_REL) && defined(__ATOMIC_SEQ_CST)
24 _LIBCPP_HIDE_FROM_ABI
inline _LIBCPP_CONSTEXPR
int __to_gcc_order(memory_order __order
) {
25 // Avoid switch statement to make this a constexpr.
26 return __order
== memory_order_relaxed
28 : (__order
== memory_order_acquire
30 : (__order
== memory_order_release
32 : (__order
== memory_order_seq_cst
34 : (__order
== memory_order_acq_rel
? __ATOMIC_ACQ_REL
: __ATOMIC_CONSUME
))));
37 _LIBCPP_HIDE_FROM_ABI
inline _LIBCPP_CONSTEXPR
int __to_gcc_failure_order(memory_order __order
) {
38 // Avoid switch statement to make this a constexpr.
39 return __order
== memory_order_relaxed
41 : (__order
== memory_order_acquire
43 : (__order
== memory_order_release
45 : (__order
== memory_order_seq_cst
47 : (__order
== memory_order_acq_rel
? __ATOMIC_ACQUIRE
: __ATOMIC_CONSUME
))));
52 _LIBCPP_END_NAMESPACE_STD
54 #endif // _LIBCPP___ATOMIC_TO_GCC_ORDER_H