atomic.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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)
  6. #ifndef BOOST_MT_ATOMIC_DETAIL_HPP
  7. #define BOOST_MT_ATOMIC_DETAIL_HPP
  8. #include <boost/config.hpp>
  9. #ifdef BOOST_HAS_THREADS
  10. # include <atomic>
  11. # define BOOST_MATH_ATOMIC_NS std
  12. namespace boost {
  13. namespace multiprecision {
  14. namespace detail {
  15. #if ATOMIC_INT_LOCK_FREE == 2
  16. using atomic_counter_type = std::atomic<int>;
  17. using atomic_unsigned_type = std::atomic<unsigned>;
  18. using atomic_integer_type = int;
  19. using atomic_unsigned_integer_type = unsigned;
  20. #elif ATOMIC_SHORT_LOCK_FREE == 2
  21. using atomic_counter_type = std::atomic<short>;
  22. using atomic_unsigned_type = std::atomic<unsigned short>;
  23. using atomic_integer_type = short;
  24. using atomic_unsigned_integer_type = unsigned short;
  25. #elif ATOMIC_LONG_LOCK_FREE == 2
  26. using atomic_unsigned_integer_type = std::atomic<long>;
  27. using atomic_unsigned_type = std::atomic<unsigned long>;
  28. using atomic_unsigned_integer_type = unsigned long;
  29. using atomic_integer_type = long;
  30. #elif ATOMIC_LLONG_LOCK_FREE == 2
  31. using atomic_unsigned_integer_type = std::atomic<long long>;
  32. using atomic_unsigned_type = std::atomic<unsigned long long>;
  33. using atomic_integer_type = long long;
  34. using atomic_unsigned_integer_type = unsigned long long;
  35. #else
  36. #define BOOST_MT_NO_ATOMIC_INT
  37. #endif
  38. }
  39. }}
  40. #else // BOOST_HAS_THREADS
  41. #define BOOST_MT_NO_ATOMIC_INT
  42. #endif // BOOST_HAS_THREADS
  43. namespace boost { namespace multiprecision { namespace detail {
  44. #ifdef BOOST_MT_NO_ATOMIC_INT
  45. using precision_type = unsigned;
  46. #else
  47. using precision_type = atomic_unsigned_type;
  48. #endif
  49. } } }
  50. #endif // BOOST_MATH_ATOMIC_DETAIL_HPP