atomic.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_MATH_ATOMIC_DETAIL_HPP
  7. #define BOOST_MATH_ATOMIC_DETAIL_HPP
  8. #include <boost/math/tools/config.hpp>
  9. #include <boost/math/tools/cxx03_warn.hpp>
  10. #ifdef BOOST_MATH_HAS_THREADS
  11. #include <atomic>
  12. namespace boost {
  13. namespace math {
  14. namespace detail {
  15. #if (ATOMIC_INT_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT)
  16. typedef std::atomic<int> atomic_counter_type;
  17. typedef std::atomic<unsigned> atomic_unsigned_type;
  18. typedef int atomic_integer_type;
  19. typedef unsigned atomic_unsigned_integer_type;
  20. #elif (ATOMIC_SHORT_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT)
  21. typedef std::atomic<short> atomic_counter_type;
  22. typedef std::atomic<unsigned short> atomic_unsigned_type;
  23. typedef short atomic_integer_type;
  24. typedef unsigned short atomic_unsigned_type;
  25. #elif (ATOMIC_LONG_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT)
  26. typedef std::atomic<long> atomic_unsigned_integer_type;
  27. typedef std::atomic<unsigned long> atomic_unsigned_type;
  28. typedef unsigned long atomic_unsigned_type;
  29. typedef long atomic_integer_type;
  30. #elif (ATOMIC_LLONG_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT)
  31. typedef std::atomic<long long> atomic_unsigned_integer_type;
  32. typedef std::atomic<unsigned long long> atomic_unsigned_type;
  33. typedef long long atomic_integer_type;
  34. typedef unsigned long long atomic_unsigned_integer_type;
  35. #elif !defined(BOOST_MATH_NO_ATOMIC_INT)
  36. # define BOOST_MATH_NO_ATOMIC_INT
  37. #endif
  38. } // Namespace detail
  39. } // Namespace math
  40. } // Namespace boost
  41. #else
  42. # define BOOST_MATH_NO_ATOMIC_INT
  43. #endif // BOOST_MATH_HAS_THREADS
  44. #endif // BOOST_MATH_ATOMIC_DETAIL_HPP