Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:33:56

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) 2017 Andrey Semashev
0007  */
0008 /*!
0009  * \file   atomic/detail/extra_ops_msvc_arm.hpp
0010  *
0011  * This header contains implementation of the extra atomic operations for ARM.
0012  */
0013 
0014 #ifndef BOOST_ATOMIC_DETAIL_EXTRA_OPS_MSVC_ARM_HPP_INCLUDED_
0015 #define BOOST_ATOMIC_DETAIL_EXTRA_OPS_MSVC_ARM_HPP_INCLUDED_
0016 
0017 #include <cstddef>
0018 #include <boost/memory_order.hpp>
0019 #include <boost/atomic/detail/config.hpp>
0020 #include <boost/atomic/detail/interlocked.hpp>
0021 #include <boost/atomic/detail/storage_traits.hpp>
0022 #include <boost/atomic/detail/extra_operations_fwd.hpp>
0023 #include <boost/atomic/detail/extra_ops_generic.hpp>
0024 #include <boost/atomic/detail/header.hpp>
0025 
0026 #ifdef BOOST_HAS_PRAGMA_ONCE
0027 #pragma once
0028 #endif
0029 
0030 namespace boost {
0031 namespace atomics {
0032 namespace detail {
0033 
0034 #if defined(BOOST_ATOMIC_INTERLOCKED_BTS) && defined(BOOST_ATOMIC_INTERLOCKED_BTR)
0035 
0036 template< typename Base, std::size_t Size, bool Signed >
0037 struct extra_operations< Base, 4u, Signed, true > :
0038     public extra_operations_generic< Base, 4u, Signed >
0039 {
0040     typedef extra_operations_generic< Base, 4u, Signed > base_type;
0041     typedef typename base_type::storage_type storage_type;
0042 
0043     static BOOST_FORCEINLINE bool bit_test_and_set(storage_type volatile& storage, unsigned int bit_number, memory_order order) BOOST_NOEXCEPT
0044     {
0045 #if defined(BOOST_ATOMIC_INTERLOCKED_BTS_RELAXED) && defined(BOOST_ATOMIC_INTERLOCKED_BTS_ACQUIRE) && defined(BOOST_ATOMIC_INTERLOCKED_BTS_RELEASE)
0046         bool result;
0047         switch (order)
0048         {
0049         case memory_order_relaxed:
0050             result = !!BOOST_ATOMIC_INTERLOCKED_BTS_RELAXED(&storage, bit_number);
0051             break;
0052         case memory_order_consume:
0053         case memory_order_acquire:
0054             result = !!BOOST_ATOMIC_INTERLOCKED_BTS_ACQUIRE(&storage, bit_number);
0055             break;
0056         case memory_order_release:
0057             result = !!BOOST_ATOMIC_INTERLOCKED_BTS_RELEASE(&storage, bit_number);
0058             break;
0059         case memory_order_acq_rel:
0060         case memory_order_seq_cst:
0061         default:
0062             result = !!BOOST_ATOMIC_INTERLOCKED_BTS(&storage, bit_number);
0063             break;
0064         }
0065         return result;
0066 #else
0067         return !!BOOST_ATOMIC_INTERLOCKED_BTS(&storage, bit_number);
0068 #endif
0069     }
0070 
0071     static BOOST_FORCEINLINE bool bit_test_and_reset(storage_type volatile& storage, unsigned int bit_number, memory_order order) BOOST_NOEXCEPT
0072     {
0073 #if defined(BOOST_ATOMIC_INTERLOCKED_BTR_RELAXED) && defined(BOOST_ATOMIC_INTERLOCKED_BTR_ACQUIRE) && defined(BOOST_ATOMIC_INTERLOCKED_BTR_RELEASE)
0074         bool result;
0075         switch (order)
0076         {
0077         case memory_order_relaxed:
0078             result = !!BOOST_ATOMIC_INTERLOCKED_BTR_RELAXED(&storage, bit_number);
0079             break;
0080         case memory_order_consume:
0081         case memory_order_acquire:
0082             result = !!BOOST_ATOMIC_INTERLOCKED_BTR_ACQUIRE(&storage, bit_number);
0083             break;
0084         case memory_order_release:
0085             result = !!BOOST_ATOMIC_INTERLOCKED_BTR_RELEASE(&storage, bit_number);
0086             break;
0087         case memory_order_acq_rel:
0088         case memory_order_seq_cst:
0089         default:
0090             result = !!BOOST_ATOMIC_INTERLOCKED_BTR(&storage, bit_number);
0091             break;
0092         }
0093         return result;
0094 #else
0095         return !!BOOST_ATOMIC_INTERLOCKED_BTR(&storage, bit_number);
0096 #endif
0097     }
0098 };
0099 
0100 #endif // defined(BOOST_ATOMIC_INTERLOCKED_BTS) && defined(BOOST_ATOMIC_INTERLOCKED_BTR)
0101 
0102 } // namespace detail
0103 } // namespace atomics
0104 } // namespace boost
0105 
0106 #include <boost/atomic/detail/footer.hpp>
0107 
0108 #endif // BOOST_ATOMIC_DETAIL_EXTRA_OPS_MSVC_ARM_HPP_INCLUDED_