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