]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/atomic/detail/pause.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / atomic / detail / pause.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 * (C) Copyright 2013 Tim Blechmann
7 * (C) Copyright 2013, 2020 Andrey Semashev
8 */
9
10 #ifndef BOOST_ATOMIC_DETAIL_PAUSE_HPP_INCLUDED_
11 #define BOOST_ATOMIC_DETAIL_PAUSE_HPP_INCLUDED_
12
13 #include <boost/atomic/detail/config.hpp>
14 #include <boost/atomic/detail/header.hpp>
15
16 #ifdef BOOST_HAS_PRAGMA_ONCE
17 #pragma once
18 #endif
19
20 #if defined(_MSC_VER)
21 #if defined(_M_AMD64) || defined(_M_IX86)
22 extern "C" void _mm_pause(void);
23 #if defined(BOOST_MSVC)
24 #pragma intrinsic(_mm_pause)
25 #endif
26 #elif defined(_M_ARM64) || defined(_M_ARM)
27 extern "C" void __yield(void);
28 #if defined(BOOST_MSVC)
29 #pragma intrinsic(__yield)
30 #endif
31 #endif
32 #endif
33
34 namespace boost {
35 namespace atomics {
36 namespace detail {
37
38 BOOST_FORCEINLINE void pause() BOOST_NOEXCEPT
39 {
40 #if defined(_MSC_VER)
41 #if defined(_M_AMD64) || defined(_M_IX86)
42 _mm_pause();
43 #elif defined(_M_ARM64) || defined(_M_ARM)
44 __yield();
45 #endif
46 #elif defined(__GNUC__)
47 #if defined(__i386__) || defined(__x86_64__)
48 __asm__ __volatile__("pause;" : : : "memory");
49 #elif (defined(__ARM_ARCH) && __ARM_ARCH >= 8) || defined(__ARM_ARCH_8A__) || defined(__aarch64__)
50 __asm__ __volatile__("yield;" : : : "memory");
51 #endif
52 #endif
53 }
54
55 } // namespace detail
56 } // namespace atomics
57 } // namespace boost
58
59 #include <boost/atomic/detail/footer.hpp>
60
61 #endif // BOOST_ATOMIC_DETAIL_PAUSE_HPP_INCLUDED_