• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  Copyright (C) 2011-2013, 2016 Tim Blechmann
2 //
3 //  Distributed under the Boost Software License, Version 1.0. (See
4 //  accompanying file LICENSE_1_0.txt or copy at
5 //  http://www.boost.org/LICENSE_1_0.txt)
6 
7 #ifndef BOOST_LOCKFREE_DETAIL_ATOMIC_HPP
8 #define BOOST_LOCKFREE_DETAIL_ATOMIC_HPP
9 
10 #include <boost/config.hpp>
11 
12 #ifndef BOOST_LOCKFREE_FORCE_STD_ATOMIC
13 
14 #define BOOST_LOCKFREE_NO_HDR_ATOMIC
15 
16 // MSVC supports atomic<> from version 2012 onwards.
17 #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1700)
18 #undef BOOST_LOCKFREE_NO_HDR_ATOMIC
19 #endif
20 
21 
22 // GCC supports atomic<> from version 4.8 onwards.
23 #if (BOOST_GCC >= 40800) && (__cplusplus >= 201103L)
24 #undef BOOST_LOCKFREE_NO_HDR_ATOMIC
25 #endif
26 
27 
28 // Apple clang is 2 mayor versions ahead, but in fact 1 minor version behind
29 #ifdef BOOST_CLANG
30 
31 #define BOOST_ATOMIC_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
32 
33 #if  defined(__apple_build_version__) && (BOOST_ATOMIC_CLANG_VERSION >= 60100) && (__cplusplus >= 201103L)
34 #undef BOOST_LOCKFREE_NO_HDR_ATOMIC
35 #endif
36 
37 #if !defined(__apple_build_version__) && (BOOST_ATOMIC_CLANG_VERSION >= 30600) && (__cplusplus >= 201103L)
38 #undef BOOST_LOCKFREE_NO_HDR_ATOMIC
39 #endif
40 
41 #undef BOOST_ATOMIC_CLANG_VERSION
42 
43 #endif // BOOST_CLANG
44 
45 // Stdlib should also be checked
46 #include <boost/config.hpp>
47 #if defined(BOOST_NO_CXX11_HDR_ATOMIC) && !defined(BOOST_LOCKFREE_NO_HDR_ATOMIC)
48 #  define BOOST_LOCKFREE_NO_HDR_ATOMIC
49 #endif
50 
51 #endif // BOOST_LOCKFREE_FORCE_STD_ATOMIC
52 
53 
54 #if defined(BOOST_LOCKFREE_NO_HDR_ATOMIC) || defined(BOOST_LOCKFREE_FORCE_BOOST_ATOMIC)
55 #include <boost/atomic.hpp>
56 #else
57 #include <atomic>
58 #endif
59 
60 namespace boost {
61 namespace lockfree {
62 namespace detail {
63 
64 #if defined(BOOST_LOCKFREE_NO_HDR_ATOMIC) || defined(BOOST_LOCKFREE_FORCE_BOOST_ATOMIC)
65 using boost::atomic;
66 using boost::memory_order_acquire;
67 using boost::memory_order_consume;
68 using boost::memory_order_relaxed;
69 using boost::memory_order_release;
70 #else
71 using std::atomic;
72 using std::memory_order_acquire;
73 using std::memory_order_consume;
74 using std::memory_order_relaxed;
75 using std::memory_order_release;
76 #endif
77 
78 }
79 using detail::atomic;
80 using detail::memory_order_acquire;
81 using detail::memory_order_consume;
82 using detail::memory_order_relaxed;
83 using detail::memory_order_release;
84 
85 }}
86 
87 #endif /* BOOST_LOCKFREE_DETAIL_ATOMIC_HPP */
88