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(__has_builtin) |
25 | #if __has_builtin(__builtin_memcpy) |
26 | #define BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCPY |
27 | #endif |
28 | #if __has_builtin(__builtin_memcmp) |
29 | #define BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCMP |
30 | #endif |
31 | #elif defined(BOOST_GCC) |
32 | #define BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCPY |
33 | #define BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCMP |
34 | #endif |
35 | |
36 | #if defined(BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCPY) |
37 | #define BOOST_ATOMIC_DETAIL_MEMCPY __builtin_memcpy |
38 | #else |
39 | #define BOOST_ATOMIC_DETAIL_MEMCPY std::memcpy |
40 | #endif |
41 | |
42 | #if defined(BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCMP) |
43 | #define BOOST_ATOMIC_DETAIL_MEMCMP __builtin_memcmp |
44 | #else |
45 | #define BOOST_ATOMIC_DETAIL_MEMCMP std::memcmp |
46 | #endif |
47 | |
48 | #if defined(__CUDACC__) |
49 | // nvcc does not support alternatives in asm statement constraints |
50 | #define BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES |
51 | // nvcc does not support condition code register ("cc") clobber in asm statements |
52 | #define BOOST_ATOMIC_DETAIL_NO_ASM_CLOBBER_CC |
53 | #endif |
54 | |
55 | #if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CLOBBER_CC) |
56 | #define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC "cc" |
57 | #define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "cc", |
58 | #else |
59 | #define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC |
60 | #define BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA |
61 | #endif |
62 | |
63 | #if ((defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 403)) ||\ |
64 | defined(__SUNPRO_CC) |
65 | // This macro indicates we're using older binutils that don't support implied zero displacements for memory opereands, |
66 | // making code like this invalid: |
67 | // movl 4+(%%edx), %%eax |
68 | #define BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS |
69 | #endif |
70 | |
71 | #if defined(__clang__) || (defined(BOOST_GCC) && (BOOST_GCC+0) < 40500) || defined(__SUNPRO_CC) |
72 | // This macro indicates that the compiler does not support allocating rax:rdx register pairs ("A") in asm blocks |
73 | #define BOOST_ATOMIC_DETAIL_NO_ASM_RAX_RDX_PAIRS |
74 | #endif |
75 | |
76 | #if defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) |
77 | #if !(defined(BOOST_LIBSTDCXX11) && (BOOST_LIBSTDCXX_VERSION+0) >= 40700) /* libstdc++ from gcc >= 4.7 in C++11 mode */ |
78 | // This macro indicates that there is no <type_traits> standard header that is sufficient for Boost.Atomic needs. |
79 | #define BOOST_ATOMIC_DETAIL_NO_CXX11_HDR_TYPE_TRAITS |
80 | #endif |
81 | #endif // defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) |
82 | |
83 | // Enable pointer/reference casts between storage and value when possible. |
84 | // Note: Despite that MSVC does not employ strict aliasing rules for optimizations |
85 | // and does not require an explicit markup for types that may alias, we still don't |
86 | // enable the optimization for this compiler because at least MSVC-8 and 9 are known |
87 | // to generate broken code sometimes when casts are used. |
88 | #if defined(__GNUC__) && (!defined(BOOST_INTEL_CXX_VERSION) || (BOOST_INTEL_CXX_VERSION+0) >= 1300) |
89 | #define BOOST_ATOMIC_DETAIL_MAY_ALIAS __attribute__((__may_alias__)) |
90 | #define BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS |
91 | #elif defined(__has_attribute) |
92 | #if __has_attribute(__may_alias__) |
93 | #define BOOST_ATOMIC_DETAIL_MAY_ALIAS __attribute__((__may_alias__)) |
94 | #define BOOST_ATOMIC_DETAIL_STORAGE_TYPE_MAY_ALIAS |
95 | #endif |
96 | #endif |
97 | |
98 | #if !defined(BOOST_ATOMIC_DETAIL_MAY_ALIAS) |
99 | #define BOOST_ATOMIC_DETAIL_MAY_ALIAS |
100 | #endif |
101 | |
102 | #endif // BOOST_ATOMIC_DETAIL_CONFIG_HPP_INCLUDED_ |
103 | |