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) 2014 Andrey Semashev |
7 | */ |
8 | /*! |
9 | * \file atomic/detail/caps_gcc_atomic.hpp |
10 | * |
11 | * This header defines feature capabilities macros |
12 | */ |
13 | |
14 | #ifndef BOOST_ATOMIC_DETAIL_CAPS_GCC_ATOMIC_HPP_INCLUDED_ |
15 | #define BOOST_ATOMIC_DETAIL_CAPS_GCC_ATOMIC_HPP_INCLUDED_ |
16 | |
17 | #include <boost/atomic/detail/config.hpp> |
18 | #include <boost/atomic/detail/int_sizes.hpp> |
19 | |
20 | #ifdef BOOST_HAS_PRAGMA_ONCE |
21 | #pragma once |
22 | #endif |
23 | |
24 | #if defined(__i386__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) |
25 | #define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B 1 |
26 | #endif |
27 | |
28 | #if defined(__x86_64__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) |
29 | #define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B 1 |
30 | #endif |
31 | |
32 | #if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) && (defined(BOOST_HAS_INT128) || !defined(BOOST_NO_ALIGNMENT)) |
33 | #define BOOST_ATOMIC_INT128_LOCK_FREE 2 |
34 | #else |
35 | #define BOOST_ATOMIC_INT128_LOCK_FREE 0 |
36 | #endif |
37 | |
38 | #if __GCC_ATOMIC_LLONG_LOCK_FREE == 2 |
39 | #define BOOST_ATOMIC_LLONG_LOCK_FREE 2 |
40 | #else |
41 | #define BOOST_ATOMIC_LLONG_LOCK_FREE BOOST_ATOMIC_INT128_LOCK_FREE |
42 | #endif |
43 | |
44 | #if __GCC_ATOMIC_LONG_LOCK_FREE == 2 |
45 | #define BOOST_ATOMIC_LONG_LOCK_FREE 2 |
46 | #else |
47 | #define BOOST_ATOMIC_LONG_LOCK_FREE BOOST_ATOMIC_LLONG_LOCK_FREE |
48 | #endif |
49 | |
50 | #if __GCC_ATOMIC_INT_LOCK_FREE == 2 |
51 | #define BOOST_ATOMIC_INT_LOCK_FREE 2 |
52 | #else |
53 | #define BOOST_ATOMIC_INT_LOCK_FREE BOOST_ATOMIC_LONG_LOCK_FREE |
54 | #endif |
55 | |
56 | #if __GCC_ATOMIC_SHORT_LOCK_FREE == 2 |
57 | #define BOOST_ATOMIC_SHORT_LOCK_FREE 2 |
58 | #else |
59 | #define BOOST_ATOMIC_SHORT_LOCK_FREE BOOST_ATOMIC_INT_LOCK_FREE |
60 | #endif |
61 | |
62 | #if __GCC_ATOMIC_CHAR_LOCK_FREE == 2 |
63 | #define BOOST_ATOMIC_CHAR_LOCK_FREE 2 |
64 | #else |
65 | #define BOOST_ATOMIC_CHAR_LOCK_FREE BOOST_ATOMIC_SHORT_LOCK_FREE |
66 | #endif |
67 | |
68 | #if __GCC_ATOMIC_POINTER_LOCK_FREE == 2 |
69 | #define BOOST_ATOMIC_POINTER_LOCK_FREE 2 |
70 | #else |
71 | #define BOOST_ATOMIC_POINTER_LOCK_FREE 0 |
72 | #endif |
73 | |
74 | |
75 | #define BOOST_ATOMIC_INT8_LOCK_FREE BOOST_ATOMIC_CHAR_LOCK_FREE |
76 | |
77 | #if BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 2 |
78 | #define BOOST_ATOMIC_INT16_LOCK_FREE BOOST_ATOMIC_SHORT_LOCK_FREE |
79 | #elif BOOST_ATOMIC_DETAIL_SIZEOF_INT == 2 |
80 | #define BOOST_ATOMIC_INT16_LOCK_FREE BOOST_ATOMIC_INT_LOCK_FREE |
81 | #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 2 |
82 | #define BOOST_ATOMIC_INT16_LOCK_FREE BOOST_ATOMIC_LONG_LOCK_FREE |
83 | #elif BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 2 |
84 | #define BOOST_ATOMIC_INT16_LOCK_FREE BOOST_ATOMIC_LLONG_LOCK_FREE |
85 | #else |
86 | #define BOOST_ATOMIC_INT16_LOCK_FREE 0 |
87 | #endif |
88 | |
89 | #if BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 4 |
90 | #define BOOST_ATOMIC_INT32_LOCK_FREE BOOST_ATOMIC_SHORT_LOCK_FREE |
91 | #elif BOOST_ATOMIC_DETAIL_SIZEOF_INT == 4 |
92 | #define BOOST_ATOMIC_INT32_LOCK_FREE BOOST_ATOMIC_INT_LOCK_FREE |
93 | #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 4 |
94 | #define BOOST_ATOMIC_INT32_LOCK_FREE BOOST_ATOMIC_LONG_LOCK_FREE |
95 | #elif BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 4 |
96 | #define BOOST_ATOMIC_INT32_LOCK_FREE BOOST_ATOMIC_LLONG_LOCK_FREE |
97 | #else |
98 | #define BOOST_ATOMIC_INT32_LOCK_FREE 0 |
99 | #endif |
100 | |
101 | #if BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 8 |
102 | #define BOOST_ATOMIC_INT64_LOCK_FREE BOOST_ATOMIC_SHORT_LOCK_FREE |
103 | #elif BOOST_ATOMIC_DETAIL_SIZEOF_INT == 8 |
104 | #define BOOST_ATOMIC_INT64_LOCK_FREE BOOST_ATOMIC_INT_LOCK_FREE |
105 | #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 8 |
106 | #define BOOST_ATOMIC_INT64_LOCK_FREE BOOST_ATOMIC_LONG_LOCK_FREE |
107 | #elif BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 8 |
108 | #define BOOST_ATOMIC_INT64_LOCK_FREE BOOST_ATOMIC_LLONG_LOCK_FREE |
109 | #else |
110 | #define BOOST_ATOMIC_INT64_LOCK_FREE 0 |
111 | #endif |
112 | |
113 | |
114 | #if __GCC_ATOMIC_WCHAR_T_LOCK_FREE == 2 |
115 | #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 2 |
116 | #elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 8 |
117 | #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE |
118 | #elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 4 |
119 | #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE |
120 | #elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 2 |
121 | #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE |
122 | #elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 1 |
123 | #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE |
124 | #else |
125 | #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 0 |
126 | #endif |
127 | |
128 | #define BOOST_ATOMIC_CHAR32_T_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE |
129 | #define BOOST_ATOMIC_CHAR16_T_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE |
130 | |
131 | #define BOOST_ATOMIC_THREAD_FENCE 2 |
132 | #define BOOST_ATOMIC_SIGNAL_FENCE 2 |
133 | |
134 | #endif // BOOST_ATOMIC_DETAIL_CAPS_GCC_ATOMIC_HPP_INCLUDED_ |
135 | |