atomic.hpp
1.96 KB
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
///////////////////////////////////////////////////////////////////////////////
// Copyright 2017 John Maddock
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_MP_DETAIL_ATOMIC_HPP
#define BOOST_MP_DETAIL_ATOMIC_HPP
#include <boost/multiprecision/detail/standalone_config.hpp>
#ifdef BOOST_HAS_THREADS
# include <atomic>
# define BOOST_MATH_ATOMIC_NS std
namespace boost {
namespace multiprecision {
namespace detail {
#if ATOMIC_INT_LOCK_FREE == 2
using atomic_counter_type = std::atomic<int>;
using atomic_unsigned_type = std::atomic<unsigned>;
using atomic_integer_type = int;
using atomic_unsigned_integer_type = unsigned;
#elif ATOMIC_SHORT_LOCK_FREE == 2
using atomic_counter_type = std::atomic<short>;
using atomic_unsigned_type = std::atomic<unsigned short>;
using atomic_integer_type = short;
using atomic_unsigned_integer_type = unsigned short;
#elif ATOMIC_LONG_LOCK_FREE == 2
using atomic_unsigned_integer_type = std::atomic<long>;
using atomic_unsigned_type = std::atomic<unsigned long>;
using atomic_unsigned_integer_type = unsigned long;
using atomic_integer_type = long;
#elif ATOMIC_LLONG_LOCK_FREE == 2
using atomic_unsigned_integer_type = std::atomic<long long>;
using atomic_unsigned_type = std::atomic<unsigned long long>;
using atomic_integer_type = long long;
using atomic_unsigned_integer_type = unsigned long long;
#else
#define BOOST_MT_NO_ATOMIC_INT
#endif
}
}}
#else // BOOST_HAS_THREADS
#define BOOST_MT_NO_ATOMIC_INT
#endif // BOOST_HAS_THREADS
namespace boost { namespace multiprecision { namespace detail {
#ifdef BOOST_MT_NO_ATOMIC_INT
using precision_type = unsigned;
#else
using precision_type = atomic_unsigned_type;
#endif
} } }
#endif // BOOST_MP_DETAIL_ATOMIC_HPP