File indexing completed on 2025-01-18 09:30:28
0001 #ifndef BOOST_CORE_DETAIL_SP_THREAD_PAUSE_HPP_INCLUDED
0002 #define BOOST_CORE_DETAIL_SP_THREAD_PAUSE_HPP_INCLUDED
0003
0004
0005
0006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
0007 # pragma once
0008 #endif
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <boost/config.hpp>
0021
0022 #if defined(__has_builtin)
0023 # if __has_builtin(__builtin_ia32_pause) && !defined(__INTEL_COMPILER)
0024 # define BOOST_CORE_HAS_BUILTIN_IA32_PAUSE
0025 # endif
0026 #endif
0027
0028 #if defined(BOOST_CORE_HAS_BUILTIN_IA32_PAUSE)
0029
0030 # define BOOST_CORE_SP_PAUSE() __builtin_ia32_pause()
0031
0032 #elif defined(_MSC_VER) && ( defined(_M_IX86) || defined(_M_X64) )
0033
0034 # include <intrin.h>
0035 # define BOOST_CORE_SP_PAUSE() _mm_pause()
0036
0037 #elif defined(_MSC_VER) && ( defined(_M_ARM) || defined(_M_ARM64) )
0038
0039 # include <intrin.h>
0040 # define BOOST_CORE_SP_PAUSE() __yield()
0041
0042 #elif defined(__GNUC__) && ( defined(__i386__) || defined(__x86_64__) )
0043
0044 # define BOOST_CORE_SP_PAUSE() __asm__ __volatile__( "rep; nop" : : : "memory" )
0045
0046 #elif defined(__GNUC__) && ( (defined(__ARM_ARCH) && __ARM_ARCH >= 8) || defined(__ARM_ARCH_8A__) || defined(__aarch64__) )
0047
0048 # define BOOST_CORE_SP_PAUSE() __asm__ __volatile__( "yield" : : : "memory" )
0049
0050 #else
0051
0052 # define BOOST_CORE_SP_PAUSE() ((void)0)
0053
0054 #endif
0055
0056 namespace boost
0057 {
0058 namespace core
0059 {
0060
0061 BOOST_FORCEINLINE void sp_thread_pause() BOOST_NOEXCEPT
0062 {
0063 BOOST_CORE_SP_PAUSE();
0064 }
0065
0066 }
0067 }
0068
0069 #undef BOOST_CORE_SP_PAUSE
0070
0071 #endif