1 /*
2  * Distributed under the Boost Software License, Version 1.0.
3  *    (See accompanying file LICENSE_1_0.txt or copy at
4  *          http://www.boost.org/LICENSE_1_0.txt)
5  *
6  * (C) Copyright 2013 Tim Blechmann
7  * (C) Copyright 2013 Andrey Semashev
8  */
9 
10 #ifndef BOOST_SYNC_DETAIL_PAUSE_HPP_INCLUDED_
11 #define BOOST_SYNC_DETAIL_PAUSE_HPP_INCLUDED_
12 
13 #include <boost/sync/detail/config.hpp>
14 #include <boost/sync/detail/header.hpp>
15 
16 #ifdef BOOST_HAS_PRAGMA_ONCE
17 #pragma once
18 #endif
19 
20 #if defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_IX86))
21 extern "C" void _mm_pause(void);
22 #pragma intrinsic(_mm_pause)
23 #endif
24 
25 namespace boost  {
26 namespace sync   {
27 namespace detail {
28 
pause()29 BOOST_FORCEINLINE void pause() BOOST_NOEXCEPT
30 {
31 #if defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_IX86))
32     _mm_pause();
33 
34 #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
35     __asm__ __volatile__("pause;");
36 
37 #endif
38 }
39 
40 } // namespace detail
41 } // namespace sync
42 } // namespace boost
43 
44 #include <boost/sync/detail/footer.hpp>
45 
46 #endif // BOOST_SYNC_DETAIL_PAUSE_HPP_INCLUDED_
47