aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-support/boost/boost/0001-Added-support-for-extending-operations-to-GCC-atomic.patch
blob: feece81532ec51d612dbe21d7da0135a3eaa5598 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
From 415db7054723291042e4ff1ffa8fdd5bc8b07163 Mon Sep 17 00:00:00 2001
From: Andrey Semashev <andrey.semashev@gmail.com>
Date: Sat, 27 Sep 2014 20:40:09 +0400
Subject: [PATCH] Added support for extending operations to GCC atomic backend.

Fix for #10446. Some platforms (e.g. Raspberry Pi) only support atomic ops of some particular size but not less. Use extending arithmetic operations for these platforms. Also, make sure bools are always treated as 8-bit values, even if the actual type is larger. This makes its use in atomic<>, atomic_flag and lock pool more consistent.

Upstream-Status: Backport [https://svn.boost.org/trac/boost/ticket/10446]
Signed-off-by: Peter A. Bigot <pab@pabigot.com>

---
 include/boost/atomic/capabilities.hpp           |   1 +
 include/boost/atomic/detail/atomic_template.hpp |   2 +-
 include/boost/atomic/detail/caps_gcc_atomic.hpp |  82 +++++------
 include/boost/atomic/detail/ops_gcc_atomic.hpp  | 184 +++++++++++++++++++++---
 4 files changed, 206 insertions(+), 63 deletions(-)

diff --git a/include/boost/atomic/capabilities.hpp b/include/boost/atomic/capabilities.hpp
index 658dd22..05bbb0f 100644
--- a/include/boost/atomic/capabilities.hpp
+++ b/include/boost/atomic/capabilities.hpp
@@ -142,6 +142,7 @@
 #define BOOST_ATOMIC_ADDRESS_LOCK_FREE BOOST_ATOMIC_POINTER_LOCK_FREE
 
 #ifndef BOOST_ATOMIC_BOOL_LOCK_FREE
+// We store bools in 1-byte storage in all backends
 #define BOOST_ATOMIC_BOOL_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
 #endif
 
diff --git a/include/boost/atomic/detail/atomic_template.hpp b/include/boost/atomic/detail/atomic_template.hpp
index 4fd6d79..bc3922a 100644
--- a/include/boost/atomic/detail/atomic_template.hpp
+++ b/include/boost/atomic/detail/atomic_template.hpp
@@ -234,7 +234,7 @@ class base_atomic< bool, int >
 {
 private:
     typedef bool value_type;
-    typedef atomics::detail::operations< storage_size_of< value_type >::value, false > operations;
+    typedef atomics::detail::operations< 1u, false > operations;
 
 protected:
     typedef value_type value_arg_type;
diff --git a/include/boost/atomic/detail/caps_gcc_atomic.hpp b/include/boost/atomic/detail/caps_gcc_atomic.hpp
index 8299ad0..f4e7a70 100644
--- a/include/boost/atomic/detail/caps_gcc_atomic.hpp
+++ b/include/boost/atomic/detail/caps_gcc_atomic.hpp
@@ -29,66 +29,48 @@
 #define BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B 1
 #endif
 
-#if __GCC_ATOMIC_BOOL_LOCK_FREE == 2
-#define BOOST_ATOMIC_FLAG_LOCK_FREE 2
-#else
-#define BOOST_ATOMIC_FLAG_LOCK_FREE 0
-#endif
-#if __GCC_ATOMIC_CHAR_LOCK_FREE == 2
-#define BOOST_ATOMIC_CHAR_LOCK_FREE 2
-#else
-#define BOOST_ATOMIC_CHAR_LOCK_FREE 0
-#endif
-#if __GCC_ATOMIC_CHAR16_T_LOCK_FREE == 2
-#define BOOST_ATOMIC_CHAR16_T_LOCK_FREE 2
-#else
-#define BOOST_ATOMIC_CHAR16_T_LOCK_FREE 0
-#endif
-#if __GCC_ATOMIC_CHAR32_T_LOCK_FREE == 2
-#define BOOST_ATOMIC_CHAR32_T_LOCK_FREE 2
+#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) && (defined(BOOST_HAS_INT128) || !defined(BOOST_NO_ALIGNMENT))
+#define BOOST_ATOMIC_INT128_LOCK_FREE 2
 #else
-#define BOOST_ATOMIC_CHAR32_T_LOCK_FREE 0
+#define BOOST_ATOMIC_INT128_LOCK_FREE 0
 #endif
-#if __GCC_ATOMIC_WCHAR_T_LOCK_FREE == 2
-#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 2
+
+#if __GCC_ATOMIC_LLONG_LOCK_FREE == 2
+#define BOOST_ATOMIC_LLONG_LOCK_FREE 2
 #else
-#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 0
+#define BOOST_ATOMIC_LLONG_LOCK_FREE BOOST_ATOMIC_INT128_LOCK_FREE
 #endif
-#if __GCC_ATOMIC_SHORT_LOCK_FREE == 2
-#define BOOST_ATOMIC_SHORT_LOCK_FREE 2
+
+#if __GCC_ATOMIC_LONG_LOCK_FREE == 2
+#define BOOST_ATOMIC_LONG_LOCK_FREE 2
 #else
-#define BOOST_ATOMIC_SHORT_LOCK_FREE 0
+#define BOOST_ATOMIC_LONG_LOCK_FREE BOOST_ATOMIC_LLONG_LOCK_FREE
 #endif
+
 #if __GCC_ATOMIC_INT_LOCK_FREE == 2
 #define BOOST_ATOMIC_INT_LOCK_FREE 2
 #else
-#define BOOST_ATOMIC_INT_LOCK_FREE 0
-#endif
-#if __GCC_ATOMIC_LONG_LOCK_FREE == 2
-#define BOOST_ATOMIC_LONG_LOCK_FREE 2
-#else
-#define BOOST_ATOMIC_LONG_LOCK_FREE 0
+#define BOOST_ATOMIC_INT_LOCK_FREE BOOST_ATOMIC_LONG_LOCK_FREE
 #endif
-#if __GCC_ATOMIC_LLONG_LOCK_FREE == 2
-#define BOOST_ATOMIC_LLONG_LOCK_FREE 2
+
+#if __GCC_ATOMIC_SHORT_LOCK_FREE == 2
+#define BOOST_ATOMIC_SHORT_LOCK_FREE 2
 #else
-#define BOOST_ATOMIC_LLONG_LOCK_FREE 0
+#define BOOST_ATOMIC_SHORT_LOCK_FREE BOOST_ATOMIC_INT_LOCK_FREE
 #endif
-#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B) && (defined(BOOST_HAS_INT128) || !defined(BOOST_NO_ALIGNMENT))
-#define BOOST_ATOMIC_INT128_LOCK_FREE 2
+
+#if __GCC_ATOMIC_CHAR_LOCK_FREE == 2
+#define BOOST_ATOMIC_CHAR_LOCK_FREE 2
 #else
-#define BOOST_ATOMIC_INT128_LOCK_FREE 0
+#define BOOST_ATOMIC_CHAR_LOCK_FREE BOOST_ATOMIC_SHORT_LOCK_FREE
 #endif
+
 #if __GCC_ATOMIC_POINTER_LOCK_FREE == 2
 #define BOOST_ATOMIC_POINTER_LOCK_FREE 2
 #else
 #define BOOST_ATOMIC_POINTER_LOCK_FREE 0
 #endif
-#if __GCC_ATOMIC_BOOL_LOCK_FREE == 2
-#define BOOST_ATOMIC_BOOL_LOCK_FREE 2
-#else
-#define BOOST_ATOMIC_BOOL_LOCK_FREE 0
-#endif
+
 
 #define BOOST_ATOMIC_INT8_LOCK_FREE BOOST_ATOMIC_CHAR_LOCK_FREE
 
@@ -128,6 +110,24 @@
 #define BOOST_ATOMIC_INT64_LOCK_FREE 0
 #endif
 
+
+#if __GCC_ATOMIC_WCHAR_T_LOCK_FREE == 2
+#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 2
+#elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 8
+#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
+#elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 4
+#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
+#elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 2
+#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
+#elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 1
+#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
+#else
+#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 0
+#endif
+
+#define BOOST_ATOMIC_CHAR32_T_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
+#define BOOST_ATOMIC_CHAR16_T_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
+
 #define BOOST_ATOMIC_THREAD_FENCE 2
 #define BOOST_ATOMIC_SIGNAL_FENCE 2
 
diff --git a/include/boost/atomic/detail/ops_gcc_atomic.hpp b/include/boost/atomic/detail/ops_gcc_atomic.hpp
index 2297791..2e4c37b 100644
--- a/include/boost/atomic/detail/ops_gcc_atomic.hpp
+++ b/include/boost/atomic/detail/ops_gcc_atomic.hpp
@@ -24,6 +24,15 @@
 #include <boost/atomic/detail/ops_cas_based.hpp>
 #endif
 
+#if __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE || __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE ||\
+    __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE || __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE ||\
+    __GCC_ATOMIC_CHAR_LOCK_FREE != BOOST_ATOMIC_CHAR_LOCK_FREE || __GCC_ATOMIC_BOOL_LOCK_FREE != BOOST_ATOMIC_BOOL_LOCK_FREE ||\
+    __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE
+// There are platforms where we need to use larger storage types
+#include <boost/atomic/detail/int_sizes.hpp>
+#include <boost/atomic/detail/ops_extending_cas_based.hpp>
+#endif
+
 #ifdef BOOST_HAS_PRAGMA_ONCE
 #pragma once
 #endif
@@ -154,73 +163,206 @@ struct gcc_atomic_operations
     }
 };
 
-#if BOOST_ATOMIC_INT8_LOCK_FREE > 0
+#if BOOST_ATOMIC_INT128_LOCK_FREE > 0
+#if defined(__clang__) && defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B)
+
+// Workaround for clang bug: http://llvm.org/bugs/show_bug.cgi?id=19149
+// Clang 3.4 does not implement 128-bit __atomic* intrinsics even though it defines __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
 template< bool Signed >
-struct operations< 1u, Signed > :
-    public gcc_atomic_operations< typename make_storage_type< 1u, Signed >::type >
+struct operations< 16u, Signed > :
+    public cas_based_operations< gcc_dcas_x86_64< Signed > >
 {
 };
+
+#else
+
+template< bool Signed >
+struct operations< 16u, Signed > :
+    public gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >
+{
+};
+
+#endif
 #endif
 
-#if BOOST_ATOMIC_INT16_LOCK_FREE > 0
+
+#if BOOST_ATOMIC_INT64_LOCK_FREE > 0
+#if defined(__clang__) && defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B)
+
+// Workaround for clang bug http://llvm.org/bugs/show_bug.cgi?id=19355
 template< bool Signed >
-struct operations< 2u, Signed > :
-    public gcc_atomic_operations< typename make_storage_type< 2u, Signed >::type >
+struct operations< 8u, Signed > :
+    public cas_based_operations< gcc_dcas_x86< Signed > >
+{
+};
+
+#elif (BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 8 && __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 8 && __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_INT == 8 && __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 8 && __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 8 && __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE)
+
+#define BOOST_ATOMIC_DETAIL_INT64_EXTENDED
+
+template< bool Signed >
+struct operations< 8u, Signed > :
+    public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 8u, Signed >
 {
 };
+
+#else
+
+template< bool Signed >
+struct operations< 8u, Signed > :
+    public gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >
+{
+};
+
+#endif
 #endif
 
 #if BOOST_ATOMIC_INT32_LOCK_FREE > 0
+#if (BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 4 && __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 4 && __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_INT == 4 && __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 4 && __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 4 && __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE)
+
+#define BOOST_ATOMIC_DETAIL_INT32_EXTENDED
+
+#if !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED)
+
+template< bool Signed >
+struct operations< 4u, Signed > :
+    public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >, 4u, Signed >
+{
+};
+
+#else // !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED)
+
+template< bool Signed >
+struct operations< 4u, Signed > :
+    public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 4u, Signed >
+{
+};
+
+#endif // !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED)
+
+#else
+
 template< bool Signed >
 struct operations< 4u, Signed > :
     public gcc_atomic_operations< typename make_storage_type< 4u, Signed >::type >
 {
 };
+
+#endif
 #endif
 
-#if BOOST_ATOMIC_INT64_LOCK_FREE > 0
-#if defined(__clang__) && defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B)
+#if BOOST_ATOMIC_INT16_LOCK_FREE > 0
+#if (BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 2 && __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 2 && __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_INT == 2 && __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 2 && __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 2 && __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE)
+
+#define BOOST_ATOMIC_DETAIL_INT16_EXTENDED
+
+#if !defined(BOOST_ATOMIC_DETAIL_INT32_EXTENDED)
 
-// Workaround for clang bug http://llvm.org/bugs/show_bug.cgi?id=19355
 template< bool Signed >
-struct operations< 8u, Signed > :
-    public cas_based_operations< gcc_dcas_x86< Signed > >
+struct operations< 2u, Signed > :
+    public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 4u, Signed >::type >, 2u, Signed >
+{
+};
+
+#elif !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED)
+
+template< bool Signed >
+struct operations< 2u, Signed > :
+    public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >, 2u, Signed >
 {
 };
 
 #else
 
 template< bool Signed >
-struct operations< 8u, Signed > :
-    public gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >
+struct operations< 2u, Signed > :
+    public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 2u, Signed >
+{
+};
+
+#endif
+
+#else
+
+template< bool Signed >
+struct operations< 2u, Signed > :
+    public gcc_atomic_operations< typename make_storage_type< 2u, Signed >::type >
 {
 };
 
 #endif
 #endif
 
-#if BOOST_ATOMIC_INT128_LOCK_FREE > 0
-#if defined(__clang__) && defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B)
+#if BOOST_ATOMIC_INT8_LOCK_FREE > 0
+#if (BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 1 && __GCC_ATOMIC_LLONG_LOCK_FREE != BOOST_ATOMIC_LLONG_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 1 && __GCC_ATOMIC_LONG_LOCK_FREE != BOOST_ATOMIC_LONG_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_INT == 1 && __GCC_ATOMIC_INT_LOCK_FREE != BOOST_ATOMIC_INT_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 1 && __GCC_ATOMIC_SHORT_LOCK_FREE != BOOST_ATOMIC_SHORT_LOCK_FREE) ||\
+    (BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 1 && __GCC_ATOMIC_WCHAR_T_LOCK_FREE != BOOST_ATOMIC_WCHAR_T_LOCK_FREE) ||\
+    (__GCC_ATOMIC_CHAR_LOCK_FREE != BOOST_ATOMIC_CHAR_LOCK_FREE) ||\
+    (__GCC_ATOMIC_BOOL_LOCK_FREE != BOOST_ATOMIC_BOOL_LOCK_FREE)
+
+#if !defined(BOOST_ATOMIC_DETAIL_INT16_EXTENDED)
 
-// Workaround for clang bug: http://llvm.org/bugs/show_bug.cgi?id=19149
-// Clang 3.4 does not implement 128-bit __atomic* intrinsics even though it defines __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
 template< bool Signed >
-struct operations< 16u, Signed > :
-    public cas_based_operations< gcc_dcas_x86_64< Signed > >
+struct operations< 1u, Signed > :
+    public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 2u, Signed >::type >, 1u, Signed >
+{
+};
+
+#elif !defined(BOOST_ATOMIC_DETAIL_INT32_EXTENDED)
+
+template< bool Signed >
+struct operations< 1u, Signed > :
+    public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 4u, Signed >::type >, 1u, Signed >
+{
+};
+
+#elif !defined(BOOST_ATOMIC_DETAIL_INT64_EXTENDED)
+
+template< bool Signed >
+struct operations< 1u, Signed > :
+    public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type >, 1u, Signed >
 {
 };
 
 #else
 
 template< bool Signed >
-struct operations< 16u, Signed > :
-    public gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >
+struct operations< 1u, Signed > :
+    public extending_cas_based_operations< gcc_atomic_operations< typename make_storage_type< 16u, Signed >::type >, 1u, Signed >
+{
+};
+
+#endif
+
+#else
+
+template< bool Signed >
+struct operations< 1u, Signed > :
+    public gcc_atomic_operations< typename make_storage_type< 1u, Signed >::type >
 {
 };
 
 #endif
 #endif
 
+#undef BOOST_ATOMIC_DETAIL_INT16_EXTENDED
+#undef BOOST_ATOMIC_DETAIL_INT32_EXTENDED
+#undef BOOST_ATOMIC_DETAIL_INT64_EXTENDED
+
 BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT
 {
     __atomic_thread_fence(atomics::detail::convert_memory_order_to_gcc(order));
-- 
1.8.5.5