spinlock.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_HPP_INCLUDED
  2. #define BOOST_SMART_PTR_DETAIL_SPINLOCK_HPP_INCLUDED
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  5. # pragma once
  6. #endif
  7. //
  8. // boost/detail/spinlock.hpp
  9. //
  10. // Copyright (c) 2008 Peter Dimov
  11. //
  12. // Distributed under the Boost Software License, Version 1.0.
  13. // See accompanying file LICENSE_1_0.txt or copy at
  14. // http://www.boost.org/LICENSE_1_0.txt)
  15. //
  16. // struct spinlock
  17. // {
  18. // void lock();
  19. // bool try_lock();
  20. // void unlock();
  21. //
  22. // class scoped_lock;
  23. // };
  24. //
  25. // #define BOOST_DETAIL_SPINLOCK_INIT <unspecified>
  26. //
  27. #include <boost/smart_ptr/detail/sp_has_gcc_intrinsics.hpp>
  28. #include <boost/smart_ptr/detail/sp_has_sync_intrinsics.hpp>
  29. #include <boost/config.hpp>
  30. #if defined( BOOST_SP_USE_STD_ATOMIC )
  31. # include <boost/smart_ptr/detail/spinlock_std_atomic.hpp>
  32. #elif defined( BOOST_SP_USE_PTHREADS )
  33. # include <boost/smart_ptr/detail/spinlock_pt.hpp>
  34. #elif defined( BOOST_SP_HAS_GCC_INTRINSICS )
  35. # include <boost/smart_ptr/detail/spinlock_gcc_atomic.hpp>
  36. #elif !defined( BOOST_NO_CXX11_HDR_ATOMIC )
  37. # include <boost/smart_ptr/detail/spinlock_std_atomic.hpp>
  38. #elif defined(__GNUC__) && defined( __arm__ ) && !defined( __thumb__ )
  39. # include <boost/smart_ptr/detail/spinlock_gcc_arm.hpp>
  40. #elif defined( BOOST_SP_HAS_SYNC_INTRINSICS )
  41. # include <boost/smart_ptr/detail/spinlock_sync.hpp>
  42. #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
  43. # include <boost/smart_ptr/detail/spinlock_w32.hpp>
  44. #elif defined(BOOST_HAS_PTHREADS)
  45. # include <boost/smart_ptr/detail/spinlock_pt.hpp>
  46. #elif !defined(BOOST_HAS_THREADS)
  47. # include <boost/smart_ptr/detail/spinlock_nt.hpp>
  48. #else
  49. # error Unrecognized threading platform
  50. #endif
  51. #endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_HPP_INCLUDED