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(BOOST_ATOMIC_FORCE_FALLBACK) |
25 | |
26 | // Compiler-based backends |
27 | #if (defined(__ibmxl__) || defined(__IBMCPP__)) && defined(__PPC__) |
28 | |
29 | // IBM XL C++ Compiler has to be checked before GCC/Clang as it pretends to be one but does not support __atomic* intrinsics. |
30 | // It does support GCC inline assembler though. |
31 | #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_ppc |
32 | |
33 | #elif ((defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 407)) ||\ |
34 | (defined(BOOST_CLANG) && ((__clang_major__ * 100 + __clang_minor__) >= 302))) &&\ |
35 | (\ |
36 | (__GCC_ATOMIC_BOOL_LOCK_FREE + 0) == 2 ||\ |
37 | (__GCC_ATOMIC_CHAR_LOCK_FREE + 0) == 2 ||\ |
38 | (__GCC_ATOMIC_SHORT_LOCK_FREE + 0) == 2 ||\ |
39 | (__GCC_ATOMIC_INT_LOCK_FREE + 0) == 2 ||\ |
40 | (__GCC_ATOMIC_LONG_LOCK_FREE + 0) == 2 ||\ |
41 | (__GCC_ATOMIC_LLONG_LOCK_FREE + 0) == 2\ |
42 | ) |
43 | |
44 | #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_atomic |
45 | |
46 | #elif (defined(__GNUC__) || defined(__SUNPRO_CC)) && (defined(__i386__) || defined(__x86_64__)) |
47 | |
48 | #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_x86 |
49 | |
50 | #elif defined(__GNUC__) && (defined(__POWERPC__) || defined(__PPC__)) |
51 | |
52 | #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_ppc |
53 | |
54 | // This list of ARM architecture versions comes from Apple's arm/arch.h header. |
55 | // I don't know how complete it is. |
56 | #elif defined(__GNUC__) &&\ |
57 | (\ |
58 | defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) ||\ |
59 | defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) ||\ |
60 | defined(__ARM_ARCH_6ZK__) ||\ |
61 | defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) ||\ |
62 | defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) ||\ |
63 | defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7S__) ||\ |
64 | defined(__ARM_ARCH_8A__)\ |
65 | ) |
66 | |
67 | #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_arm |
68 | |
69 | #elif (defined(__GNUC__) || defined(__SUNPRO_CC)) && (defined(__sparcv8plus) || defined(__sparc_v9__)) |
70 | |
71 | #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_sparc |
72 | |
73 | #elif defined(__GNUC__) && defined(__alpha__) |
74 | |
75 | #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_alpha |
76 | |
77 | #elif defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 401) &&\ |
78 | (\ |
79 | defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1) ||\ |
80 | defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) ||\ |
81 | defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) ||\ |
82 | defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) ||\ |
83 | defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16)\ |
84 | ) |
85 | |
86 | #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_sync |
87 | |
88 | #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) |
89 | |
90 | #define BOOST_ATOMIC_DETAIL_PLATFORM msvc_x86 |
91 | |
92 | #elif defined(_MSC_VER) && _MSC_VER >= 1700 && (defined(_M_ARM) || defined(_M_ARM64)) |
93 | |
94 | #define BOOST_ATOMIC_DETAIL_PLATFORM msvc_arm |
95 | |
96 | #endif |
97 | |
98 | // OS-based backends |
99 | #if !defined(BOOST_ATOMIC_DETAIL_PLATFORM) |
100 | |
101 | #if defined(__linux__) && defined(__arm__) |
102 | |
103 | #define BOOST_ATOMIC_DETAIL_PLATFORM linux_arm |
104 | |
105 | #elif defined(BOOST_WINDOWS) || defined(_WIN32_CE) |
106 | |
107 | #define BOOST_ATOMIC_DETAIL_PLATFORM windows |
108 | |
109 | #endif |
110 | |
111 | #endif // !defined(BOOST_ATOMIC_DETAIL_PLATFORM) |
112 | |
113 | #endif // !defined(BOOST_ATOMIC_FORCE_FALLBACK) |
114 | |
115 | #if !defined(BOOST_ATOMIC_DETAIL_PLATFORM) |
116 | #define BOOST_ATOMIC_DETAIL_PLATFORM emulated |
117 | #define BOOST_ATOMIC_EMULATED |
118 | #endif |
119 | |
120 | #define (prefix) <BOOST_JOIN(prefix, BOOST_ATOMIC_DETAIL_PLATFORM).hpp> |
121 | |
122 | #endif // BOOST_ATOMIC_DETAIL_PLATFORM_HPP_INCLUDED_ |
123 | |