From d8e19f3114a751fd78aaef68e763f24d286b0f8c Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 2 Sep 2015 10:51:14 +0000 Subject: [PATCH] re PR libstdc++/67408 ( assumes that __gthread_mutex_t and__gthread_recursive_mutex_t are the same types) 2015-09-02 Sebastian Huber PR libstdc++/67408 * include/std/mutex (__timed_mutex_impl::_M_try_lock_until): Use _Derived::_M_timedlock(). (timed_mutex): Add _M_timedlock() and make base class a friend. (recursive_timed_mutex): Likewise. From-SVN: r227400 --- libstdc++-v3/ChangeLog | 8 ++++++++ libstdc++-v3/include/std/mutex | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 823939fa8f7..d9c9d49353f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2015-09-02 Sebastian Huber + + PR libstdc++/67408 + * include/std/mutex (__timed_mutex_impl::_M_try_lock_until): Use + _Derived::_M_timedlock(). + (timed_mutex): Add _M_timedlock() and make base class a friend. + (recursive_timed_mutex): Likewise. + 2015-08-28 Tim Shen PR libstdc++/67362 diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex index deb85dfefe0..790508c65c2 100644 --- a/libstdc++-v3/include/std/mutex +++ b/libstdc++-v3/include/std/mutex @@ -230,8 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static_cast(__ns.count()) }; - auto __mutex = static_cast<_Derived*>(this)->native_handle(); - return !__gthread_mutex_timedlock(__mutex, &__ts); + return static_cast<_Derived*>(this)->_M_timedlock(__ts); } template @@ -293,6 +292,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION native_handle_type native_handle() { return &_M_mutex; } + + private: + friend class __timed_mutex_impl; + + bool + _M_timedlock(const __gthread_time_t& __ts) + { return !__gthread_mutex_timedlock(&_M_mutex, &__ts); } }; /// recursive_timed_mutex @@ -346,6 +352,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION native_handle_type native_handle() { return &_M_mutex; } + + private: + friend class __timed_mutex_impl; + + bool + _M_timedlock(const __gthread_time_t& __ts) + { return !__gthread_recursive_mutex_timedlock(&_M_mutex, &__ts); } }; #endif #endif // _GLIBCXX_HAS_GTHREADS -- 2.30.2