caps_arch_gcc_aarch64.hpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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) 2020, 2022 Andrey Semashev
  7. */
  8. /*!
  9. * \file atomic/detail/caps_arch_gcc_aarch64.hpp
  10. *
  11. * This header defines feature capabilities macros
  12. */
  13. #ifndef BOOST_ATOMIC_DETAIL_CAPS_ARCH_GCC_AARCH64_HPP_INCLUDED_
  14. #define BOOST_ATOMIC_DETAIL_CAPS_ARCH_GCC_AARCH64_HPP_INCLUDED_
  15. #include <boost/atomic/detail/config.hpp>
  16. #ifdef BOOST_HAS_PRAGMA_ONCE
  17. #pragma once
  18. #endif
  19. #if defined(__AARCH64EL__) || \
  20. (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
  21. (defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \
  22. defined(BOOST_WINDOWS)
  23. #define BOOST_ATOMIC_DETAIL_AARCH64_LITTLE_ENDIAN
  24. #elif defined(__AARCH64EB__) || \
  25. defined(__ARM_BIG_ENDIAN) || \
  26. (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) || \
  27. (defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__))
  28. #define BOOST_ATOMIC_DETAIL_AARCH64_BIG_ENDIAN
  29. #else
  30. #include <boost/predef/other/endian.h>
  31. #if BOOST_ENDIAN_LITTLE_BYTE
  32. #define BOOST_ATOMIC_DETAIL_AARCH64_LITTLE_ENDIAN
  33. #elif BOOST_ENDIAN_BIG_BYTE
  34. #define BOOST_ATOMIC_DETAIL_AARCH64_BIG_ENDIAN
  35. #else
  36. #error "Boost.Atomic: Failed to determine AArch64 endianness, the target platform is not supported. Please, report to the developers (patches are welcome)."
  37. #endif
  38. #endif
  39. #if defined(__ARM_FEATURE_ATOMICS)
  40. // ARMv8.1 added Large System Extensions, which includes cas, swp, and a number of other read-modify-write instructions
  41. #define BOOST_ATOMIC_DETAIL_AARCH64_HAS_LSE
  42. #endif
  43. #if defined(__ARM_FEATURE_COMPLEX)
  44. // ARMv8.3 added Release Consistency processor consistent (RCpc) memory model, which includes ldapr and similar instructions.
  45. // Unfortunately, there seems to be no dedicated __ARM_FEATURE macro for this, so we use __ARM_FEATURE_COMPLEX, which is also defined starting ARMv8.3.
  46. #define BOOST_ATOMIC_DETAIL_AARCH64_HAS_RCPC
  47. #endif
  48. #define BOOST_ATOMIC_INT8_LOCK_FREE 2
  49. #define BOOST_ATOMIC_INT16_LOCK_FREE 2
  50. #define BOOST_ATOMIC_INT32_LOCK_FREE 2
  51. #define BOOST_ATOMIC_INT64_LOCK_FREE 2
  52. #define BOOST_ATOMIC_INT128_LOCK_FREE 2
  53. #define BOOST_ATOMIC_POINTER_LOCK_FREE 2
  54. #define BOOST_ATOMIC_THREAD_FENCE 2
  55. #define BOOST_ATOMIC_SIGNAL_FENCE 2
  56. #endif // BOOST_ATOMIC_DETAIL_CAPS_ARCH_GCC_AARCH64_HPP_INCLUDED_