hwcaps_gcc_x86.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. * Copyright (c) 2017 Andrey Semashev
  7. */
  8. /*!
  9. * \file atomic/detail/hwcaps_gcc_x86.hpp
  10. *
  11. * This header defines hardware capabilities macros for x86
  12. */
  13. #ifndef BOOST_ATOMIC_DETAIL_HWCAPS_GCC_X86_HPP_INCLUDED_
  14. #define BOOST_ATOMIC_DETAIL_HWCAPS_GCC_X86_HPP_INCLUDED_
  15. #include <boost/atomic/detail/config.hpp>
  16. #ifdef BOOST_HAS_PRAGMA_ONCE
  17. #pragma once
  18. #endif
  19. #if defined(__GNUC__)
  20. #if defined(__i386__) &&\
  21. (\
  22. defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) ||\
  23. defined(__i586__) || defined(__i686__) || defined(__SSE__)\
  24. )
  25. #define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B 1
  26. #endif
  27. #if defined(__x86_64__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16)
  28. #define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B 1
  29. #endif
  30. #if defined(__x86_64__) || defined(__SSE2__)
  31. // Use mfence only if SSE2 is available
  32. #define BOOST_ATOMIC_DETAIL_X86_HAS_MFENCE 1
  33. #endif
  34. #else // defined(__GNUC__)
  35. #if defined(__i386__) && !defined(BOOST_ATOMIC_NO_CMPXCHG8B)
  36. #define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B 1
  37. #endif
  38. #if defined(__x86_64__) && !defined(BOOST_ATOMIC_NO_CMPXCHG16B)
  39. #define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B 1
  40. #endif
  41. #if !defined(BOOST_ATOMIC_NO_MFENCE)
  42. #define BOOST_ATOMIC_DETAIL_X86_HAS_MFENCE 1
  43. #endif
  44. #endif // defined(__GNUC__)
  45. #endif // BOOST_ATOMIC_DETAIL_HWCAPS_GCC_X86_HPP_INCLUDED_