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) 2020 Andrey Semashev
0007  */
0008 /*!
0009  * \file   atomic/detail/fence_arch_ops_msvc_x86.hpp
0010  *
0011  * This header contains implementation of the \c fence_arch_operations struct.
0012  */
0013 
0014 #ifndef BOOST_ATOMIC_DETAIL_FENCE_ARCH_OPS_MSVC_X86_HPP_INCLUDED_
0015 #define BOOST_ATOMIC_DETAIL_FENCE_ARCH_OPS_MSVC_X86_HPP_INCLUDED_
0016 
0017 #include <boost/cstdint.hpp>
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/ops_msvc_common.hpp>
0022 #include <boost/atomic/detail/header.hpp>
0023 
0024 #ifdef BOOST_HAS_PRAGMA_ONCE
0025 #pragma once
0026 #endif
0027 
0028 namespace boost {
0029 namespace atomics {
0030 namespace detail {
0031 
0032 //! Fence operations for x86
0033 struct fence_arch_operations_msvc_x86
0034 {
0035     static BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT
0036     {
0037         if (order == memory_order_seq_cst)
0038         {
0039             // See the comment in fence_ops_gcc_x86.hpp as to why we're not using mfence here.
0040             // We're not using __faststorefence() here because it generates an atomic operation
0041             // on [rsp]/[esp] location, which may alias valid data and cause false data dependency.
0042             boost::uint32_t dummy;
0043             BOOST_ATOMIC_INTERLOCKED_INCREMENT(&dummy);
0044         }
0045         else if (order != memory_order_relaxed)
0046         {
0047             BOOST_ATOMIC_DETAIL_COMPILER_BARRIER();
0048         }
0049     }
0050 
0051     static BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT
0052     {
0053         if (order != memory_order_relaxed)
0054             BOOST_ATOMIC_DETAIL_COMPILER_BARRIER();
0055     }
0056 };
0057 
0058 typedef fence_arch_operations_msvc_x86 fence_arch_operations;
0059 
0060 } // namespace detail
0061 } // namespace atomics
0062 } // namespace boost
0063 
0064 #include <boost/atomic/detail/footer.hpp>
0065 
0066 #endif // BOOST_ATOMIC_DETAIL_FENCE_ARCH_OPS_MSVC_X86_HPP_INCLUDED_