1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #ifndef BOOST_FIBERS_DETAIL_CPU_RELAX_H
- #define BOOST_FIBERS_DETAIL_CPU_RELAX_H
- #include <chrono>
- #include <thread>
- #include <boost/config.hpp>
- #include <boost/predef.h>
- #include <boost/fiber/detail/config.hpp>
- #if BOOST_COMP_MSVC || BOOST_COMP_MSVC_EMULATED
- # include <windows.h>
- #endif
- #ifdef BOOST_HAS_ABI_HEADERS
- # include BOOST_ABI_PREFIX
- #endif
- namespace boost {
- namespace fibers {
- namespace detail {
- #if BOOST_ARCH_ARM
- # if BOOST_COMP_MSVC
- # define cpu_relax() YieldProcessor();
- # elif (defined(__ARM_ARCH_6K__) || \
- defined(__ARM_ARCH_6Z__) || \
- defined(__ARM_ARCH_6ZK__) || \
- defined(__ARM_ARCH_6T2__) || \
- defined(__ARM_ARCH_7__) || \
- defined(__ARM_ARCH_7A__) || \
- defined(__ARM_ARCH_7R__) || \
- defined(__ARM_ARCH_7M__) || \
- defined(__ARM_ARCH_7S__) || \
- defined(__ARM_ARCH_8A__) || \
- defined(__aarch64__))
- # define cpu_relax() asm volatile ("yield" ::: "memory");
- # else
- # define cpu_relax() asm volatile ("nop" ::: "memory");
- # endif
- #elif BOOST_ARCH_MIPS && (((__mips_isa_rev > 1) && defined(__mips32)) || ((__mips_isa_rev > 2) && defined(__mips64)))
- # define cpu_relax() asm volatile ("pause" ::: "memory");
- #elif BOOST_ARCH_PPC
- # if defined(__POWERPC__)
- # define cpu_relax() asm volatile ("or r27,r27,r27" ::: "memory");
- # else
- # define cpu_relax() asm volatile ("or 27,27,27" ::: "memory");
- # endif
- #elif BOOST_ARCH_X86
- # if BOOST_COMP_MSVC || BOOST_COMP_MSVC_EMULATED
- # define cpu_relax() YieldProcessor();
- # else
- # define cpu_relax() asm volatile ("pause" ::: "memory");
- # endif
- #else
- # define cpu_relax() { \
- static constexpr std::chrono::microseconds us0{ 0 }; \
- std::this_thread::sleep_for( us0); \
- }
- #endif
- }}}
- #ifdef BOOST_HAS_ABI_HEADERS
- # include BOOST_ABI_SUFFIX
- #endif
- #endif
|