From 2932ca420340d9be59380bf7d30e92ae9dcea606 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 23 Dec 2018 01:54:36 +0200 Subject: [PATCH] Change sp_counted_base_nt/_pt to use boost::int_least32_t instead of long (which may be 64 bit) --- include/boost/smart_ptr/detail/sp_counted_base_nt.hpp | 5 +++-- include/boost/smart_ptr/detail/sp_counted_base_pt.hpp | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/boost/smart_ptr/detail/sp_counted_base_nt.hpp b/include/boost/smart_ptr/detail/sp_counted_base_nt.hpp index e61bd88..35a65d8 100644 --- a/include/boost/smart_ptr/detail/sp_counted_base_nt.hpp +++ b/include/boost/smart_ptr/detail/sp_counted_base_nt.hpp @@ -20,6 +20,7 @@ #include #include +#include namespace boost { @@ -34,8 +35,8 @@ private: sp_counted_base( sp_counted_base const & ); sp_counted_base & operator= ( sp_counted_base const & ); - long use_count_; // #shared - long weak_count_; // #weak + (#shared != 0) + boost::int_least32_t use_count_; // #shared + boost::int_least32_t weak_count_; // #weak + (#shared != 0) public: diff --git a/include/boost/smart_ptr/detail/sp_counted_base_pt.hpp b/include/boost/smart_ptr/detail/sp_counted_base_pt.hpp index 3110f23..1aa6756 100644 --- a/include/boost/smart_ptr/detail/sp_counted_base_pt.hpp +++ b/include/boost/smart_ptr/detail/sp_counted_base_pt.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include namespace boost @@ -36,8 +37,8 @@ private: sp_counted_base( sp_counted_base const & ); sp_counted_base & operator= ( sp_counted_base const & ); - long use_count_; // #shared - long weak_count_; // #weak + (#shared != 0) + boost::int_least32_t use_count_; // #shared + boost::int_least32_t weak_count_; // #weak + (#shared != 0) mutable pthread_mutex_t m_; @@ -93,7 +94,7 @@ public: void release() // nothrow { BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); - long new_use_count = --use_count_; + boost::int_least32_t new_use_count = --use_count_; BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); if( new_use_count == 0 ) @@ -113,7 +114,7 @@ public: void weak_release() // nothrow { BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); - long new_weak_count = --weak_count_; + boost::int_least32_t new_weak_count = --weak_count_; BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); if( new_weak_count == 0 ) @@ -125,7 +126,7 @@ public: long use_count() const // nothrow { BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); - long r = use_count_; + boost::int_least32_t r = use_count_; BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); return r;