atomic_count_solaris.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SOLARIS_HPP_INCLUDED
  2. #define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SOLARIS_HPP_INCLUDED
  3. //
  4. // boost/detail/atomic_count_solaris.hpp
  5. // based on: boost/detail/atomic_count_win32.hpp
  6. //
  7. // Copyright (c) 2001-2005 Peter Dimov
  8. // Copyright (c) 2006 Michael van der Westhuizen
  9. //
  10. // Distributed under the Boost Software License, Version 1.0. (See
  11. // accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. //
  14. #include <atomic.h>
  15. namespace boost
  16. {
  17. namespace detail
  18. {
  19. class atomic_count
  20. {
  21. public:
  22. explicit atomic_count( uint32_t v ): value_( v )
  23. {
  24. }
  25. long operator++()
  26. {
  27. return atomic_inc_32_nv( &value_ );
  28. }
  29. long operator--()
  30. {
  31. return atomic_dec_32_nv( &value_ );
  32. }
  33. operator uint32_t() const
  34. {
  35. return static_cast<uint32_t const volatile &>( value_ );
  36. }
  37. private:
  38. atomic_count( atomic_count const & );
  39. atomic_count & operator=( atomic_count const & );
  40. uint32_t value_;
  41. };
  42. } // namespace detail
  43. } // namespace boost
  44. #endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SOLARIS_HPP_INCLUDED