]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/atomic/detail/fence_ops_gcc_sync.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / atomic / detail / fence_ops_gcc_sync.hpp
1 /*
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
5 *
6 * Copyright (c) 2020 Andrey Semashev
7 */
8 /*!
9 * \file atomic/detail/fence_ops_gcc_sync.hpp
10 *
11 * This header contains implementation of the \c fence_operations struct.
12 */
13
14 #ifndef BOOST_ATOMIC_DETAIL_FENCE_OPS_GCC_SYNC_HPP_INCLUDED_
15 #define BOOST_ATOMIC_DETAIL_FENCE_OPS_GCC_SYNC_HPP_INCLUDED_
16
17 #include <boost/memory_order.hpp>
18 #include <boost/atomic/detail/config.hpp>
19 #include <boost/atomic/detail/header.hpp>
20
21 #ifdef BOOST_HAS_PRAGMA_ONCE
22 #pragma once
23 #endif
24
25 namespace boost {
26 namespace atomics {
27 namespace detail {
28
29 //! Fence operations based on gcc __sync* intrinsics
30 struct fence_operations_gcc_sync
31 {
32 static BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT
33 {
34 if (order != memory_order_relaxed)
35 __sync_synchronize();
36 }
37
38 static BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT
39 {
40 if (order != memory_order_relaxed)
41 __asm__ __volatile__ ("" ::: "memory");
42 }
43 };
44
45 typedef fence_operations_gcc_sync fence_operations;
46
47 } // namespace detail
48 } // namespace atomics
49 } // namespace boost
50
51 #include <boost/atomic/detail/footer.hpp>
52
53 #endif // BOOST_ATOMIC_DETAIL_FENCE_OPS_GCC_SYNC_HPP_INCLUDED_