pause.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright Andrey Semashev 2016.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file pause.hpp
  9. * \author Andrey Semashev
  10. * \date 06.01.2016
  11. *
  12. * \brief This header is the Boost.Log library implementation, see the library documentation
  13. * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
  14. */
  15. #ifndef BOOST_LOG_DETAIL_PAUSE_HPP_INCLUDED_
  16. #define BOOST_LOG_DETAIL_PAUSE_HPP_INCLUDED_
  17. #include <boost/log/detail/config.hpp>
  18. #include <boost/log/detail/header.hpp>
  19. #ifdef BOOST_HAS_PRAGMA_ONCE
  20. #pragma once
  21. #endif
  22. #if defined(__INTEL_COMPILER) || defined(_MSC_VER)
  23. # if defined(_M_IX86)
  24. # define BOOST_LOG_AUX_PAUSE __asm { pause }
  25. # elif defined(_M_AMD64)
  26. extern "C" void _mm_pause(void);
  27. # if defined(BOOST_MSVC)
  28. # pragma intrinsic(_mm_pause)
  29. # endif
  30. # define BOOST_LOG_AUX_PAUSE _mm_pause()
  31. # endif
  32. #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
  33. # define BOOST_LOG_AUX_PAUSE __asm__ __volatile__("pause;")
  34. #endif
  35. namespace boost {
  36. BOOST_LOG_OPEN_NAMESPACE
  37. namespace aux {
  38. BOOST_FORCEINLINE void pause() BOOST_NOEXCEPT
  39. {
  40. #if defined(BOOST_LOG_AUX_PAUSE)
  41. BOOST_LOG_AUX_PAUSE;
  42. #endif
  43. }
  44. } // namespace aux
  45. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  46. } // namespace boost
  47. #include <boost/log/detail/footer.hpp>
  48. #endif // BOOST_LOG_DETAIL_PAUSE_HPP_INCLUDED_