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 Andrey Semashev 8 */ 9 /*! 10 * \file atomic/detail/config.hpp 11 * 12 * This header defines configuraion macros for Boost.Atomic 13 */ 14 15 #ifndef BOOST_ATOMIC_DETAIL_CONFIG_HPP_INCLUDED_ 16 #define BOOST_ATOMIC_DETAIL_CONFIG_HPP_INCLUDED_ 17 18 #include <boost/config.hpp> 19 20 #ifdef BOOST_HAS_PRAGMA_ONCE 21 #pragma once 22 #endif 23 24 #if defined(__CUDACC__) 25 // nvcc does not support alternatives ("q,m") in asm statement constraints 26 #define BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES 27 // nvcc does not support condition code register ("cc") clobber in asm statements 28 #define BOOST_ATOMIC_DETAIL_NO_ASM_CLOBBER_CC 29 #endif 30 31 #if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CLOBBER_CC) 32 #define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC "cc" 33 #define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "cc", 34 #else 35 #define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC 36 #define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA 37 #endif 38 39 #if (defined(__i386__) || defined(__x86_64__)) && (defined(__clang__) || (defined(BOOST_GCC) && (BOOST_GCC+0) < 40500) || defined(__SUNPRO_CC)) 40 // This macro indicates that the compiler does not support allocating eax:edx or rax:rdx register pairs ("A") in asm blocks 41 #define BOOST_ATOMIC_DETAIL_X86_NO_ASM_AX_DX_PAIRS 42 #endif 43 44 #if defined(__i386__) && (defined(__PIC__) || defined(__PIE__)) && !(defined(__clang__) || (defined(BOOST_GCC) && (BOOST_GCC+0) >= 50100)) 45 // This macro indicates that asm blocks should preserve ebx value unchanged. Some compilers are able to maintain ebx themselves 46 // around the asm blocks. For those compilers we don't need to save/restore ebx in asm blocks. 47 #define BOOST_ATOMIC_DETAIL_X86_ASM_PRESERVE_EBX 48 #endif 49 50 #if defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) 51 #if !(defined(BOOST_LIBSTDCXX11) && (BOOST_LIBSTDCXX_VERSION+0) >= 40700) /* libstdc++ from gcc >= 4.7 in C++11 mode */ 52 // This macro indicates that there is not even a basic <type_traits> standard header that is sufficient for most Boost.Atomic needs. 53 #define BOOST_ATOMIC_DETAIL_NO_CXX11_BASIC_HDR_TYPE_TRAITS 54 #endif 55 #endif // defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) 56 57 #if defined(BOOST_NO_CXX11_ALIGNAS) ||\ 58 (defined(BOOST_GCC) && (BOOST_GCC+0) < 40900) ||\ 59 (defined(BOOST_MSVC) && (BOOST_MSVC+0) < 1910 && defined(_M_IX86)) 60 // gcc prior to 4.9 doesn't support alignas with a constant expression as an argument. 61 // 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, 62 // when aligned types are used in function arguments, even though the std::max_align_t type has alignment of 8. 63 #define BOOST_ATOMIC_DETAIL_NO_CXX11_ALIGNAS 64 #endif 65 66 #if defined(BOOST_NO_CXX11_CONSTEXPR) || (defined(BOOST_GCC) && (BOOST_GCC+0) < 40800) 67 // This macro indicates that the compiler doesn't support constexpr constructors that initialize one member 68 // of an anonymous union member of the class. 69 #define BOOST_ATOMIC_DETAIL_NO_CXX11_CONSTEXPR_UNION_INIT 70 #endif 71 72 #if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_CONSTEXPR_UNION_INIT) 73 #define BOOST_ATOMIC_DETAIL_CONSTEXPR_UNION_INIT BOOST_CONSTEXPR 74 #else 75 #define BOOST_ATOMIC_DETAIL_CONSTEXPR_UNION_INIT 76 #endif 77 78 // Enable pointer/reference casts between storage and value when possible. 79 // Note: Despite that MSVC does not employ strict aliasing rules for optimizations 80 // and does not require an explicit markup for types that may alias, we still don't 81 // enable the optimization for this compiler because at least MSVC-8 and 9 are known 82 // to generate broken code sometimes when casts are used. 83 #define BOOST_ATOMIC_DETAIL_MAY_ALIAS BOOST_MAY_ALIAS 84 #if !defined(BOOST_NO_MAY_ALIAS) 85 #define BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS 86 #endif 87 88 #if defined(__GCC_ASM_FLAG_OUTPUTS__) 89 // The compiler supports output values in flag registers. 90 // See: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html, Section 6.44.3. 91 #define BOOST_ATOMIC_DETAIL_ASM_HAS_FLAG_OUTPUTS 92 #endif 93 94 #if defined(BOOST_INTEL) || (defined(BOOST_GCC) && (BOOST_GCC+0) < 40700) ||\ 95 (defined(BOOST_CLANG) && !defined(__apple_build_version__) && ((__clang_major__+0) * 100 + (__clang_minor__+0)) < 302) ||\ 96 (defined(__clang__) && defined(__apple_build_version__) && ((__clang_major__+0) * 100 + (__clang_minor__+0)) < 402) 97 // Intel compiler (at least 18.0 update 1) breaks if noexcept specification is used in defaulted function declarations: 98 // error: the default constructor of "boost::atomics::atomic<T>" cannot be referenced -- it is a deleted function 99 // GCC 4.6 doesn't seem to support that either. Clang 3.1 deduces wrong noexcept for the defaulted function and fails as well. 100 #define BOOST_ATOMIC_DETAIL_DEF_NOEXCEPT_DECL 101 #define BOOST_ATOMIC_DETAIL_DEF_NOEXCEPT_IMPL BOOST_NOEXCEPT 102 #else 103 #define BOOST_ATOMIC_DETAIL_DEF_NOEXCEPT_DECL BOOST_NOEXCEPT 104 #define BOOST_ATOMIC_DETAIL_DEF_NOEXCEPT_IMPL 105 #endif 106 107 #if defined(__has_builtin) 108 #if __has_builtin(__builtin_constant_p) 109 #define BOOST_ATOMIC_DETAIL_IS_CONSTANT(x) __builtin_constant_p(x) 110 #endif 111 #elif defined(__GNUC__) 112 #define BOOST_ATOMIC_DETAIL_IS_CONSTANT(x) __builtin_constant_p(x) 113 #endif 114 115 #if !defined(BOOST_ATOMIC_DETAIL_IS_CONSTANT) 116 #define BOOST_ATOMIC_DETAIL_IS_CONSTANT(x) false 117 #endif 118 119 #if (defined(__BYTE_ORDER__) && defined(__FLOAT_WORD_ORDER__) && (__BYTE_ORDER__+0) == (__FLOAT_WORD_ORDER__+0)) ||\ 120 defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) 121 // This macro indicates that integer and floating point endianness is the same 122 #define BOOST_ATOMIC_DETAIL_INT_FP_ENDIAN_MATCH 123 #endif 124 125 // Deprecated symbols markup 126 #if !defined(BOOST_ATOMIC_DETAIL_DEPRECATED) && defined(_MSC_VER) 127 #if (_MSC_VER) >= 1400 128 #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) __declspec(deprecated(msg)) 129 #else 130 // MSVC 7.1 only supports the attribute without a message 131 #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) __declspec(deprecated) 132 #endif 133 #endif 134 135 #if !defined(BOOST_ATOMIC_DETAIL_DEPRECATED) && defined(__has_extension) 136 #if __has_extension(attribute_deprecated_with_message) 137 #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) __attribute__((deprecated(msg))) 138 #endif 139 #endif 140 141 // gcc since 4.5 supports deprecated attribute with a message; older versions support the attribute without a message. 142 // Oracle Studio 12.4 supports deprecated attribute with a message; this is the first release that supports the attribute. 143 #if !defined(BOOST_ATOMIC_DETAIL_DEPRECATED) && (\ 144 (defined(__GNUC__) && ((__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0)) >= 405) ||\ 145 (defined(__SUNPRO_CC) && (__SUNPRO_CC + 0) >= 0x5130)) 146 #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) __attribute__((deprecated(msg))) 147 #endif 148 149 #if !defined(BOOST_ATOMIC_DETAIL_DEPRECATED) && __cplusplus >= 201402 150 #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) [[deprecated(msg)]] 151 #endif 152 153 #if !defined(BOOST_ATOMIC_DETAIL_DEPRECATED) && defined(__GNUC__) 154 #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) __attribute__((deprecated)) 155 #endif 156 157 #if !defined(BOOST_ATOMIC_DETAIL_DEPRECATED) && defined(__has_attribute) 158 #if __has_attribute(deprecated) 159 #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) __attribute__((deprecated)) 160 #endif 161 #endif 162 163 #if !defined(BOOST_ATOMIC_DETAIL_DEPRECATED) 164 #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) 165 #endif 166 167 // In Boost.Atomic 1.73 we deprecated atomic<>::storage() accessor in favor of atomic<>::value(). In future releases storage() will be removed. 168 #if !defined(BOOST_ATOMIC_SILENCE_STORAGE_DEPRECATION) 169 #define BOOST_ATOMIC_DETAIL_STORAGE_DEPRECATED BOOST_ATOMIC_DETAIL_DEPRECATED("Boost.Atomic 1.73 has deprecated atomic<>::storage() in favor of atomic<>::value() and atomic<>::storage_type in favor of atomic<>::value_type. You can define BOOST_ATOMIC_SILENCE_STORAGE_DEPRECATION to disable this warning.") 170 #else 171 #define BOOST_ATOMIC_DETAIL_STORAGE_DEPRECATED 172 #endif 173 174 #endif // BOOST_ATOMIC_DETAIL_CONFIG_HPP_INCLUDED_ 175