1 #ifndef BOOST_SMART_PTR_DETAIL_SP_THREAD_PAUSE_HPP_INCLUDED 2 #define BOOST_SMART_PTR_DETAIL_SP_THREAD_PAUSE_HPP_INCLUDED 3 4 // MS compatible compilers support #pragma once 5 6 #if defined(_MSC_VER) && (_MSC_VER >= 1020) 7 # pragma once 8 #endif 9 10 // boost/smart_ptr/detail/sp_thread_pause.hpp 11 // 12 // inline void bost::detail::sp_thread_pause(); 13 // 14 // Emits a "pause" instruction. 15 // 16 // Copyright 2008, 2020 Peter Dimov 17 // Distributed under the Boost Software License, Version 1.0 18 // https://www.boost.org/LICENSE_1_0.txt 19 20 #if defined(_MSC_VER) && _MSC_VER >= 1310 && ( defined(_M_IX86) || defined(_M_X64) ) && !defined(__c2__) 21 22 extern "C" void _mm_pause(); 23 24 #define BOOST_SP_PAUSE _mm_pause(); 25 26 #elif defined(__GNUC__) && ( defined(__i386__) || defined(__x86_64__) ) 27 28 #define BOOST_SP_PAUSE __asm__ __volatile__( "rep; nop" : : : "memory" ); 29 30 #else 31 32 #define BOOST_SP_PAUSE 33 34 #endif 35 36 namespace boost 37 { 38 namespace detail 39 { 40 sp_thread_pause()41inline void sp_thread_pause() 42 { 43 BOOST_SP_PAUSE 44 } 45 46 } // namespace detail 47 } // namespace boost 48 49 #undef BOOST_SP_PAUSE 50 51 #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_THREAD_PAUSE_HPP_INCLUDED 52