File indexing completed on 2025-01-30 09:35:34
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_FIBERS_DETAIL_CPU_RELAX_H
0008 #define BOOST_FIBERS_DETAIL_CPU_RELAX_H
0009
0010 #include <chrono>
0011 #include <thread>
0012
0013 #include <boost/config.hpp>
0014 #include <boost/predef.h>
0015
0016 #include <boost/fiber/detail/config.hpp>
0017
0018 #if BOOST_COMP_MSVC || BOOST_COMP_MSVC_EMULATED
0019 # include <windows.h>
0020 #endif
0021
0022 #ifdef BOOST_HAS_ABI_HEADERS
0023 # include BOOST_ABI_PREFIX
0024 #endif
0025
0026 namespace boost {
0027 namespace fibers {
0028 namespace detail {
0029
0030 #if BOOST_ARCH_ARM
0031 # if BOOST_COMP_MSVC
0032 # define cpu_relax() YieldProcessor();
0033 # elif (defined(__ARM_ARCH_6K__) || \
0034 defined(__ARM_ARCH_6Z__) || \
0035 defined(__ARM_ARCH_6ZK__) || \
0036 defined(__ARM_ARCH_6T2__) || \
0037 defined(__ARM_ARCH_7__) || \
0038 defined(__ARM_ARCH_7A__) || \
0039 defined(__ARM_ARCH_7R__) || \
0040 defined(__ARM_ARCH_7M__) || \
0041 defined(__ARM_ARCH_7S__) || \
0042 defined(__ARM_ARCH_8A__) || \
0043 defined(__aarch64__))
0044
0045
0046 # define cpu_relax() asm volatile ("yield" ::: "memory");
0047 # else
0048 # define cpu_relax() asm volatile ("nop" ::: "memory");
0049 # endif
0050 #elif BOOST_ARCH_MIPS && (((__mips_isa_rev > 1) && defined(__mips32)) || ((__mips_isa_rev > 2) && defined(__mips64)))
0051 # define cpu_relax() asm volatile ("pause" ::: "memory");
0052 #elif BOOST_ARCH_PPC
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 # if defined(__POWERPC__)
0063 # define cpu_relax() asm volatile ("or r27,r27,r27" ::: "memory");
0064 # else
0065 # define cpu_relax() asm volatile ("or 27,27,27" ::: "memory");
0066 # endif
0067 #elif BOOST_ARCH_X86
0068 # if BOOST_COMP_MSVC || BOOST_COMP_MSVC_EMULATED
0069 # define cpu_relax() YieldProcessor();
0070 # else
0071 # define cpu_relax() asm volatile ("pause" ::: "memory");
0072 # endif
0073 #else
0074 # define cpu_relax() { \
0075 static constexpr std::chrono::microseconds us0{ 0 }; \
0076 std::this_thread::sleep_for( us0); \
0077 }
0078 #endif
0079
0080 }}}
0081
0082 #ifdef BOOST_HAS_ABI_HEADERS
0083 # include BOOST_ABI_SUFFIX
0084 #endif
0085
0086 #endif