* [patch] libstdc++/67408 Handle distinct __gthread_recursive_mutex_t type.
@ 2015-09-02 10:51 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2015-09-02 10:51 UTC (permalink / raw)
To: libstdc++, gcc-patches; +Cc: Sebastian Huber
[-- Attachment #1: Type: text/plain, Size: 241 bytes --]
This makes recursive_timed_mutex work for non-pthreads targets where
__gthread_mutex_t and __gthread_recursive_mutex_t are not the same
type. Thanks to Sebastian for the bug report and patch.
Tested powerpc64le-linux, committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1714 bytes --]
commit 852d09122561d301b2980b6f9c97e88c5499006c
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Sep 2 11:39:46 2015 +0100
2015-09-02 Sebastian Huber <sebastian.huber@embedded-brains.de>
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.
diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex
index deb85df..790508c 100644
--- a/libstdc++-v3/include/std/mutex
+++ b/libstdc++-v3/include/std/mutex
@@ -230,8 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static_cast<long>(__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<typename _Clock, typename _Duration>
@@ -293,6 +292,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
native_handle_type
native_handle()
{ return &_M_mutex; }
+
+ private:
+ friend class __timed_mutex_impl<timed_mutex>;
+
+ 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<recursive_timed_mutex>;
+
+ bool
+ _M_timedlock(const __gthread_time_t& __ts)
+ { return !__gthread_recursive_mutex_timedlock(&_M_mutex, &__ts); }
};
#endif
#endif // _GLIBCXX_HAS_GTHREADS
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-09-02 10:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-02 10:51 [patch] libstdc++/67408 Handle distinct __gthread_recursive_mutex_t type Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).