]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ) | |
65 | ||
66 | #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_arm | |
67 | ||
68 | #elif (defined(__GNUC__) || defined(__SUNPRO_CC)) && (defined(__sparcv8plus) || defined(__sparc_v9__)) | |
69 | ||
70 | #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_sparc | |
71 | ||
72 | #elif defined(__GNUC__) && defined(__alpha__) | |
73 | ||
74 | #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_alpha | |
75 | ||
76 | #elif defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 401) &&\ | |
77 | (\ | |
78 | defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1) ||\ | |
79 | defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) ||\ | |
80 | defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) ||\ | |
81 | defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) ||\ | |
82 | defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16)\ | |
83 | ) | |
84 | ||
85 | #define BOOST_ATOMIC_DETAIL_PLATFORM gcc_sync | |
86 | ||
87 | #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) | |
88 | ||
89 | #define BOOST_ATOMIC_DETAIL_PLATFORM msvc_x86 | |
90 | ||
91 | #elif defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_M_ARM) | |
92 | ||
93 | #define BOOST_ATOMIC_DETAIL_PLATFORM msvc_arm | |
94 | ||
95 | #endif | |
96 | ||
97 | // OS-based backends | |
98 | #if !defined(BOOST_ATOMIC_DETAIL_PLATFORM) | |
99 | ||
100 | #if defined(__linux__) && defined(__arm__) | |
101 | ||
102 | #define BOOST_ATOMIC_DETAIL_PLATFORM linux_arm | |
103 | ||
104 | #elif defined(BOOST_WINDOWS) || defined(_WIN32_CE) | |
105 | ||
106 | #define BOOST_ATOMIC_DETAIL_PLATFORM windows | |
107 | ||
108 | #endif | |
109 | ||
110 | #endif // !defined(BOOST_ATOMIC_DETAIL_PLATFORM) | |
111 | ||
112 | #endif // !defined(BOOST_ATOMIC_FORCE_FALLBACK) | |
113 | ||
114 | #if !defined(BOOST_ATOMIC_DETAIL_PLATFORM) | |
115 | #define BOOST_ATOMIC_DETAIL_PLATFORM emulated | |
116 | #define BOOST_ATOMIC_EMULATED | |
117 | #endif | |
118 | ||
119 | #define BOOST_ATOMIC_DETAIL_HEADER(prefix) <BOOST_JOIN(prefix, BOOST_ATOMIC_DETAIL_PLATFORM).hpp> | |
120 | ||
121 | #endif // BOOST_ATOMIC_DETAIL_PLATFORM_HPP_INCLUDED_ |