Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:43:51

0001 /*
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * Copyright (c) 2020 Andrey Semashev
0007  */
0008 /*!
0009  * \file   atomic/detail/memory_order_utils.hpp
0010  *
0011  * This header contains utilities related to memory order constants.
0012  */
0013 
0014 #ifndef BOOST_ATOMIC_DETAIL_MEMORY_ORDER_UTILS_HPP_INCLUDED_
0015 #define BOOST_ATOMIC_DETAIL_MEMORY_ORDER_UTILS_HPP_INCLUDED_
0016 
0017 #include <boost/memory_order.hpp>
0018 #include <boost/atomic/detail/config.hpp>
0019 #include <boost/atomic/detail/header.hpp>
0020 
0021 #ifdef BOOST_HAS_PRAGMA_ONCE
0022 #pragma once
0023 #endif
0024 
0025 namespace boost {
0026 namespace atomics {
0027 namespace detail {
0028 
0029 BOOST_FORCEINLINE BOOST_CONSTEXPR memory_order deduce_failure_order(memory_order order) BOOST_NOEXCEPT
0030 {
0031     return order == memory_order_acq_rel ? memory_order_acquire : (order == memory_order_release ? memory_order_relaxed : order);
0032 }
0033 
0034 BOOST_FORCEINLINE BOOST_CONSTEXPR bool cas_failure_order_must_not_be_stronger_than_success_order(memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT
0035 {
0036     // 15 == (memory_order_seq_cst | memory_order_consume), see memory_order.hpp
0037     // Given the enum values we can test the strength of memory order requirements with this single condition.
0038     return (static_cast< unsigned int >(failure_order) & 15u) <= (static_cast< unsigned int >(success_order) & 15u);
0039 }
0040 
0041 } // namespace detail
0042 } // namespace atomics
0043 } // namespace boost
0044 
0045 #include <boost/atomic/detail/footer.hpp>
0046 
0047 #endif // BOOST_ATOMIC_DETAIL_MEMORY_ORDER_UTILS_HPP_INCLUDED_