1 // (C) Copyright John Maddock 2013
3 // Use, modification and distribution are subject to the
4 // Boost Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/config for more information.
9 // MACRO: BOOST_NO_CXX11_HDR_ATOMIC
10 // TITLE: C++11 <atomic> header is either not present or too broken to be used
11 // DESCRIPTION: The compiler does not support the C++11 header <atomic>
15 #if !defined(ATOMIC_BOOL_LOCK_FREE) || !defined(ATOMIC_CHAR_LOCK_FREE) || !defined(ATOMIC_CHAR16_T_LOCK_FREE) \
16 || !defined(ATOMIC_CHAR32_T_LOCK_FREE) || !defined(ATOMIC_WCHAR_T_LOCK_FREE) || !defined(ATOMIC_SHORT_LOCK_FREE)\
17 || !defined(ATOMIC_INT_LOCK_FREE) || !defined(ATOMIC_LONG_LOCK_FREE) || !defined(ATOMIC_LLONG_LOCK_FREE)\
18 || !defined(ATOMIC_POINTER_LOCK_FREE)
19 # error "required macros not defined"
22 namespace boost_no_cxx11_hdr_atomic {
24 void consume(std::memory_order)
29 consume(std::memory_order_relaxed);
30 consume(std::memory_order_consume);
31 consume(std::memory_order_acquire);
32 consume(std::memory_order_release);
33 consume(std::memory_order_acq_rel);
34 consume(std::memory_order_seq_cst);
37 std::atomic<unsigned> a2;
44 a1.compare_exchange_weak(v, 2, std::memory_order_relaxed, std::memory_order_relaxed);
45 a1.compare_exchange_strong(v, 2, std::memory_order_relaxed, std::memory_order_relaxed);
73 std::atomic_is_lock_free(&a1);
74 // This produces linker errors on Mingw32 for some reason, probably not required anyway for most uses??
75 //std::atomic_init(&a1, 2);
76 std::atomic_store(&a1, 3);
77 std::atomic_store_explicit(&a1, 3, std::memory_order_relaxed);
78 std::atomic_load(&a1);
79 std::atomic_load_explicit(&a1, std::memory_order_relaxed);
80 std::atomic_exchange(&a1, 3);
81 std::atomic_compare_exchange_weak(&a1, &v, 2);
82 std::atomic_compare_exchange_strong(&a1, &v, 2);
83 std::atomic_compare_exchange_weak_explicit(&a1, &v, 2, std::memory_order_relaxed, std::memory_order_relaxed);
84 std::atomic_compare_exchange_strong_explicit(&a1, &v, 2, std::memory_order_relaxed, std::memory_order_relaxed);
86 std::atomic_flag f = ATOMIC_FLAG_INIT;
87 f.test_and_set(std::memory_order_relaxed);
89 f.clear(std::memory_order_relaxed);
92 std::atomic_thread_fence(std::memory_order_relaxed);
93 std::atomic_signal_fence(std::memory_order_relaxed);