[RFC 1/2] gthread: Add __gthread_cond_timedwaitonclock

Jonathan Wakely jwakely@redhat.com
Mon Jul 6 13:51:00 GMT 2015


On 06/07/15 13:55 +0100, Mike Crowe wrote:
>diff --git a/libgcc/gthr-posix.h b/libgcc/gthr-posix.h
>index fb59816..0e01866 100644
>--- a/libgcc/gthr-posix.h
>+++ b/libgcc/gthr-posix.h
>@@ -33,6 +33,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> #define __GTHREADS_CXX0X 1
>
> #include <pthread.h>
>+#include <time.h>
>
> #if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \
>      || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK))
>@@ -44,6 +45,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> # endif
> #endif
>
>+
>+#if defined(_GLIBCXX_USE_PTHREAD_COND_TIMEDWAITONCLOCK_NP)
>+# define _GTHREAD_USE_COND_TIMEDWAITONCLOCK 1
>+#endif

This isn't correct, because it's possible to include <gthr.h> before
including any C++ Standard Library header, so the _GLIBCXX_ macro
defined in libstdc++'s c++config.h will not have been defined.

It might make sense to just do this internally in libstdc++ and not
involve gthr-posix.h at all, this is what we do for pthread_rwlock_t
usage in <shared_mutex> so you might want to follow that model.

How portable is pthread_cond_timedwaitonclock_np? Is it unique to
glibc or do any other posix systems provide it?



More information about the Libstdc++ mailing list