hwcaps_gcc_arm.hpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_arm.hpp
  10. *
  11. * This header defines hardware capabilities macros for ARM
  12. */
  13. #ifndef BOOST_ATOMIC_DETAIL_HWCAPS_GCC_ARM_HPP_INCLUDED_
  14. #define BOOST_ATOMIC_DETAIL_HWCAPS_GCC_ARM_HPP_INCLUDED_
  15. #include <boost/atomic/detail/config.hpp>
  16. #include <boost/atomic/detail/platform.hpp>
  17. #ifdef BOOST_HAS_PRAGMA_ONCE
  18. #pragma once
  19. #endif
  20. #if defined(__GNUC__) && defined(__arm__) && (BOOST_ATOMIC_DETAIL_ARM_ARCH+0) >= 6
  21. #if BOOST_ATOMIC_DETAIL_ARM_ARCH > 6
  22. // ARMv7 and later have dmb instruction
  23. #define BOOST_ATOMIC_DETAIL_ARM_HAS_DMB 1
  24. #endif
  25. #if defined(__ARM_FEATURE_LDREX)
  26. #if (__ARM_FEATURE_LDREX & 1)
  27. #define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXB_STREXB 1
  28. #endif
  29. #if (__ARM_FEATURE_LDREX & 2)
  30. #define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXH_STREXH 1
  31. #endif
  32. #if (__ARM_FEATURE_LDREX & 8)
  33. #define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXD_STREXD 1
  34. #endif
  35. #else // defined(__ARM_FEATURE_LDREX)
  36. #if !(defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6Z__))
  37. // ARMv6k and ARMv7 have 8 and 16-bit ldrex/strex variants, but at least GCC 4.7 fails to compile them. GCC 4.9 is known to work.
  38. #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409
  39. #define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXB_STREXB 1
  40. #define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXH_STREXH 1
  41. #endif
  42. #if !(((defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__)) && defined(__thumb__)) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7M__))
  43. // ARMv6k and ARMv7 except ARMv7-M have 64-bit ldrex/strex variants.
  44. // Unfortunately, GCC (at least 4.7.3 on Ubuntu) does not allocate register pairs properly when targeting ARMv6k Thumb,
  45. // which is required for ldrexd/strexd instructions, so we disable 64-bit support. When targeting ARMv6k ARM
  46. // or ARMv7 (both ARM and Thumb 2) it works as expected.
  47. #define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXD_STREXD 1
  48. #endif
  49. #endif // !(defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6Z__))
  50. #endif // defined(__ARM_FEATURE_LDREX)
  51. #endif // defined(__GNUC__) && defined(__arm__) && (BOOST_ATOMIC_DETAIL_ARM_ARCH+0) >= 6
  52. #endif // BOOST_ATOMIC_DETAIL_HWCAPS_GCC_ARM_HPP_INCLUDED_