]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/atomic/detail/platform.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / atomic / detail / platform.hpp
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) 2009 Helge Bahmann
7 * Copyright (c) 2014 Andrey Semashev
8 */
9 /*!
10 * \file atomic/detail/platform.hpp
11 *
12 * This header defines macros for the target platform detection
13 */
14
15 #ifndef BOOST_ATOMIC_DETAIL_PLATFORM_HPP_INCLUDED_
16 #define BOOST_ATOMIC_DETAIL_PLATFORM_HPP_INCLUDED_
17
18 #include <boost/atomic/detail/config.hpp>
19
20 #ifdef BOOST_HAS_PRAGMA_ONCE
21 #pragma once
22 #endif
23
24 #if defined(__GNUC__) && defined(__arm__)
25
26 // Newer gcc versions define __ARM_ARCH. Older ones don't, so we have to deduce ARM arch version from a bunch of version-specific macros.
27 #if defined(__ARM_ARCH)
28 #define BOOST_ATOMIC_DETAIL_ARM_ARCH __ARM_ARCH
29 #elif defined(__ARM_ARCH_8A__)
30 #define BOOST_ATOMIC_DETAIL_ARM_ARCH 8
31 #elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) ||\
32 defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) ||\
33 defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7S__)
34 #define BOOST_ATOMIC_DETAIL_ARM_ARCH 7
35 #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) ||\
36 defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) ||\
37 defined(__ARM_ARCH_6ZK__)
38 #define BOOST_ATOMIC_DETAIL_ARM_ARCH 6
39 #else
40 // We are not interested in older versions - they don't support atomic ops
41 #define BOOST_ATOMIC_DETAIL_ARM_ARCH 0
42 #endif
43
44 #endif // defined(__GNUC__) && defined(__arm__)
45
46 #if !defined(BOOST_ATOMIC_FORCE_FALLBACK)
47
48 // Determine the target platform.
49 // The target platform describes the compiler and target architecture. It can be used by more generic backends, such as the ones
50 // based on compiler intrinsics, to implement specialized operations in a non-generic way.
51
52 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
53
54 #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_x86
55 #define BOOST_ATOMIC_DETAIL_EXTRA_BACKEND gcc_x86
56
57 #elif defined(__GNUC__) && (defined(__POWERPC__) || defined(__PPC__))
58
59 #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_ppc
60 #define BOOST_ATOMIC_DETAIL_EXTRA_BACKEND gcc_ppc
61
62 #elif defined(__GNUC__) && defined(__arm__) && (BOOST_ATOMIC_DETAIL_ARM_ARCH+0) >= 6
63
64 #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_arm
65 #define BOOST_ATOMIC_DETAIL_EXTRA_BACKEND gcc_arm
66
67 #elif (defined(__GNUC__) || defined(__SUNPRO_CC)) && (defined(__sparcv8plus) || defined(__sparc_v9__))
68
69 #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_sparc
70
71 #elif defined(__GNUC__) && defined(__alpha__)
72
73 #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_alpha
74
75 #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
76
77 #define BOOST_ATOMIC_DETAIL_PLATFORM msvc_x86
78
79 #elif defined(_MSC_VER) && _MSC_VER >= 1700 && (defined(_M_ARM) || defined(_M_ARM64))
80
81 #define BOOST_ATOMIC_DETAIL_PLATFORM msvc_arm
82
83 #endif
84
85 // Compiler-based backends
86
87 // IBM XL C++ Compiler has to be checked before GCC/Clang as it pretends to be one but does not support __atomic* intrinsics.
88 // It does support GCC inline assembler though.
89 #if !(defined(__ibmxl__) || defined(__IBMCPP__)) &&\
90 ((defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 407)) ||\
91 (defined(BOOST_CLANG) && ((__clang_major__ * 100 + __clang_minor__) >= 302))) &&\
92 (\
93 (__GCC_ATOMIC_BOOL_LOCK_FREE + 0) == 2 ||\
94 (__GCC_ATOMIC_CHAR_LOCK_FREE + 0) == 2 ||\
95 (__GCC_ATOMIC_SHORT_LOCK_FREE + 0) == 2 ||\
96 (__GCC_ATOMIC_INT_LOCK_FREE + 0) == 2 ||\
97 (__GCC_ATOMIC_LONG_LOCK_FREE + 0) == 2 ||\
98 (__GCC_ATOMIC_LLONG_LOCK_FREE + 0) == 2\
99 )
100
101 #define BOOST_ATOMIC_DETAIL_BACKEND gcc_atomic
102
103 #elif defined(BOOST_ATOMIC_DETAIL_PLATFORM)
104
105 #define BOOST_ATOMIC_DETAIL_BACKEND BOOST_ATOMIC_DETAIL_PLATFORM
106
107 #elif defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 401) &&\
108 (\
109 defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1) ||\
110 defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) ||\
111 defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) ||\
112 defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) ||\
113 defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16)\
114 )
115
116 #define BOOST_ATOMIC_DETAIL_BACKEND gcc_sync
117
118 #endif
119
120 // OS-based backends
121
122 #if !defined(BOOST_ATOMIC_DETAIL_BACKEND)
123
124 #if defined(__linux__) && defined(__arm__)
125
126 #define BOOST_ATOMIC_DETAIL_BACKEND linux_arm
127
128 #elif defined(BOOST_WINDOWS) || defined(_WIN32_CE)
129
130 #define BOOST_ATOMIC_DETAIL_BACKEND windows
131
132 #endif
133
134 #endif // !defined(BOOST_ATOMIC_DETAIL_BACKEND)
135
136 #endif // !defined(BOOST_ATOMIC_FORCE_FALLBACK)
137
138 #if !defined(BOOST_ATOMIC_DETAIL_BACKEND)
139 #define BOOST_ATOMIC_DETAIL_BACKEND emulated
140 #define BOOST_ATOMIC_EMULATED
141 #endif
142
143 #if !defined(BOOST_ATOMIC_DETAIL_EXTRA_BACKEND)
144 #define BOOST_ATOMIC_DETAIL_EXTRA_BACKEND generic
145 #define BOOST_ATOMIC_DETAIL_EXTRA_BACKEND_GENERIC
146 #endif
147
148 #define BOOST_ATOMIC_DETAIL_BACKEND_HEADER(prefix) <BOOST_JOIN(prefix, BOOST_ATOMIC_DETAIL_BACKEND).hpp>
149 #define BOOST_ATOMIC_DETAIL_EXTRA_BACKEND_HEADER(prefix) <BOOST_JOIN(prefix, BOOST_ATOMIC_DETAIL_EXTRA_BACKEND).hpp>
150
151 #endif // BOOST_ATOMIC_DETAIL_PLATFORM_HPP_INCLUDED_