config.hpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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) 2012 Hartmut Kaiser
  7. * Copyright (c) 2014-2018, 2020-2021 Andrey Semashev
  8. */
  9. /*!
  10. * \file atomic/detail/config.hpp
  11. *
  12. * This header defines configuraion macros for Boost.Atomic
  13. */
  14. #ifndef BOOST_ATOMIC_DETAIL_CONFIG_HPP_INCLUDED_
  15. #define BOOST_ATOMIC_DETAIL_CONFIG_HPP_INCLUDED_
  16. #include <boost/config.hpp>
  17. #ifdef BOOST_HAS_PRAGMA_ONCE
  18. #pragma once
  19. #endif
  20. #if defined(__CUDACC__)
  21. // nvcc does not support alternatives ("q,m") in asm statement constraints
  22. #define BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES
  23. // nvcc does not support condition code register ("cc") clobber in asm statements
  24. #define BOOST_ATOMIC_DETAIL_NO_ASM_CLOBBER_CC
  25. #endif
  26. #if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CLOBBER_CC)
  27. #define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC "cc"
  28. #define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "cc",
  29. #else
  30. #define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC
  31. #define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA
  32. #endif
  33. #if (defined(__i386__) || defined(__x86_64__)) && (defined(__clang__) || (defined(BOOST_GCC) && BOOST_GCC < 40500) || defined(__SUNPRO_CC))
  34. // This macro indicates that the compiler does not support allocating eax:edx or rax:rdx register pairs ("A") in asm blocks
  35. #define BOOST_ATOMIC_DETAIL_X86_NO_ASM_AX_DX_PAIRS
  36. #endif
  37. #if defined(__i386__) && (defined(__PIC__) || defined(__PIE__)) && !(defined(__clang__) || (defined(BOOST_GCC) && BOOST_GCC >= 50100))
  38. // This macro indicates that asm blocks should preserve ebx value unchanged. Some compilers are able to maintain ebx themselves
  39. // around the asm blocks. For those compilers we don't need to save/restore ebx in asm blocks.
  40. #define BOOST_ATOMIC_DETAIL_X86_ASM_PRESERVE_EBX
  41. #endif
  42. #if defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
  43. #if !(defined(BOOST_LIBSTDCXX11) && BOOST_LIBSTDCXX_VERSION >= 40700) /* libstdc++ from gcc >= 4.7 in C++11 mode */
  44. // This macro indicates that there is not even a basic <type_traits> standard header that is sufficient for most Boost.Atomic needs.
  45. #define BOOST_ATOMIC_DETAIL_NO_CXX11_BASIC_HDR_TYPE_TRAITS
  46. #endif
  47. #endif // defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
  48. #if defined(BOOST_NO_CXX11_ALIGNAS) ||\
  49. (defined(BOOST_GCC) && BOOST_GCC < 40900) ||\
  50. (defined(BOOST_MSVC) && BOOST_MSVC < 1910 && defined(_M_IX86))
  51. // gcc prior to 4.9 doesn't support alignas with a constant expression as an argument.
  52. // MSVC 14.0 does support alignas, but in 32-bit mode emits "error C2719: formal parameter with requested alignment of N won't be aligned" for N > 4,
  53. // when aligned types are used in function arguments, even though the std::max_align_t type has alignment of 8.
  54. #define BOOST_ATOMIC_DETAIL_NO_CXX11_ALIGNAS
  55. #endif
  56. #if defined(BOOST_NO_CXX11_CONSTEXPR) || (defined(BOOST_GCC) && BOOST_GCC < 40800)
  57. // This macro indicates that the compiler doesn't support constexpr constructors that initialize one member
  58. // of an anonymous union member of the class.
  59. #define BOOST_ATOMIC_DETAIL_NO_CXX11_CONSTEXPR_UNION_INIT
  60. #endif
  61. #if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_CONSTEXPR_UNION_INIT)
  62. #define BOOST_ATOMIC_DETAIL_CONSTEXPR_UNION_INIT BOOST_CONSTEXPR
  63. #else
  64. #define BOOST_ATOMIC_DETAIL_CONSTEXPR_UNION_INIT
  65. #endif
  66. // Enable pointer/reference casts between storage and value when possible.
  67. // Note: Despite that MSVC does not employ strict aliasing rules for optimizations
  68. // and does not require an explicit markup for types that may alias, we still don't
  69. // enable the optimization for this compiler because at least MSVC-8 and 9 are known
  70. // to generate broken code sometimes when casts are used.
  71. #define BOOST_ATOMIC_DETAIL_MAY_ALIAS BOOST_MAY_ALIAS
  72. #if !defined(BOOST_NO_MAY_ALIAS)
  73. #define BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS
  74. #endif
  75. #if defined(__GCC_ASM_FLAG_OUTPUTS__)
  76. // The compiler supports output values in flag registers.
  77. // See: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html, Section 6.44.3.
  78. #define BOOST_ATOMIC_DETAIL_ASM_HAS_FLAG_OUTPUTS
  79. #endif
  80. #if defined(BOOST_INTEL) || (defined(BOOST_GCC) && BOOST_GCC < 40700) ||\
  81. (defined(BOOST_CLANG) && !defined(__apple_build_version__) && (__clang_major__ * 100 + __clang_minor__) < 302) ||\
  82. (defined(__clang__) && defined(__apple_build_version__) && (__clang_major__ * 100 + __clang_minor__) < 402)
  83. // Intel compiler (at least 18.0 update 1) breaks if noexcept specification is used in defaulted function declarations:
  84. // error: the default constructor of "boost::atomics::atomic<T>" cannot be referenced -- it is a deleted function
  85. // GCC 4.6 doesn't seem to support that either. Clang 3.1 deduces wrong noexcept for the defaulted function and fails as well.
  86. #define BOOST_ATOMIC_DETAIL_DEF_NOEXCEPT_DECL
  87. #define BOOST_ATOMIC_DETAIL_DEF_NOEXCEPT_IMPL BOOST_NOEXCEPT
  88. #else
  89. #define BOOST_ATOMIC_DETAIL_DEF_NOEXCEPT_DECL BOOST_NOEXCEPT
  90. #define BOOST_ATOMIC_DETAIL_DEF_NOEXCEPT_IMPL
  91. #endif
  92. #if defined(__has_builtin)
  93. #if __has_builtin(__builtin_constant_p)
  94. #define BOOST_ATOMIC_DETAIL_IS_CONSTANT(x) __builtin_constant_p(x)
  95. #endif
  96. #if __has_builtin(__builtin_clear_padding)
  97. #define BOOST_ATOMIC_DETAIL_CLEAR_PADDING(x) __builtin_clear_padding(x)
  98. #elif __has_builtin(__builtin_zero_non_value_bits)
  99. #define BOOST_ATOMIC_DETAIL_CLEAR_PADDING(x) __builtin_zero_non_value_bits(x)
  100. #endif
  101. #endif
  102. #if !defined(BOOST_ATOMIC_DETAIL_IS_CONSTANT) && defined(__GNUC__)
  103. #define BOOST_ATOMIC_DETAIL_IS_CONSTANT(x) __builtin_constant_p(x)
  104. #endif
  105. #if !defined(BOOST_ATOMIC_DETAIL_IS_CONSTANT)
  106. #define BOOST_ATOMIC_DETAIL_IS_CONSTANT(x) false
  107. #endif
  108. #if !defined(BOOST_ATOMIC_DETAIL_CLEAR_PADDING) && defined(BOOST_MSVC) && BOOST_MSVC >= 1927
  109. // Note that as of MSVC 19.29 this intrinsic does not clear padding in unions:
  110. // https://developercommunity.visualstudio.com/t/__builtin_zero_non_value_bits-does-not-c/1551510
  111. #define BOOST_ATOMIC_DETAIL_CLEAR_PADDING(x) __builtin_zero_non_value_bits(x)
  112. #endif
  113. #if !defined(BOOST_ATOMIC_DETAIL_CLEAR_PADDING)
  114. #define BOOST_ATOMIC_NO_CLEAR_PADDING
  115. #define BOOST_ATOMIC_DETAIL_CLEAR_PADDING(x)
  116. #endif
  117. #if (defined(__BYTE_ORDER__) && defined(__FLOAT_WORD_ORDER__) && __BYTE_ORDER__ == __FLOAT_WORD_ORDER__) ||\
  118. defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
  119. // This macro indicates that integer and floating point endianness is the same
  120. #define BOOST_ATOMIC_DETAIL_INT_FP_ENDIAN_MATCH
  121. #endif
  122. #endif // BOOST_ATOMIC_DETAIL_CONFIG_HPP_INCLUDED_