Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/atomic/detail/pause.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * Distributed under the Boost Software License, Version 1.0.
0003  *    (See accompanying file LICENSE_1_0.txt or copy at
0004  *          http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * (C) Copyright 2013 Tim Blechmann
0007  * (C) Copyright 2013, 2020 Andrey Semashev
0008  */
0009 
0010 #ifndef BOOST_ATOMIC_DETAIL_PAUSE_HPP_INCLUDED_
0011 #define BOOST_ATOMIC_DETAIL_PAUSE_HPP_INCLUDED_
0012 
0013 #include <boost/atomic/detail/config.hpp>
0014 #include <boost/atomic/detail/header.hpp>
0015 
0016 #ifdef BOOST_HAS_PRAGMA_ONCE
0017 #pragma once
0018 #endif
0019 
0020 #if defined(_MSC_VER)
0021 #if defined(_M_AMD64) || defined(_M_IX86)
0022 extern "C" void _mm_pause(void);
0023 #if defined(BOOST_MSVC)
0024 #pragma intrinsic(_mm_pause)
0025 #endif
0026 #elif defined(_M_ARM64) || defined(_M_ARM)
0027 extern "C" void __yield(void);
0028 #if defined(BOOST_MSVC)
0029 #pragma intrinsic(__yield)
0030 #endif
0031 #endif
0032 #endif
0033 
0034 namespace boost {
0035 namespace atomics {
0036 namespace detail {
0037 
0038 BOOST_FORCEINLINE void pause() BOOST_NOEXCEPT
0039 {
0040 #if defined(_MSC_VER)
0041 #if defined(_M_AMD64) || defined(_M_IX86)
0042     _mm_pause();
0043 #elif defined(_M_ARM64) || defined(_M_ARM)
0044     __yield();
0045 #endif
0046 #elif defined(__GNUC__)
0047 #if defined(__i386__) || defined(__x86_64__)
0048     __asm__ __volatile__("pause;" : : : "memory");
0049 #elif (defined(__ARM_ARCH) && __ARM_ARCH >= 8) || defined(__ARM_ARCH_8A__) || defined(__aarch64__)
0050     __asm__ __volatile__("yield;" : : : "memory");
0051 #elif defined(__riscv) && __riscv_xlen == 64
0052 #if defined(__riscv_zihintpause)
0053     __asm__ __volatile__("pause" : : : "memory");
0054 #else
0055     /* Encoding of the pause instruction */
0056     __asm__ __volatile__ (".4byte 0x100000F");
0057 #endif
0058 #endif
0059 #endif
0060 }
0061 
0062 } // namespace detail
0063 } // namespace atomics
0064 } // namespace boost
0065 
0066 #include <boost/atomic/detail/footer.hpp>
0067 
0068 #endif // BOOST_ATOMIC_DETAIL_PAUSE_HPP_INCLUDED_