1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright 2017 John Maddock
3 // Distributed under the Boost
4 // 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 #ifndef BOOST_MATH_ATOMIC_DETAIL_HPP
8 #define BOOST_MATH_ATOMIC_DETAIL_HPP
10 #include <boost/config.hpp>
12 #ifdef BOOST_HAS_THREADS
14 #ifndef BOOST_NO_CXX11_HDR_ATOMIC
16 # define BOOST_MATH_ATOMIC_NS std
20 #if ATOMIC_INT_LOCK_FREE == 2
21 typedef std::atomic<int> atomic_counter_type;
22 typedef std::atomic<unsigned> atomic_unsigned_type;
23 typedef int atomic_integer_type;
24 typedef unsigned atomic_unsigned_integer_type;
25 #elif ATOMIC_SHORT_LOCK_FREE == 2
26 typedef std::atomic<short> atomic_counter_type;
27 typedef std::atomic<unsigned short> atomic_unsigned_type;
28 typedef short atomic_integer_type;
29 typedef unsigned short atomic_unsigned_type;
30 #elif ATOMIC_LONG_LOCK_FREE == 2
31 typedef std::atomic<long> atomic_unsigned_integer_type;
32 typedef std::atomic<unsigned long> atomic_unsigned_type;
33 typedef unsigned long atomic_unsigned_type;
34 typedef long atomic_integer_type;
35 #elif ATOMIC_LLONG_LOCK_FREE == 2
36 typedef std::atomic<long long> atomic_unsigned_integer_type;
37 typedef std::atomic<unsigned long long> atomic_unsigned_type;
38 typedef long long atomic_integer_type;
39 typedef unsigned long long atomic_unsigned_integer_type;
41 # define BOOST_MATH_NO_ATOMIC_INT
45 #else // BOOST_NO_CXX11_HDR_ATOMIC
47 // We need Boost.Atomic, but on any platform that supports auto-linking we do
48 // not need to link against a separate library:
50 #define BOOST_ATOMIC_NO_LIB
51 #include <boost/atomic.hpp>
52 # define BOOST_MATH_ATOMIC_NS boost
54 namespace boost{ namespace math{ namespace detail{
57 // We need a type to use as an atomic counter:
59 #if BOOST_ATOMIC_INT_LOCK_FREE == 2
60 typedef boost::atomic<int> atomic_counter_type;
61 typedef boost::atomic<unsigned> atomic_unsigned_type;
62 typedef int atomic_integer_type;
63 typedef unsigned atomic_unsigned_integer_type;
64 #elif BOOST_ATOMIC_SHORT_LOCK_FREE == 2
65 typedef boost::atomic<short> atomic_counter_type;
66 typedef boost::atomic<unsigned short> atomic_unsigned_type;
67 typedef short atomic_integer_type;
68 typedef unsigned short atomic_unsigned_integer_type;
69 #elif BOOST_ATOMIC_LONG_LOCK_FREE == 2
70 typedef boost::atomic<long> atomic_counter_type;
71 typedef boost::atomic<unsigned long> atomic_unsigned_type;
72 typedef long atomic_integer_type;
73 typedef unsigned long atomic_unsigned_integer_type;
74 #elif BOOST_ATOMIC_LLONG_LOCK_FREE == 2
75 typedef boost::atomic<long long> atomic_counter_type;
76 typedef boost::atomic<unsigned long long> atomic_unsigned_type;
77 typedef long long atomic_integer_type;
78 typedef unsigned long long atomic_unsigned_integer_type;
80 # define BOOST_MATH_NO_ATOMIC_INT
85 #endif // BOOST_NO_CXX11_HDR_ATOMIC
87 #else // BOOST_HAS_THREADS
89 # define BOOST_MATH_NO_ATOMIC_INT
91 #endif // BOOST_HAS_THREADS
93 #endif // BOOST_MATH_ATOMIC_DETAIL_HPP