Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:35:34

0001 
0002 //          Copyright Oliver Kowalke 2016.
0003 // Distributed under the Boost Software License, Version 1.0.
0004 //    (See accompanying file LICENSE_1_0.txt or copy at
0005 //          http://www.boost.org/LICENSE_1_0.txt)
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 // http://groups.google.com/a/chromium.org/forum/#!msg/chromium-dev/YGVrZbxYOlU/Vpgy__zeBQAJ
0045 // mnemonic 'yield' is supported from ARMv6k onwards
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 // http://code.metager.de/source/xref/gnu/glibc/sysdeps/powerpc/sys/platform/ppc.h
0054 // http://stackoverflow.com/questions/5425506/equivalent-of-x86-pause-instruction-for-ppc
0055 // mnemonic 'or' shared resource hints
0056 // or 27, 27, 27 This form of 'or' provides a hint that performance
0057 //               will probably be imrpoved if shared resources dedicated
0058 //               to the executing processor are released for use by other
0059 //               processors
0060 // extended mnemonics (available with POWER7)
0061 // yield   ==   or 27, 27, 27
0062 # if defined(__POWERPC__) // Darwin PPC
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 // BOOST_FIBERS_DETAIL_CPU_RELAX_H