Brian Silverman | 7e17102 | 2018-08-05 00:17:49 -0700 | [diff] [blame^] | 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 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 | // Enable pointer/reference casts between storage and value when possible. |
| 58 | // Note: Despite that MSVC does not employ strict aliasing rules for optimizations |
| 59 | // and does not require an explicit markup for types that may alias, we still don't |
| 60 | // enable the optimization for this compiler because at least MSVC-8 and 9 are known |
| 61 | // to generate broken code sometimes when casts are used. |
| 62 | #define BOOST_ATOMIC_DETAIL_MAY_ALIAS BOOST_MAY_ALIAS |
| 63 | #if !defined(BOOST_NO_MAY_ALIAS) |
| 64 | #define BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS |
| 65 | #endif |
| 66 | |
| 67 | #if defined(__GCC_ASM_FLAG_OUTPUTS__) |
| 68 | // The compiler supports output values in flag registers. |
| 69 | // See: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html, Section 6.44.3. |
| 70 | #define BOOST_ATOMIC_DETAIL_ASM_HAS_FLAG_OUTPUTS |
| 71 | #endif |
| 72 | |
| 73 | #if defined(__has_builtin) |
| 74 | #if __has_builtin(__builtin_constant_p) |
| 75 | #define BOOST_ATOMIC_DETAIL_IS_CONSTANT(x) __builtin_constant_p(x) |
| 76 | #endif |
| 77 | #elif defined(__GNUC__) |
| 78 | #define BOOST_ATOMIC_DETAIL_IS_CONSTANT(x) __builtin_constant_p(x) |
| 79 | #endif |
| 80 | |
| 81 | #if !defined(BOOST_ATOMIC_DETAIL_IS_CONSTANT) |
| 82 | #define BOOST_ATOMIC_DETAIL_IS_CONSTANT(x) false |
| 83 | #endif |
| 84 | |
| 85 | #if (defined(__BYTE_ORDER__) && defined(__FLOAT_WORD_ORDER__) && (__BYTE_ORDER__+0) == (__FLOAT_WORD_ORDER__+0)) ||\ |
| 86 | defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) |
| 87 | // This macro indicates that integer and floating point endianness is the same |
| 88 | #define BOOST_ATOMIC_DETAIL_INT_FP_ENDIAN_MATCH |
| 89 | #endif |
| 90 | |
| 91 | // Deprecated symbols markup |
| 92 | #if !defined(BOOST_ATOMIC_DETAIL_DEPRECATED) && defined(_MSC_VER) |
| 93 | #if (_MSC_VER) >= 1400 |
| 94 | #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) __declspec(deprecated(msg)) |
| 95 | #else |
| 96 | // MSVC 7.1 only supports the attribute without a message |
| 97 | #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) __declspec(deprecated) |
| 98 | #endif |
| 99 | #endif |
| 100 | |
| 101 | #if !defined(BOOST_ATOMIC_DETAIL_DEPRECATED) && defined(__has_extension) |
| 102 | #if __has_extension(attribute_deprecated_with_message) |
| 103 | #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) __attribute__((deprecated(msg))) |
| 104 | #endif |
| 105 | #endif |
| 106 | |
| 107 | // gcc since 4.5 supports deprecated attribute with a message; older versions support the attribute without a message. |
| 108 | // Oracle Studio 12.4 supports deprecated attribute with a message; this is the first release that supports the attribute. |
| 109 | #if !defined(BOOST_ATOMIC_DETAIL_DEPRECATED) && (\ |
| 110 | (defined(__GNUC__) && ((__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0)) >= 405) ||\ |
| 111 | (defined(__SUNPRO_CC) && (__SUNPRO_CC + 0) >= 0x5130)) |
| 112 | #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) __attribute__((deprecated(msg))) |
| 113 | #endif |
| 114 | |
| 115 | #if !defined(BOOST_ATOMIC_DETAIL_DEPRECATED) && __cplusplus >= 201402 |
| 116 | #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) [[deprecated(msg)]] |
| 117 | #endif |
| 118 | |
| 119 | #if !defined(BOOST_ATOMIC_DETAIL_DEPRECATED) && defined(__GNUC__) |
| 120 | #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) __attribute__((deprecated)) |
| 121 | #endif |
| 122 | |
| 123 | #if !defined(BOOST_ATOMIC_DETAIL_DEPRECATED) && defined(__has_attribute) |
| 124 | #if __has_attribute(deprecated) |
| 125 | #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) __attribute__((deprecated)) |
| 126 | #endif |
| 127 | #endif |
| 128 | |
| 129 | #if !defined(BOOST_ATOMIC_DETAIL_DEPRECATED) |
| 130 | #define BOOST_ATOMIC_DETAIL_DEPRECATED(msg) |
| 131 | #endif |
| 132 | |
| 133 | // In Boost.Atomic 1.67 we changed (op)_and_test methods to return true when the result is non-zero. This would be more consistent |
| 134 | // with the other names used in Boost.Atomic and the C++ standard library. Since the methods were announced as experimental and |
| 135 | // the previous behavior was released only in Boost 1.66, it was decided to change the result without changing the method names. |
| 136 | // By defining BOOST_ATOMIC_HIGHLIGHT_OP_AND_TEST the user has a way to highlight all uses of the affected functions so |
| 137 | // that it is easier to find and update the affected code (which is typically adding or removing negation of the result). This |
| 138 | // highlighting functionality is a temporary measure to help users upgrade from Boost 1.66 to newer Boost versions. It will |
| 139 | // be removed eventually. |
| 140 | // |
| 141 | // More info at: |
| 142 | // https://github.com/boostorg/atomic/issues/11 |
| 143 | // http://boost.2283326.n4.nabble.com/atomic-op-and-test-naming-tc4701445.html |
| 144 | #if defined(BOOST_ATOMIC_HIGHLIGHT_OP_AND_TEST) |
| 145 | #define BOOST_ATOMIC_DETAIL_HIGHLIGHT_OP_AND_TEST BOOST_ATOMIC_DETAIL_DEPRECATED("Boost.Atomic 1.67 has changed (op)_and_test result to the opposite. The functions now return true when the result is non-zero. Please, verify your use of the operation and undefine BOOST_ATOMIC_HIGHLIGHT_OP_AND_TEST.") |
| 146 | #else |
| 147 | #define BOOST_ATOMIC_DETAIL_HIGHLIGHT_OP_AND_TEST |
| 148 | #endif |
| 149 | |
| 150 | #endif // BOOST_ATOMIC_DETAIL_CONFIG_HPP_INCLUDED_ |