unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] nptl: Add pthread_clockjoin_np
@ 2019-09-18 12:30 Mike Crowe
  2019-09-18 12:30 ` [PATCH v2 1/4] nptl: Convert tst-join3 to use libsupport Mike Crowe
                   ` (4 more replies)
  0 siblings, 5 replies; 23+ messages in thread
From: Mike Crowe @ 2019-09-18 12:30 UTC (permalink / raw)
  To: libc-alpha; +Cc: Mike Crowe

The aim of this series is to add pthread_clockjoin_np, which works
like pthread_timedjoin_np except it accepts an additional parameter to
indicate which clock the timeout should be measured against.

The naming matches the pthread_cond_clockwait,
pthread_mutex_clocklock, sem_clockwait, etc. functions added in glibc
v2.30 and documented at http://austingroupbugs.net/view.php?id=1216.

The series also includes some minimal documentation for
pthread_tryjoin_np and pthread_timedjoin_np, along with some new
tests.

Thanks to everyone who provided feedback for the first version[1] of
this series.

[1] https://sourceware.org/ml/libc-alpha/2019-06/msg00911.html

Mike Crowe (4):
  nptl: Convert tst-join3 to use libsupport
  manual: Add documentation for pthread_tryjoin_np and pthread_timedjoin_np
  nptl: Add pthread_clockjoin_np
  nptl: Add pthread_timedjoin_np, pthread_clockjoin_np NULL timeout test

 ChangeLog                                                       |  85 ++++++-
 NEWS                                                            |   9 +-
 manual/threads.texi                                             |  38 ++-
 nptl/Makefile                                                   |   6 +-
 nptl/Versions                                                   |   4 +-
 nptl/pthreadP.h                                                 |   5 +-
 nptl/pthread_clockjoin.c                                        |  28 ++-
 nptl/pthread_join.c                                             |   2 +-
 nptl/pthread_join_common.c                                      |  23 +-
 nptl/pthread_timedjoin.c                                        |   3 +-
 nptl/pthread_tryjoin.c                                          |   2 +-
 nptl/thrd_join.c                                                |   2 +-
 nptl/tst-join10.c                                               |  20 +-
 nptl/tst-join11.c                                               |  21 +-
 nptl/tst-join12.c                                               |  20 +-
 nptl/tst-join13.c                                               |  21 +-
 nptl/tst-join14.c                                               |  73 +++++-
 nptl/tst-join3.c                                                | 104 ++-----
 nptl/tst-join5.c                                                |  20 +-
 sysdeps/nptl/pthread.h                                          |  11 +-
 sysdeps/unix/sysv/linux/aarch64/libpthread.abilist              |   1 +-
 sysdeps/unix/sysv/linux/alpha/libpthread.abilist                |   1 +-
 sysdeps/unix/sysv/linux/arm/be/libpthread.abilist               |   1 +-
 sysdeps/unix/sysv/linux/arm/le/libpthread.abilist               |   1 +-
 sysdeps/unix/sysv/linux/csky/libpthread.abilist                 |   1 +-
 sysdeps/unix/sysv/linux/hppa/libpthread.abilist                 |   1 +-
 sysdeps/unix/sysv/linux/i386/libpthread.abilist                 |   1 +-
 sysdeps/unix/sysv/linux/ia64/libpthread.abilist                 |   1 +-
 sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist        |   1 +-
 sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist          |   1 +-
 sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist        |   1 +-
 sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist        |   1 +-
 sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist          |   1 +-
 sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist          |   1 +-
 sysdeps/unix/sysv/linux/nios2/libpthread.abilist                |   1 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist    |   1 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist |   1 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist |   1 +-
 sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist           |   1 +-
 sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist         |   1 +-
 sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist         |   1 +-
 sysdeps/unix/sysv/linux/sh/be/libpthread.abilist                |   1 +-
 sysdeps/unix/sysv/linux/sh/le/libpthread.abilist                |   1 +-
 sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist        |   1 +-
 sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist        |   1 +-
 sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist            |   1 +-
 sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist           |   1 +-
 47 files changed, 428 insertions(+), 96 deletions(-)
 create mode 100644 nptl/pthread_clockjoin.c
 create mode 100644 nptl/tst-join10.c
 create mode 100644 nptl/tst-join11.c
 create mode 100644 nptl/tst-join12.c
 create mode 100644 nptl/tst-join13.c
 create mode 100644 nptl/tst-join14.c

base-commit: 2f9046fb059e94fe254c9a4ff5bcd52182069e44
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 1/4] nptl: Convert tst-join3 to use libsupport
  2019-09-18 12:30 [PATCH v2 0/4] nptl: Add pthread_clockjoin_np Mike Crowe
@ 2019-09-18 12:30 ` Mike Crowe
  2019-09-26 20:45   ` Adhemerval Zanella
  2019-09-18 12:30 ` [PATCH v2 2/4] manual: Add documentation for pthread_tryjoin_np and pthread_timedjoin_np Mike Crowe
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 23+ messages in thread
From: Mike Crowe @ 2019-09-18 12:30 UTC (permalink / raw)
  To: libc-alpha; +Cc: Mike Crowe

* nptl/tst-join3.c: Use libsupport.
---
 ChangeLog        |  4 ++-
 nptl/tst-join3.c | 86 +++++++++++--------------------------------------
 2 files changed, 24 insertions(+), 66 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index adc93a7..d7943ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2019-09-18  Mike Crowe  <mac@mcrowe.com>
+
+	* nptl/tst-join3.c: Use libsupport.
+
 2019-09-18  Stefan Liebler  <stli@linux.ibm.com>
 
 	* elf/tst-pldd.c (do_test): Add UNSUPPORTED check.
diff --git a/nptl/tst-join3.c b/nptl/tst-join3.c
index d8785c5..a4ae459 100644
--- a/nptl/tst-join3.c
+++ b/nptl/tst-join3.c
@@ -22,6 +22,10 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/time.h>
+#include <support/check.h>
+#include <support/timespec.h>
+#include <support/xthread.h>
+#include <support/xtime.h>
 
 
 static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
@@ -30,11 +34,7 @@ static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
 static void *
 tf (void *arg)
 {
-  if (pthread_mutex_lock (&lock) != 0)
-    {
-      puts ("child: mutex_lock failed");
-      return NULL;
-    }
+  xpthread_mutex_lock (&lock);
 
   return (void *) 42l;
 }
@@ -43,80 +43,34 @@ tf (void *arg)
 static int
 do_test (void)
 {
-  pthread_t th;
-
-  if (pthread_mutex_lock (&lock) != 0)
-    {
-      puts ("mutex_lock failed");
-      exit (1);
-    }
-
-  if (pthread_create (&th, NULL, tf, NULL) != 0)
-    {
-      puts ("mutex_create failed");
-      exit (1);
-    }
+  xpthread_mutex_lock (&lock);
+  pthread_t th = xpthread_create (NULL, tf, NULL);
 
   void *status;
-  struct timespec ts;
-  struct timeval tv;
-  (void) gettimeofday (&tv, NULL);
-  TIMEVAL_TO_TIMESPEC (&tv, &ts);
-  ts.tv_nsec += 200000000;
-  if (ts.tv_nsec >= 1000000000)
-    {
-      ts.tv_nsec -= 1000000000;
-      ++ts.tv_sec;
-    }
-  int val = pthread_timedjoin_np (th, &status, &ts);
-  if (val == 0)
-    {
-      puts ("1st timedjoin succeeded");
-      exit (1);
-    }
-  else if (val != ETIMEDOUT)
-    {
-      puts ("1st timedjoin didn't return ETIMEDOUT");
-      exit (1);
-    }
+  struct timespec timeout = timespec_add (xclock_now (CLOCK_REALTIME),
+                                          make_timespec (0, 200000000));
 
-  if (pthread_mutex_unlock (&lock) != 0)
-    {
-      puts ("mutex_unlock failed");
-      exit (1);
-    }
+  int val = pthread_timedjoin_np (th, &status, &timeout);
+  TEST_COMPARE (val, ETIMEDOUT);
+
+  xpthread_mutex_unlock (&lock);
 
   while (1)
     {
-      (void) gettimeofday (&tv, NULL);
-      TIMEVAL_TO_TIMESPEC (&tv, &ts);
-      ts.tv_nsec += 200000000;
-      if (ts.tv_nsec >= 1000000000)
-	{
-	  ts.tv_nsec -= 1000000000;
-	  ++ts.tv_sec;
-	}
-
-      val = pthread_timedjoin_np (th, &status, &ts);
+      timeout = timespec_add (xclock_now (CLOCK_REALTIME),
+                              make_timespec (0, 200000000));
+
+      val = pthread_timedjoin_np (th, &status, &timeout);
       if (val == 0)
 	break;
 
-      if (val != ETIMEDOUT)
-	{
-	  printf ("timedjoin returned %s (%d), expected only 0 or ETIMEDOUT\n",
-		  strerror (val), val);
-	  exit (1);
-	}
+      TEST_COMPARE (val, ETIMEDOUT);
     }
 
   if (status != (void *) 42l)
-    {
-      printf ("return value %p, expected %p\n", status, (void *) 42l);
-      exit (1);
-    }
+    FAIL_EXIT1 ("return value %p, expected %p\n", status, (void *) 42l);
 
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
-- 
git-series 0.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 2/4] manual: Add documentation for pthread_tryjoin_np and pthread_timedjoin_np
  2019-09-18 12:30 [PATCH v2 0/4] nptl: Add pthread_clockjoin_np Mike Crowe
  2019-09-18 12:30 ` [PATCH v2 1/4] nptl: Convert tst-join3 to use libsupport Mike Crowe
@ 2019-09-18 12:30 ` Mike Crowe
  2019-09-26 21:26   ` Adhemerval Zanella
  2019-09-18 12:30 ` [PATCH v2 3/4] nptl: Add pthread_clockjoin_np Mike Crowe
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 23+ messages in thread
From: Mike Crowe @ 2019-09-18 12:30 UTC (permalink / raw)
  To: libc-alpha; +Cc: Mike Crowe

This documentation isn't perfect, but it's better than nothing and can
hopefully act as a basis for future improvement. In particular, although
I'm certain that the functions are MT-Safe, I'm not sure about the rest of
the @safety line.

Yann Droneaud pointed out that pthread_timedjoin_np would wait forever if
the timeout parameter is passed as NULL. Since it's now too late to change
that, I've documented it.

	* manual/threads.texi: Add brief documentation for
	pthread_tryjoin_np and pthread_timedjoin_np.
---
 ChangeLog           |  5 +++++
 manual/threads.texi | 26 ++++++++++++++++++++++++--
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d7943ff..94ee860 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2019-09-18  Mike Crowe  <mac@mcrowe.com>
 
+	* manual/threads.texi: Add brief documentation for
+	pthread_tryjoin_np and pthread_timedjoin_np.
+
+2019-09-18  Mike Crowe  <mac@mcrowe.com>
+
 	* nptl/tst-join3.c: Use libsupport.
 
 2019-09-18  Stefan Liebler  <stli@linux.ibm.com>
diff --git a/manual/threads.texi b/manual/threads.texi
index 0e5e84a..8dcfc53 100644
--- a/manual/threads.texi
+++ b/manual/threads.texi
@@ -727,6 +727,30 @@ rather than @code{CLOCK_REALTIME}.  Currently, @var{clockid} must be either
 returned.
 @end deftypefun
 
+@comment pthread.h
+@comment GNU extension
+@deftypefun int pthread_tryjoin_np (pthread_t *@var{thread},
+				      void **@var{thread_return})
+@standards{GNU, pthread.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Behaves like @code{pthread_join} except that it will return @code{EBUSY}
+immediately if the thread specified by @var{thread} has not yet terminated.
+@end deftypefun
+
+@comment pthread.h
+@comment GNU extension
+@deftypefun int pthread_timedjoin_np (pthread_t *@var{thread},
+				      void **@var{thread_return},
+				      const struct timespec *@var{abstime})
+@standards{GNU, pthread.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Behaves like @code{pthread_tryjoin_np} except that it will block until the
+absolute time @var{abstime} measured against @code{CLOCK_REALTIME} is
+reached if the thread has not terminated by that time and return
+@code{EBUSY}. If @var{abstime} is equal to @code{NULL} then the function
+will wait forever in the same way as @code{pthread_join}.
+@end deftypefun
+
 @c FIXME these are undocumented:
 @c pthread_atfork
 @c pthread_attr_destroy
@@ -844,6 +868,4 @@ returned.
 @c pthread_spin_trylock
 @c pthread_spin_unlock
 @c pthread_testcancel
-@c pthread_timedjoin_np
-@c pthread_tryjoin_np
 @c pthread_yield
-- 
git-series 0.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 3/4] nptl: Add pthread_clockjoin_np
  2019-09-18 12:30 [PATCH v2 0/4] nptl: Add pthread_clockjoin_np Mike Crowe
  2019-09-18 12:30 ` [PATCH v2 1/4] nptl: Convert tst-join3 to use libsupport Mike Crowe
  2019-09-18 12:30 ` [PATCH v2 2/4] manual: Add documentation for pthread_tryjoin_np and pthread_timedjoin_np Mike Crowe
@ 2019-09-18 12:30 ` Mike Crowe
  2019-09-26 23:17   ` Adhemerval Zanella
  2019-10-08  8:26   ` Mike Crowe
  2019-09-18 12:30 ` [PATCH v2 4/4] nptl: Add pthread_timedjoin_np, pthread_clockjoin_np NULL timeout test Mike Crowe
  2019-10-31 14:31 ` [PATCH v2 0/4] nptl: Add pthread_clockjoin_np Adhemerval Zanella
  4 siblings, 2 replies; 23+ messages in thread
From: Mike Crowe @ 2019-09-18 12:30 UTC (permalink / raw)
  To: libc-alpha; +Cc: Mike Crowe

Introduce pthread_clockjoin_np as a version of pthread_timedjoin_np that
accepts a clockid_t parameter to indicate which clock the timeout should be
measured against. This mirrors the recently-added POSIX-proposed "clock"
wait functions.

	* NEWS: Mention addition of pthread_clockjoin_np along with other
	"clock" variants of existing "timed" functions.
	* sysdeps/nptl/pthread.h: Add declaration of pthread_clockjoin_np.
	* manual/threads.texi: Add pthread_clockjoin_np.
	* nptl/Makefile: Add pthread_clockjoin source file.  Add new join
	tests.
	* nptl/Versions: Add pthread_clockjoin_np.
	* nptl/PthreadP.h: Rename __pthread_timedjoin_ex to
	__pthread_clockjoin_ex and add clockid_t parameter.
	* nptl/pthread_clockjoin.c: New file to implement pthread_clockjoin_np.
	* nptl/pthread_join_common.c (clockwait_tid): Rename from
	timedwait_tid and add clockid parameter.  Use __clock_gettime
	passing supplied clockid rather than using __gettimeofday.  Perform
	relative timeout calculation entirely in timespec.
	(__pthread_clockjoin_ex): Rename from __pthread_timedjoin_ex and
	add clockid parameter to pass to clockwait_tid rather than
	timedwait_tid.
	* nptl/pthread_timedjoin.c (__pthread_timedjoin_np): Call
	__pthread_clockjoin_ex passing CLOCK_REALTIME as clockid.
	* nptl/pthread_join.c (__pthread_join): Call __pthread_clockjoin_ex
	and pass zero as unused clockid_t parameter.
	* nptl/pthread_tryjoin.c (__pthread_tryjoin_np): Likewise.
	* nptl/thrd_join.c (thrd_join): Likewise.
	* nptl/tst-join3.c (tf): Ensure that mutex is unlocked after use so
	that it can be used again.  (do_test_clock): Rename from do_test and
	accept a clock parameter.  (do_test): Test pthread_timedjoin_np,
	pthread_clockjoin_np with CLOCK_REALTIME and pthread_clockjoin_np
	with CLOCK_MONOTONIC.
	* nptl/tst-join5.c (thread_join): Add support for testing
	pthread_clockjoin_np with both CLOCK_REALTIME and CLOCK_MONOTONIC.
	* nptl/tst-join10.c: Wrap tst-join5.c with
	USE_PTHREAD_CLOCKJOIN_NP_REALTIME.
	* nptl/tst-join11.c: Wrap tst-join5.c with
	USE_PTHREAD_CLOCKJOIN_NP_REALTIME and WAIT_IN_CHILD.
	* nptl/tst-join12.c: Wrap tst-join5.c with
	USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC.
	* nptl/tst-join13.c: Wrap tst-join5.c with
	USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC and WAIT_IN_CHILD.
	* sysdeps/unix/sysv/linux/aarch64/libpthread.abilist: Add
	pthread_clockjoin_np.
	* sysdeps/unix/sysv/linux/alpha/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/be/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/le/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/csky/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/be/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/le/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist: Likewise.
---
 ChangeLog                                                       | 71 +++++++-
 NEWS                                                            |  9 +-
 manual/threads.texi                                             | 12 +-
 nptl/Makefile                                                   |  5 +-
 nptl/Versions                                                   |  4 +-
 nptl/pthreadP.h                                                 |  5 +-
 nptl/pthread_clockjoin.c                                        | 28 +++-
 nptl/pthread_join.c                                             |  2 +-
 nptl/pthread_join_common.c                                      | 23 +-
 nptl/pthread_timedjoin.c                                        |  3 +-
 nptl/pthread_tryjoin.c                                          |  2 +-
 nptl/thrd_join.c                                                |  2 +-
 nptl/tst-join10.c                                               | 20 ++-
 nptl/tst-join11.c                                               | 21 ++-
 nptl/tst-join12.c                                               | 20 ++-
 nptl/tst-join13.c                                               | 21 ++-
 nptl/tst-join3.c                                                | 26 ++-
 nptl/tst-join5.c                                                | 20 +-
 sysdeps/nptl/pthread.h                                          | 11 +-
 sysdeps/unix/sysv/linux/aarch64/libpthread.abilist              |  1 +-
 sysdeps/unix/sysv/linux/alpha/libpthread.abilist                |  1 +-
 sysdeps/unix/sysv/linux/arm/be/libpthread.abilist               |  1 +-
 sysdeps/unix/sysv/linux/arm/le/libpthread.abilist               |  1 +-
 sysdeps/unix/sysv/linux/csky/libpthread.abilist                 |  1 +-
 sysdeps/unix/sysv/linux/hppa/libpthread.abilist                 |  1 +-
 sysdeps/unix/sysv/linux/i386/libpthread.abilist                 |  1 +-
 sysdeps/unix/sysv/linux/ia64/libpthread.abilist                 |  1 +-
 sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist        |  1 +-
 sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist          |  1 +-
 sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist        |  1 +-
 sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist        |  1 +-
 sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist          |  1 +-
 sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist          |  1 +-
 sysdeps/unix/sysv/linux/nios2/libpthread.abilist                |  1 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist    |  1 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist |  1 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist |  1 +-
 sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist           |  1 +-
 sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist         |  1 +-
 sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist         |  1 +-
 sysdeps/unix/sysv/linux/sh/be/libpthread.abilist                |  1 +-
 sysdeps/unix/sysv/linux/sh/le/libpthread.abilist                |  1 +-
 sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist        |  1 +-
 sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist        |  1 +-
 sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist            |  1 +-
 sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist           |  1 +-
 46 files changed, 300 insertions(+), 32 deletions(-)
 create mode 100644 nptl/pthread_clockjoin.c
 create mode 100644 nptl/tst-join10.c
 create mode 100644 nptl/tst-join11.c
 create mode 100644 nptl/tst-join12.c
 create mode 100644 nptl/tst-join13.c

diff --git a/ChangeLog b/ChangeLog
index 94ee860..8a2166d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,75 @@
 2019-09-18  Mike Crowe  <mac@mcrowe.com>
+	* NEWS: Mention addition of pthread_clockjoin_np along with other
+	"clock" variants of existing "timed" functions.
+	* sysdeps/nptl/pthread.h: Add declaration of pthread_clockjoin_np.
+	* manual/threads.texi: Add pthread_clockjoin_np.
+	* nptl/Makefile: Add pthread_clockjoin source file.  Add new join
+	tests.
+	* nptl/Versions: Add pthread_clockjoin_np.
+	* nptl/PthreadP.h: Rename __pthread_timedjoin_ex to
+	__pthread_clockjoin_ex and add clockid_t parameter.
+	* nptl/pthread_clockjoin.c: New file to implement pthread_clockjoin_np.
+	* nptl/pthread_join_common.c (clockwait_tid): Rename from
+	timedwait_tid and add clockid parameter.  Use __clock_gettime
+	passing supplied clockid rather than using __gettimeofday.  Perform
+	relative timeout calculation entirely in timespec.
+	(__pthread_clockjoin_ex): Rename from __pthread_timedjoin_ex and
+	add clockid parameter to pass to clockwait_tid rather than
+	timedwait_tid.
+	* nptl/pthread_timedjoin.c (__pthread_timedjoin_np): Call
+	__pthread_clockjoin_ex passing CLOCK_REALTIME as clockid.
+	* nptl/pthread_join.c (__pthread_join): Call __pthread_clockjoin_ex
+	and pass zero as unused clockid_t parameter.
+	* nptl/pthread_tryjoin.c (__pthread_tryjoin_np): Likewise.
+	* nptl/thrd_join.c (thrd_join): Likewise.
+	* nptl/tst-join3.c (tf): Ensure that mutex is unlocked after use so
+	that it can be used again.  (do_test_clock): Rename from do_test and
+	accept a clock parameter.  (do_test): Test pthread_timedjoin_np,
+	pthread_clockjoin_np with CLOCK_REALTIME and pthread_clockjoin_np
+	with CLOCK_MONOTONIC.
+	* nptl/tst-join5.c (thread_join): Add support for testing
+	pthread_clockjoin_np with both CLOCK_REALTIME and CLOCK_MONOTONIC.
+	* nptl/tst-join10.c: Wrap tst-join5.c with
+	USE_PTHREAD_CLOCKJOIN_NP_REALTIME.
+	* nptl/tst-join11.c: Wrap tst-join5.c with
+	USE_PTHREAD_CLOCKJOIN_NP_REALTIME and WAIT_IN_CHILD.
+	* nptl/tst-join12.c: Wrap tst-join5.c with
+	USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC.
+	* nptl/tst-join13.c: Wrap tst-join5.c with
+	USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC and WAIT_IN_CHILD.
+	* sysdeps/unix/sysv/linux/aarch64/libpthread.abilist: Add
+	pthread_clockjoin_np.
+	* sysdeps/unix/sysv/linux/alpha/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/arm/be/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/arm/le/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/csky/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/hppa/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/i386/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/ia64/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/nios2/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist:
+	Likewise.
+	* sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist:
+	Likewise.
+	* sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist:
+	Likewise.
+	* sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/sh/be/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/sh/le/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist: Likewise.
+
+2019-09-18  Mike Crowe  <mac@mcrowe.com>
 
 	* manual/threads.texi: Add brief documentation for
 	pthread_tryjoin_np and pthread_timedjoin_np.
diff --git a/NEWS b/NEWS
index d728684..bb1b07a 100644
--- a/NEWS
+++ b/NEWS
@@ -81,10 +81,11 @@ Major new features:
 
 * Add new POSIX-proposed pthread_cond_clockwait, pthread_mutex_clocklock,
   pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock and sem_clockwait
-  functions.  These behave similarly to their "timed" equivalents, but also
-  accept a clockid_t parameter to determine which clock their timeout should
-  be measured against.  All functions allow waiting against CLOCK_MONOTONIC
-  and CLOCK_REALTIME.  The decision of which clock to be used is made at the
+  functions along with glibc-specific pthread_clockjoin_np.  These behave
+  similarly to their "timed" equivalents, but also accept a clockid_t
+  parameter to determine which clock their timeout should be measured
+  against.  All functions allow waiting against CLOCK_MONOTONIC and
+  CLOCK_REALTIME.  The decision of which clock to be used is made at the
   time of the wait (unlike with pthread_condattr_setclock, which requires
   the clock choice at initialization time).
 
diff --git a/manual/threads.texi b/manual/threads.texi
index 8dcfc53..0055025 100644
--- a/manual/threads.texi
+++ b/manual/threads.texi
@@ -751,6 +751,18 @@ reached if the thread has not terminated by that time and return
 will wait forever in the same way as @code{pthread_join}.
 @end deftypefun
 
+@comment pthread.h
+@comment GNU extension
+@deftypefun int pthread_clockjoin_np (pthread_t *@var{thread},
+				      void **@var{thread_return},
+                                      clockid_t @var{clockid},
+				      const struct timespec *@var{abstime})
+@standards{GNU, pthread.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Behaves like @code{pthread_timedjoin_np} except that time absolute time in
+@var{abstime} is measured against the clock specified by @var{clockid}.
+@end deftypefun
+
 @c FIXME these are undocumented:
 @c pthread_atfork
 @c pthread_attr_destroy
diff --git a/nptl/Makefile b/nptl/Makefile
index 66f89f1..5521a58 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -51,7 +51,7 @@ pthread-compat-wrappers = \
 libpthread-routines = nptl-init nptlfreeres vars events version pt-interp \
 		      pthread_create pthread_exit pthread_detach \
 		      pthread_join pthread_tryjoin pthread_timedjoin \
-		      pthread_join_common pthread_yield \
+		      pthread_clockjoin pthread_join_common pthread_yield \
 		      pthread_getconcurrency pthread_setconcurrency \
 		      pthread_getschedparam pthread_setschedparam \
 		      pthread_setschedprio \
@@ -189,6 +189,7 @@ CFLAGS-forward.c += -fexceptions
 CFLAGS-pthread_testcancel.c += -fexceptions
 CFLAGS-pthread_join.c += -fexceptions -fasynchronous-unwind-tables
 CFLAGS-pthread_timedjoin.c += -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pthread_clockjoin.c += -fexceptions -fasynchronous-unwind-tables
 CFLAGS-pthread_once.c += $(uses-callbacks) -fexceptions \
 			-fasynchronous-unwind-tables
 CFLAGS-pthread_cond_wait.c += -fexceptions -fasynchronous-unwind-tables
@@ -273,7 +274,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
 	tst-kill1 tst-kill2 tst-kill3 tst-kill4 tst-kill5 tst-kill6 \
 	tst-raise1 \
 	tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 tst-join6 tst-join7 \
-	tst-join8 tst-join9 \
+	tst-join8 tst-join9 tst-join10 tst-join11 tst-join12 tst-join13 \
 	tst-detach1 \
 	tst-eintr2 tst-eintr3 tst-eintr4 tst-eintr5 \
 	tst-tsd1 tst-tsd2 tst-tsd3 tst-tsd4 tst-tsd5 tst-tsd6 \
diff --git a/nptl/Versions b/nptl/Versions
index 6f4d74f..c169400 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -279,6 +279,10 @@ libpthread {
     pthread_mutex_clocklock;
   }
 
+  GLIBC_2.31 {
+    pthread_clockjoin_np;
+  }
+
   GLIBC_PRIVATE {
     __pthread_initialize_minimal;
     __pthread_clock_gettime; __pthread_clock_settime;
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index 070b3af..19bd544 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -475,7 +475,8 @@ extern int __pthread_setcanceltype (int type, int *oldtype);
 extern int __pthread_enable_asynccancel (void) attribute_hidden;
 extern void __pthread_disable_asynccancel (int oldtype) attribute_hidden;
 extern void __pthread_testcancel (void);
-extern int __pthread_timedjoin_ex (pthread_t, void **, const struct timespec *,
+extern int __pthread_clockjoin_ex (pthread_t, void **,
+                                   clockid_t, const struct timespec *,
 				   bool);
 
 #if IS_IN (libpthread)
@@ -495,7 +496,7 @@ hidden_proto (__pthread_setcancelstate)
 hidden_proto (__pthread_testcancel)
 hidden_proto (__pthread_mutexattr_init)
 hidden_proto (__pthread_mutexattr_settype)
-hidden_proto (__pthread_timedjoin_ex)
+hidden_proto (__pthread_clockjoin_ex)
 #endif
 
 extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond);
diff --git a/nptl/pthread_clockjoin.c b/nptl/pthread_clockjoin.c
new file mode 100644
index 0000000..fc1ef18
--- /dev/null
+++ b/nptl/pthread_clockjoin.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include "pthreadP.h"
+
+int
+__pthread_clockjoin_np (pthread_t threadid, void **thread_return,
+			clockid_t clockid,
+			const struct timespec *abstime)
+{
+  return __pthread_clockjoin_ex (threadid, thread_return,
+                                 clockid, abstime, true);
+}
+weak_alias (__pthread_clockjoin_np, pthread_clockjoin_np)
diff --git a/nptl/pthread_join.c b/nptl/pthread_join.c
index 3523b20..e189155 100644
--- a/nptl/pthread_join.c
+++ b/nptl/pthread_join.c
@@ -21,6 +21,6 @@
 int
 __pthread_join (pthread_t threadid, void **thread_return)
 {
-  return __pthread_timedjoin_ex (threadid, thread_return, NULL, true);
+  return __pthread_clockjoin_ex (threadid, thread_return, 0, NULL, true);
 }
 weak_alias (__pthread_join, pthread_join)
diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c
index 9545ae4..1871061 100644
--- a/nptl/pthread_join_common.c
+++ b/nptl/pthread_join_common.c
@@ -36,7 +36,7 @@ cleanup (void *arg)
    afterwards.  The kernel up to version 3.16.3 does not use the private futex
    operations for futex wake-up when the clone terminates.  */
 static int
-timedwait_tid (pid_t *tidp, const struct timespec *abstime)
+clockwait_tid (pid_t *tidp, clockid_t clockid, const struct timespec *abstime)
 {
   pid_t tid;
 
@@ -46,15 +46,17 @@ timedwait_tid (pid_t *tidp, const struct timespec *abstime)
   /* Repeat until thread terminated.  */
   while ((tid = *tidp) != 0)
     {
-      struct timeval tv;
+      struct timespec ts;
       struct timespec rt;
 
-      /* Get the current time.  */
-      __gettimeofday (&tv, NULL);
+      /* Get the current time. This can only fail if clockid is
+         invalid. */
+      if (__glibc_unlikely (__clock_gettime (clockid, &ts)))
+        return EINVAL;
 
       /* Compute relative timeout.  */
-      rt.tv_sec = abstime->tv_sec - tv.tv_sec;
-      rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+      rt.tv_sec = abstime->tv_sec - ts.tv_sec;
+      rt.tv_nsec = abstime->tv_nsec - ts.tv_nsec;
       if (rt.tv_nsec < 0)
         {
           rt.tv_nsec += 1000000000;
@@ -77,7 +79,8 @@ timedwait_tid (pid_t *tidp, const struct timespec *abstime)
 }
 
 int
-__pthread_timedjoin_ex (pthread_t threadid, void **thread_return,
+__pthread_clockjoin_ex (pthread_t threadid, void **thread_return,
+                        clockid_t clockid,
 			const struct timespec *abstime, bool block)
 {
   struct pthread *pd = (struct pthread *) threadid;
@@ -122,7 +125,7 @@ __pthread_timedjoin_ex (pthread_t threadid, void **thread_return,
 
   /* BLOCK waits either indefinitely or based on an absolute time.  POSIX also
      states a cancellation point shall occur for pthread_join, and we use the
-     same rationale for posix_timedjoin_np.  Both timedwait_tid and the futex
+     same rationale for posix_timedjoin_np.  Both clockwait_tid and the futex
      call use the cancellable variant.  */
   if (block)
     {
@@ -132,7 +135,7 @@ __pthread_timedjoin_ex (pthread_t threadid, void **thread_return,
       pthread_cleanup_push (cleanup, &pd->joinid);
 
       if (abstime != NULL)
-	result = timedwait_tid (&pd->tid, abstime);
+	result = clockwait_tid (&pd->tid, clockid, abstime);
       else
 	{
 	  pid_t tid;
@@ -165,4 +168,4 @@ __pthread_timedjoin_ex (pthread_t threadid, void **thread_return,
 
   return result;
 }
-hidden_def (__pthread_timedjoin_ex)
+hidden_def (__pthread_clockjoin_ex)
diff --git a/nptl/pthread_timedjoin.c b/nptl/pthread_timedjoin.c
index bb48a1e..1890d1a 100644
--- a/nptl/pthread_timedjoin.c
+++ b/nptl/pthread_timedjoin.c
@@ -22,6 +22,7 @@ int
 __pthread_timedjoin_np (pthread_t threadid, void **thread_return,
 			const struct timespec *abstime)
 {
-  return __pthread_timedjoin_ex (threadid, thread_return, abstime, true);
+  return __pthread_clockjoin_ex (threadid, thread_return,
+                                 CLOCK_REALTIME, abstime, true);
 }
 weak_alias (__pthread_timedjoin_np, pthread_timedjoin_np)
diff --git a/nptl/pthread_tryjoin.c b/nptl/pthread_tryjoin.c
index 28e765b..ac53956 100644
--- a/nptl/pthread_tryjoin.c
+++ b/nptl/pthread_tryjoin.c
@@ -28,5 +28,5 @@ pthread_tryjoin_np (pthread_t threadid, void **thread_return)
 
   /* If pd->tid == 0 then lll_wait_tid will not block on futex
      operation.  */
-  return __pthread_timedjoin_ex (threadid, thread_return, NULL, false);
+  return __pthread_clockjoin_ex (threadid, thread_return, 0, NULL, false);
 }
diff --git a/nptl/thrd_join.c b/nptl/thrd_join.c
index 497d0d2..10d9a72 100644
--- a/nptl/thrd_join.c
+++ b/nptl/thrd_join.c
@@ -22,7 +22,7 @@ int
 thrd_join (thrd_t thr, int *res)
 {
   void *pthread_res;
-  int err_code = __pthread_timedjoin_ex (thr, &pthread_res, NULL, true);
+  int err_code = __pthread_clockjoin_ex (thr, &pthread_res, 0, NULL, true);
   if (res)
    *res = (int) (uintptr_t) pthread_res;
 
diff --git a/nptl/tst-join10.c b/nptl/tst-join10.c
new file mode 100644
index 0000000..a222dd1
--- /dev/null
+++ b/nptl/tst-join10.c
@@ -0,0 +1,20 @@
+/* Check if pthread_clockjoin_np is a cancellation entrypoint.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define USE_PTHREAD_CLOCKJOIN_NP_REALTIME 1
+#include <nptl/tst-join5.c>
diff --git a/nptl/tst-join11.c b/nptl/tst-join11.c
new file mode 100644
index 0000000..341588a
--- /dev/null
+++ b/nptl/tst-join11.c
@@ -0,0 +1,21 @@
+/* Check if pthread_clockjoin_np is a cancellation entrypoint.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define USE_PTHREAD_CLOCKJOIN_NP_REALTIME 1
+#define WAIT_IN_CHILD 1
+#include <nptl/tst-join5.c>
diff --git a/nptl/tst-join12.c b/nptl/tst-join12.c
new file mode 100644
index 0000000..44592dc
--- /dev/null
+++ b/nptl/tst-join12.c
@@ -0,0 +1,20 @@
+/* Check if pthread_clockjoin_np is a cancellation entrypoint.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC 1
+#include <nptl/tst-join5.c>
diff --git a/nptl/tst-join13.c b/nptl/tst-join13.c
new file mode 100644
index 0000000..d4e49d5
--- /dev/null
+++ b/nptl/tst-join13.c
@@ -0,0 +1,21 @@
+/* Check if pthread_clockjoin_np is a cancellation entrypoint.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC 1
+#define WAIT_IN_CHILD 1
+#include <nptl/tst-join5.c>
diff --git a/nptl/tst-join3.c b/nptl/tst-join3.c
index a4ae459..c06e65a 100644
--- a/nptl/tst-join3.c
+++ b/nptl/tst-join3.c
@@ -28,6 +28,8 @@
 #include <support/xtime.h>
 
 
+#define CLOCK_USE_TIMEDJOIN (-1)
+
 static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
 
 
@@ -35,19 +37,23 @@ static void *
 tf (void *arg)
 {
   xpthread_mutex_lock (&lock);
+  xpthread_mutex_unlock (&lock);
 
   return (void *) 42l;
 }
 
 
 static int
-do_test (void)
+do_test_clock (clockid_t clockid)
 {
+  const clockid_t clockid_for_get =
+    (clockid == CLOCK_USE_TIMEDJOIN) ? CLOCK_REALTIME : clockid;
+
   xpthread_mutex_lock (&lock);
   pthread_t th = xpthread_create (NULL, tf, NULL);
 
   void *status;
-  struct timespec timeout = timespec_add (xclock_now (CLOCK_REALTIME),
+  struct timespec timeout = timespec_add (xclock_now (clockid_for_get),
                                           make_timespec (0, 200000000));
 
   int val = pthread_timedjoin_np (th, &status, &timeout);
@@ -57,10 +63,13 @@ do_test (void)
 
   while (1)
     {
-      timeout = timespec_add (xclock_now (CLOCK_REALTIME),
+      timeout = timespec_add (xclock_now (clockid_for_get),
                               make_timespec (0, 200000000));
 
-      val = pthread_timedjoin_np (th, &status, &timeout);
+      if (clockid == CLOCK_USE_TIMEDJOIN)
+        val = pthread_timedjoin_np (th, &status, &timeout);
+      else
+        val = pthread_clockjoin_np (th, &status, clockid, &timeout);
       if (val == 0)
 	break;
 
@@ -73,4 +82,13 @@ do_test (void)
   return 0;
 }
 
+static int
+do_test (void)
+{
+  do_test_clock (CLOCK_USE_TIMEDJOIN);
+  do_test_clock (CLOCK_REALTIME);
+  do_test_clock (CLOCK_MONOTONIC);
+  return 0;
+}
+
 #include <support/test-driver.c>
diff --git a/nptl/tst-join5.c b/nptl/tst-join5.c
index 41cacf1..1ee765c 100644
--- a/nptl/tst-join5.c
+++ b/nptl/tst-join5.c
@@ -24,7 +24,9 @@
 #include <unistd.h>
 
 #include <support/check.h>
+#include <support/timespec.h>
 #include <support/xthread.h>
+#include <support/xtime.h>
 
 static void
 wait_code (void)
@@ -42,12 +44,18 @@ static pthread_barrier_t b;
 static int
 thread_join (pthread_t thread, void **retval)
 {
-#ifdef USE_PTHREAD_TIMEDJOIN_NP
-  struct timespec tv;
-  TEST_COMPARE (clock_gettime (CLOCK_REALTIME, &tv), 0);
-  /* Arbitrary large timeout to make it act as pthread_join.  */
-  tv.tv_sec += 1000;
-  return pthread_timedjoin_np ((pthread_t) thread, retval, &tv);
+#if defined USE_PTHREAD_TIMEDJOIN_NP
+  const struct timespec ts = timespec_add (xclock_now (CLOCK_REALTIME),
+                                           make_timespec (1000, 0));
+  return pthread_timedjoin_np ((pthread_t) thread, retval, &ts);
+#elif defined USE_PTHREAD_CLOCKJOIN_NP_REALTIME
+  const struct timespec ts = timespec_add (xclock_now (CLOCK_REALTIME),
+                                           make_timespec (1000, 0));
+  return pthread_clockjoin_np ((pthread_t) thread, retval, CLOCK_REALTIME, &ts);
+#elif defined USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC
+  const struct timespec ts = timespec_add (xclock_now (CLOCK_MONOTONIC),
+                                           make_timespec (1000, 0));
+  return pthread_clockjoin_np ((pthread_t) thread, retval, CLOCK_MONOTONIC, &ts);
 #else
   return pthread_join ((pthread_t) thread, retval);
 #endif
diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h
index ceb724d..35be74e 100644
--- a/sysdeps/nptl/pthread.h
+++ b/sysdeps/nptl/pthread.h
@@ -263,6 +263,17 @@ extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
    __THROW.  */
 extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
 				 const struct timespec *__abstime);
+
+/* Make calling thread wait for termination of the thread TH, but only
+   until TIMEOUT measured against the clock specified by CLOCKID.  The
+   exit status of the thread is stored in *THREAD_RETURN, if
+   THREAD_RETURN is not NULL.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int pthread_clockjoin_np (pthread_t __th, void **__thread_return,
+                                 clockid_t clockid,
+				 const struct timespec *__abstime);
 #endif
 
 /* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
diff --git a/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist b/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
index cdc3ad5..e96fe0d 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
@@ -239,3 +239,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
diff --git a/sysdeps/unix/sysv/linux/alpha/libpthread.abilist b/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
index e2c8832..4e34197 100644
--- a/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
@@ -251,6 +251,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libpthread.abilist b/sysdeps/unix/sysv/linux/arm/be/libpthread.abilist
index db670ef..01d8712 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libpthread.abilist
@@ -32,6 +32,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 _IO_flockfile F
 GLIBC_2.4 _IO_ftrylockfile F
 GLIBC_2.4 _IO_funlockfile F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libpthread.abilist b/sysdeps/unix/sysv/linux/arm/le/libpthread.abilist
index db670ef..01d8712 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libpthread.abilist
@@ -32,6 +32,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 _IO_flockfile F
 GLIBC_2.4 _IO_ftrylockfile F
 GLIBC_2.4 _IO_funlockfile F
diff --git a/sysdeps/unix/sysv/linux/csky/libpthread.abilist b/sysdeps/unix/sysv/linux/csky/libpthread.abilist
index 44eedc7..44383c6 100644
--- a/sysdeps/unix/sysv/linux/csky/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libpthread.abilist
@@ -232,3 +232,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
diff --git a/sysdeps/unix/sysv/linux/hppa/libpthread.abilist b/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
index 5454761..522356c 100644
--- a/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
@@ -241,6 +241,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/i386/libpthread.abilist b/sysdeps/unix/sysv/linux/i386/libpthread.abilist
index f9e7821..d38b44f 100644
--- a/sysdeps/unix/sysv/linux/i386/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libpthread.abilist
@@ -249,6 +249,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/ia64/libpthread.abilist b/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
index 5be0e0f..8772654 100644
--- a/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
@@ -243,6 +243,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
index db670ef..01d8712 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
@@ -32,6 +32,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 _IO_flockfile F
 GLIBC_2.4 _IO_ftrylockfile F
 GLIBC_2.4 _IO_funlockfile F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
index f9e7821..d38b44f 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
@@ -249,6 +249,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist
index 7bee5b4..300d8de 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist
@@ -239,3 +239,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist
index 7bee5b4..300d8de 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist
@@ -239,3 +239,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist b/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
index e0390a6..68af03b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
@@ -250,6 +250,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist b/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
index e0390a6..68af03b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
@@ -250,6 +250,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/nios2/libpthread.abilist b/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
index 21abc95..6c26192 100644
--- a/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
@@ -239,3 +239,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
index c410fa8..55f3161 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
@@ -251,6 +251,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist
index a0a8058..475eec2 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist
@@ -242,6 +242,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist
index cdc3ad5..e96fe0d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist
@@ -239,3 +239,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist
index aa6f793..94b478e 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist
@@ -234,3 +234,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
index c504fbf..c9c833d 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
@@ -251,6 +251,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
index 933f202..5bfa892 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
@@ -243,6 +243,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libpthread.abilist b/sysdeps/unix/sysv/linux/sh/be/libpthread.abilist
index 5454761..522356c 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libpthread.abilist
@@ -241,6 +241,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libpthread.abilist b/sysdeps/unix/sysv/linux/sh/le/libpthread.abilist
index 5454761..522356c 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libpthread.abilist
@@ -241,6 +241,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
index e2c8832..4e34197 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
@@ -251,6 +251,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
index 5be0e0f..8772654 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
@@ -243,6 +243,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
index 87be582..72a9396 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
@@ -241,6 +241,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
 GLIBC_2.4 pthread_mutex_consistent_np F
 GLIBC_2.4 pthread_mutex_getprioceiling F
 GLIBC_2.4 pthread_mutex_setprioceiling F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
index 5539c4e..6b80eda 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
@@ -239,3 +239,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
 GLIBC_2.30 pthread_rwlock_clockrdlock F
 GLIBC_2.30 pthread_rwlock_clockwrlock F
 GLIBC_2.30 sem_clockwait F
+GLIBC_2.31 pthread_clockjoin_np F
-- 
git-series 0.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 4/4] nptl: Add pthread_timedjoin_np, pthread_clockjoin_np NULL timeout test
  2019-09-18 12:30 [PATCH v2 0/4] nptl: Add pthread_clockjoin_np Mike Crowe
                   ` (2 preceding siblings ...)
  2019-09-18 12:30 ` [PATCH v2 3/4] nptl: Add pthread_clockjoin_np Mike Crowe
@ 2019-09-18 12:30 ` Mike Crowe
  2019-09-26 23:30   ` Adhemerval Zanella
  2019-10-31 14:31 ` [PATCH v2 0/4] nptl: Add pthread_clockjoin_np Adhemerval Zanella
  4 siblings, 1 reply; 23+ messages in thread
From: Mike Crowe @ 2019-09-18 12:30 UTC (permalink / raw)
  To: libc-alpha; +Cc: Mike Crowe

Passing NULL as the timeout parameter to pthread_timedjoin_np has resulted
in it behaving like pthread_join for a long time. Since that is now the
documented behaviour, we ought to test that both it and the new
pthread_clockjoin_np support it.

	* nptl/tst-join14.c: Test passing NULL as abstime parameter of
	pthread_timedjoin_np and pthread_clockjoin_np.
	* nptl/Makefile: Add tst-join14.c.
---
 ChangeLog         |  5 +++-
 nptl/Makefile     |  1 +-
 nptl/tst-join14.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 79 insertions(+)
 create mode 100644 nptl/tst-join14.c

diff --git a/ChangeLog b/ChangeLog
index 8a2166d..048c4b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
 2019-09-18  Mike Crowe  <mac@mcrowe.com>
+	* nptl/tst-join14.c: Test passing NULL as abstime parameter of
+	pthread_timedjoin_np and pthread_clockjoin_np.
+	* nptl/Makefile: Add tst-join14.c.
+
+2019-09-18  Mike Crowe  <mac@mcrowe.com>
 	* NEWS: Mention addition of pthread_clockjoin_np along with other
 	"clock" variants of existing "timed" functions.
 	* sysdeps/nptl/pthread.h: Add declaration of pthread_clockjoin_np.
diff --git a/nptl/Makefile b/nptl/Makefile
index 5521a58..3e05b79 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -275,6 +275,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
 	tst-raise1 \
 	tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 tst-join6 tst-join7 \
 	tst-join8 tst-join9 tst-join10 tst-join11 tst-join12 tst-join13 \
+	tst-join14 \
 	tst-detach1 \
 	tst-eintr2 tst-eintr3 tst-eintr4 tst-eintr5 \
 	tst-tsd1 tst-tsd2 tst-tsd3 tst-tsd4 tst-tsd5 tst-tsd6 \
diff --git a/nptl/tst-join14.c b/nptl/tst-join14.c
new file mode 100644
index 0000000..261b919
--- /dev/null
+++ b/nptl/tst-join14.c
@@ -0,0 +1,73 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <support/check.h>
+#include <support/timespec.h>
+#include <support/xthread.h>
+#include <support/xtime.h>
+
+
+#define CLOCK_USE_TIMEDJOIN (-1)
+
+
+static void *
+tf (void *arg)
+{
+  struct timespec ts = make_timespec(0, 100000);
+  nanosleep(&ts, NULL);
+
+  return (void *) 42l;
+}
+
+
+/* Check that pthread_timedjoin_np and pthread_clockjoin_np wait "forever" if
+ * passed a timeout parameter of NULL. We can't actually wait forever, but we
+ * can be sure that we did at least wait for some time by checking the exit
+ * status of the thread. */
+static int
+do_test_clock (clockid_t clockid)
+{
+  pthread_t th = xpthread_create (NULL, tf, NULL);
+
+  void *status;
+  int val = (clockid == CLOCK_USE_TIMEDJOIN)
+    ? pthread_timedjoin_np (th, &status, NULL)
+    : pthread_clockjoin_np (th, &status, clockid, NULL);
+  TEST_COMPARE (val, 0);
+
+  if (status != (void *) 42l)
+    FAIL_EXIT1 ("return value %p, expected %p\n", status, (void *) 42l);
+
+  return 0;
+}
+
+static int
+do_test (void)
+{
+  do_test_clock (CLOCK_USE_TIMEDJOIN);
+  do_test_clock (CLOCK_REALTIME);
+  do_test_clock (CLOCK_MONOTONIC);
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
git-series 0.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 1/4] nptl: Convert tst-join3 to use libsupport
  2019-09-18 12:30 ` [PATCH v2 1/4] nptl: Convert tst-join3 to use libsupport Mike Crowe
@ 2019-09-26 20:45   ` Adhemerval Zanella
  0 siblings, 0 replies; 23+ messages in thread
From: Adhemerval Zanella @ 2019-09-26 20:45 UTC (permalink / raw)
  To: libc-alpha



On 18/09/2019 05:30, Mike Crowe wrote:
> * nptl/tst-join3.c: Use libsupport.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

> ---
>  ChangeLog        |  4 ++-
>  nptl/tst-join3.c | 86 +++++++++++--------------------------------------
>  2 files changed, 24 insertions(+), 66 deletions(-)
> 
> diff --git a/ChangeLog b/ChangeLog
> index adc93a7..d7943ff 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,7 @@
> +2019-09-18  Mike Crowe  <mac@mcrowe.com>
> +
> +	* nptl/tst-join3.c: Use libsupport.
> +
>  2019-09-18  Stefan Liebler  <stli@linux.ibm.com>
>  
>  	* elf/tst-pldd.c (do_test): Add UNSUPPORTED check.
> diff --git a/nptl/tst-join3.c b/nptl/tst-join3.c
> index d8785c5..a4ae459 100644
> --- a/nptl/tst-join3.c
> +++ b/nptl/tst-join3.c
> @@ -22,6 +22,10 @@
>  #include <stdlib.h>
>  #include <string.h>
>  #include <sys/time.h>
> +#include <support/check.h>
> +#include <support/timespec.h>
> +#include <support/xthread.h>
> +#include <support/xtime.h>
>  
>  
>  static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
> @@ -30,11 +34,7 @@ static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
>  static void *
>  tf (void *arg)
>  {
> -  if (pthread_mutex_lock (&lock) != 0)
> -    {
> -      puts ("child: mutex_lock failed");
> -      return NULL;
> -    }
> +  xpthread_mutex_lock (&lock);
>  
>    return (void *) 42l;
>  }

Ok.

> @@ -43,80 +43,34 @@ tf (void *arg)
>  static int
>  do_test (void)
>  {
> -  pthread_t th;
> -
> -  if (pthread_mutex_lock (&lock) != 0)
> -    {
> -      puts ("mutex_lock failed");
> -      exit (1);
> -    }
> -
> -  if (pthread_create (&th, NULL, tf, NULL) != 0)
> -    {
> -      puts ("mutex_create failed");
> -      exit (1);
> -    }
> +  xpthread_mutex_lock (&lock);
> +  pthread_t th = xpthread_create (NULL, tf, NULL);
>  

Ok.

>    void *status;
> -  struct timespec ts;
> -  struct timeval tv;
> -  (void) gettimeofday (&tv, NULL);
> -  TIMEVAL_TO_TIMESPEC (&tv, &ts);
> -  ts.tv_nsec += 200000000;
> -  if (ts.tv_nsec >= 1000000000)
> -    {
> -      ts.tv_nsec -= 1000000000;
> -      ++ts.tv_sec;
> -    }
> -  int val = pthread_timedjoin_np (th, &status, &ts);
> -  if (val == 0)
> -    {
> -      puts ("1st timedjoin succeeded");
> -      exit (1);
> -    }
> -  else if (val != ETIMEDOUT)
> -    {
> -      puts ("1st timedjoin didn't return ETIMEDOUT");
> -      exit (1);
> -    }
> +  struct timespec timeout = timespec_add (xclock_now (CLOCK_REALTIME),
> +                                          make_timespec (0, 200000000));

Ok.

>  
> -  if (pthread_mutex_unlock (&lock) != 0)
> -    {
> -      puts ("mutex_unlock failed");
> -      exit (1);
> -    }
> +  int val = pthread_timedjoin_np (th, &status, &timeout);
> +  TEST_COMPARE (val, ETIMEDOUT);
> +
> +  xpthread_mutex_unlock (&lock);
>  
>    while (1)
>      {
> -      (void) gettimeofday (&tv, NULL);
> -      TIMEVAL_TO_TIMESPEC (&tv, &ts);
> -      ts.tv_nsec += 200000000;
> -      if (ts.tv_nsec >= 1000000000)
> -	{
> -	  ts.tv_nsec -= 1000000000;
> -	  ++ts.tv_sec;
> -	}
> -
> -      val = pthread_timedjoin_np (th, &status, &ts);
> +      timeout = timespec_add (xclock_now (CLOCK_REALTIME),
> +                              make_timespec (0, 200000000));
> +
> +      val = pthread_timedjoin_np (th, &status, &timeout);
>        if (val == 0)
>  	break;
>  

Ok.

> -      if (val != ETIMEDOUT)
> -	{
> -	  printf ("timedjoin returned %s (%d), expected only 0 or ETIMEDOUT\n",
> -		  strerror (val), val);
> -	  exit (1);
> -	}
> +      TEST_COMPARE (val, ETIMEDOUT);

Ok.

>      }
>  
>    if (status != (void *) 42l)
> -    {
> -      printf ("return value %p, expected %p\n", status, (void *) 42l);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("return value %p, expected %p\n", status, (void *) 42l);
>  
>    return 0;
>  }>  
> -#define TEST_FUNCTION do_test ()
> -#include "../test-skeleton.c"
> +#include <support/test-driver.c>
> 

Ok.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 2/4] manual: Add documentation for pthread_tryjoin_np and pthread_timedjoin_np
  2019-09-18 12:30 ` [PATCH v2 2/4] manual: Add documentation for pthread_tryjoin_np and pthread_timedjoin_np Mike Crowe
@ 2019-09-26 21:26   ` Adhemerval Zanella
  2019-09-27  9:08     ` Yann Droneaud
  2019-09-28  8:53     ` Mike Crowe
  0 siblings, 2 replies; 23+ messages in thread
From: Adhemerval Zanella @ 2019-09-26 21:26 UTC (permalink / raw)
  To: libc-alpha



On 18/09/2019 05:30, Mike Crowe wrote:
> This documentation isn't perfect, but it's better than nothing and can
> hopefully act as a basis for future improvement. In particular, although
> I'm certain that the functions are MT-Safe, I'm not sure about the rest of
> the @safety line.
> 
> Yann Droneaud pointed out that pthread_timedjoin_np would wait forever if
> the timeout parameter is passed as NULL. Since it's now too late to change
> that, I've documented it.

To which semantic do you think it would be better to change? Since this
symbol are not yet in POSIX there still the possibility to change it
by using a new plus a compat symbol.

> 
> 	* manual/threads.texi: Add brief documentation for
> 	pthread_tryjoin_np and pthread_timedjoin_np.

LGTM, thanks.

> ---
>  ChangeLog           |  5 +++++
>  manual/threads.texi | 26 ++++++++++++++++++++++++--
>  2 files changed, 29 insertions(+), 2 deletions(-)
> 
> diff --git a/ChangeLog b/ChangeLog
> index d7943ff..94ee860 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,5 +1,10 @@
>  2019-09-18  Mike Crowe  <mac@mcrowe.com>
>  
> +	* manual/threads.texi: Add brief documentation for
> +	pthread_tryjoin_np and pthread_timedjoin_np.
> +
> +2019-09-18  Mike Crowe  <mac@mcrowe.com>
> +
>  	* nptl/tst-join3.c: Use libsupport.
>  
>  2019-09-18  Stefan Liebler  <stli@linux.ibm.com>
> diff --git a/manual/threads.texi b/manual/threads.texi
> index 0e5e84a..8dcfc53 100644
> --- a/manual/threads.texi
> +++ b/manual/threads.texi
> @@ -727,6 +727,30 @@ rather than @code{CLOCK_REALTIME}.  Currently, @var{clockid} must be either
>  returned.
>  @end deftypefun
>  
> +@comment pthread.h
> +@comment GNU extension
> +@deftypefun int pthread_tryjoin_np (pthread_t *@var{thread},
> +				      void **@var{thread_return})
> +@standards{GNU, pthread.h}
> +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
> +Behaves like @code{pthread_join} except that it will return @code{EBUSY}
> +immediately if the thread specified by @var{thread} has not yet terminated.
> +@end deftypefun
> +

Ok.

> +@comment pthread.h
> +@comment GNU extension
> +@deftypefun int pthread_timedjoin_np (pthread_t *@var{thread},
> +				      void **@var{thread_return},
> +				      const struct timespec *@var{abstime})
> +@standards{GNU, pthread.h}
> +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
> +Behaves like @code{pthread_tryjoin_np} except that it will block until the
> +absolute time @var{abstime} measured against @code{CLOCK_REALTIME} is
> +reached if the thread has not terminated by that time and return
> +@code{EBUSY}. If @var{abstime} is equal to @code{NULL} then the function
> +will wait forever in the same way as @code{pthread_join}.
> +@end deftypefun
> +
>  @c FIXME these are undocumented:
>  @c pthread_atfork
>  @c pthread_attr_destroy
> @@ -844,6 +868,4 @@ returned.
>  @c pthread_spin_trylock
>  @c pthread_spin_unlock
>  @c pthread_testcancel
> -@c pthread_timedjoin_np
> -@c pthread_tryjoin_np
>  @c pthread_yield
> 

Ok.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 3/4] nptl: Add pthread_clockjoin_np
  2019-09-18 12:30 ` [PATCH v2 3/4] nptl: Add pthread_clockjoin_np Mike Crowe
@ 2019-09-26 23:17   ` Adhemerval Zanella
  2019-09-28 19:45     ` Mike Crowe
  2019-10-08  8:26   ` Mike Crowe
  1 sibling, 1 reply; 23+ messages in thread
From: Adhemerval Zanella @ 2019-09-26 23:17 UTC (permalink / raw)
  To: libc-alpha



On 18/09/2019 05:30, Mike Crowe wrote:
> Introduce pthread_clockjoin_np as a version of pthread_timedjoin_np that
> accepts a clockid_t parameter to indicate which clock the timeout should be
> measured against. This mirrors the recently-added POSIX-proposed "clock"
> wait functions.

I see the addition begin reasonable now that we are also providing similar
functions for mutexes, conditional variables, read-write locks, and
semaphores.

> 
> 	* NEWS: Mention addition of pthread_clockjoin_np along with other
> 	"clock" variants of existing "timed" functions.
> 	* sysdeps/nptl/pthread.h: Add declaration of pthread_clockjoin_np.
> 	* manual/threads.texi: Add pthread_clockjoin_np.
> 	* nptl/Makefile: Add pthread_clockjoin source file.  Add new join
> 	tests.
> 	* nptl/Versions: Add pthread_clockjoin_np.
> 	* nptl/PthreadP.h: Rename __pthread_timedjoin_ex to
> 	__pthread_clockjoin_ex and add clockid_t parameter.
> 	* nptl/pthread_clockjoin.c: New file to implement pthread_clockjoin_np.
> 	* nptl/pthread_join_common.c (clockwait_tid): Rename from
> 	timedwait_tid and add clockid parameter.  Use __clock_gettime
> 	passing supplied clockid rather than using __gettimeofday.  Perform
> 	relative timeout calculation entirely in timespec.
> 	(__pthread_clockjoin_ex): Rename from __pthread_timedjoin_ex and
> 	add clockid parameter to pass to clockwait_tid rather than
> 	timedwait_tid.
> 	* nptl/pthread_timedjoin.c (__pthread_timedjoin_np): Call
> 	__pthread_clockjoin_ex passing CLOCK_REALTIME as clockid.
> 	* nptl/pthread_join.c (__pthread_join): Call __pthread_clockjoin_ex
> 	and pass zero as unused clockid_t parameter.
> 	* nptl/pthread_tryjoin.c (__pthread_tryjoin_np): Likewise.
> 	* nptl/thrd_join.c (thrd_join): Likewise.
> 	* nptl/tst-join3.c (tf): Ensure that mutex is unlocked after use so
> 	that it can be used again.  (do_test_clock): Rename from do_test and
> 	accept a clock parameter.  (do_test): Test pthread_timedjoin_np,
> 	pthread_clockjoin_np with CLOCK_REALTIME and pthread_clockjoin_np
> 	with CLOCK_MONOTONIC.
> 	* nptl/tst-join5.c (thread_join): Add support for testing
> 	pthread_clockjoin_np with both CLOCK_REALTIME and CLOCK_MONOTONIC.
> 	* nptl/tst-join10.c: Wrap tst-join5.c with
> 	USE_PTHREAD_CLOCKJOIN_NP_REALTIME.
> 	* nptl/tst-join11.c: Wrap tst-join5.c with
> 	USE_PTHREAD_CLOCKJOIN_NP_REALTIME and WAIT_IN_CHILD.
> 	* nptl/tst-join12.c: Wrap tst-join5.c with
> 	USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC.
> 	* nptl/tst-join13.c: Wrap tst-join5.c with
> 	USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC and WAIT_IN_CHILD.
> 	* sysdeps/unix/sysv/linux/aarch64/libpthread.abilist: Add
> 	pthread_clockjoin_np.
> 	* sysdeps/unix/sysv/linux/alpha/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/arm/be/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/arm/le/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/csky/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/hppa/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/i386/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/ia64/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/nios2/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist:
> 	Likewise.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist:
> 	Likewise.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist:
> 	Likewise.
> 	* sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/sh/be/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/sh/le/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist: Likewise.
> 	* sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist: Likewise.

LGTM with some nits below.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

> ---
>  ChangeLog                                                       | 71 +++++++-
>  NEWS                                                            |  9 +-
>  manual/threads.texi                                             | 12 +-
>  nptl/Makefile                                                   |  5 +-
>  nptl/Versions                                                   |  4 +-
>  nptl/pthreadP.h                                                 |  5 +-
>  nptl/pthread_clockjoin.c                                        | 28 +++-
>  nptl/pthread_join.c                                             |  2 +-
>  nptl/pthread_join_common.c                                      | 23 +-
>  nptl/pthread_timedjoin.c                                        |  3 +-
>  nptl/pthread_tryjoin.c                                          |  2 +-
>  nptl/thrd_join.c                                                |  2 +-
>  nptl/tst-join10.c                                               | 20 ++-
>  nptl/tst-join11.c                                               | 21 ++-
>  nptl/tst-join12.c                                               | 20 ++-
>  nptl/tst-join13.c                                               | 21 ++-
>  nptl/tst-join3.c                                                | 26 ++-
>  nptl/tst-join5.c                                                | 20 +-
>  sysdeps/nptl/pthread.h                                          | 11 +-
>  sysdeps/unix/sysv/linux/aarch64/libpthread.abilist              |  1 +-
>  sysdeps/unix/sysv/linux/alpha/libpthread.abilist                |  1 +-
>  sysdeps/unix/sysv/linux/arm/be/libpthread.abilist               |  1 +-
>  sysdeps/unix/sysv/linux/arm/le/libpthread.abilist               |  1 +-
>  sysdeps/unix/sysv/linux/csky/libpthread.abilist                 |  1 +-
>  sysdeps/unix/sysv/linux/hppa/libpthread.abilist                 |  1 +-
>  sysdeps/unix/sysv/linux/i386/libpthread.abilist                 |  1 +-
>  sysdeps/unix/sysv/linux/ia64/libpthread.abilist                 |  1 +-
>  sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist        |  1 +-
>  sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist          |  1 +-
>  sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist        |  1 +-
>  sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist        |  1 +-
>  sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist          |  1 +-
>  sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist          |  1 +-
>  sysdeps/unix/sysv/linux/nios2/libpthread.abilist                |  1 +-
>  sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist    |  1 +-
>  sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist |  1 +-
>  sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist |  1 +-
>  sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist           |  1 +-
>  sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist         |  1 +-
>  sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist         |  1 +-
>  sysdeps/unix/sysv/linux/sh/be/libpthread.abilist                |  1 +-
>  sysdeps/unix/sysv/linux/sh/le/libpthread.abilist                |  1 +-
>  sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist        |  1 +-
>  sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist        |  1 +-
>  sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist            |  1 +-
>  sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist           |  1 +-
>  46 files changed, 300 insertions(+), 32 deletions(-)
>  create mode 100644 nptl/pthread_clockjoin.c
>  create mode 100644 nptl/tst-join10.c
>  create mode 100644 nptl/tst-join11.c
>  create mode 100644 nptl/tst-join12.c
>  create mode 100644 nptl/tst-join13.c
> 
> diff --git a/ChangeLog b/ChangeLog
> index 94ee860..8a2166d 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,4 +1,75 @@
>  2019-09-18  Mike Crowe  <mac@mcrowe.com>
> +	* NEWS: Mention addition of pthread_clockjoin_np along with other
> +	"clock" variants of existing "timed" functions.
> +	* sysdeps/nptl/pthread.h: Add declaration of pthread_clockjoin_np.
> +	* manual/threads.texi: Add pthread_clockjoin_np.
> +	* nptl/Makefile: Add pthread_clockjoin source file.  Add new join
> +	tests.
> +	* nptl/Versions: Add pthread_clockjoin_np.
> +	* nptl/PthreadP.h: Rename __pthread_timedjoin_ex to
> +	__pthread_clockjoin_ex and add clockid_t parameter.
> +	* nptl/pthread_clockjoin.c: New file to implement pthread_clockjoin_np.
> +	* nptl/pthread_join_common.c (clockwait_tid): Rename from
> +	timedwait_tid and add clockid parameter.  Use __clock_gettime
> +	passing supplied clockid rather than using __gettimeofday.  Perform
> +	relative timeout calculation entirely in timespec.
> +	(__pthread_clockjoin_ex): Rename from __pthread_timedjoin_ex and
> +	add clockid parameter to pass to clockwait_tid rather than
> +	timedwait_tid.
> +	* nptl/pthread_timedjoin.c (__pthread_timedjoin_np): Call
> +	__pthread_clockjoin_ex passing CLOCK_REALTIME as clockid.
> +	* nptl/pthread_join.c (__pthread_join): Call __pthread_clockjoin_ex
> +	and pass zero as unused clockid_t parameter.
> +	* nptl/pthread_tryjoin.c (__pthread_tryjoin_np): Likewise.
> +	* nptl/thrd_join.c (thrd_join): Likewise.
> +	* nptl/tst-join3.c (tf): Ensure that mutex is unlocked after use so
> +	that it can be used again.  (do_test_clock): Rename from do_test and
> +	accept a clock parameter.  (do_test): Test pthread_timedjoin_np,
> +	pthread_clockjoin_np with CLOCK_REALTIME and pthread_clockjoin_np
> +	with CLOCK_MONOTONIC.
> +	* nptl/tst-join5.c (thread_join): Add support for testing
> +	pthread_clockjoin_np with both CLOCK_REALTIME and CLOCK_MONOTONIC.
> +	* nptl/tst-join10.c: Wrap tst-join5.c with
> +	USE_PTHREAD_CLOCKJOIN_NP_REALTIME.
> +	* nptl/tst-join11.c: Wrap tst-join5.c with
> +	USE_PTHREAD_CLOCKJOIN_NP_REALTIME and WAIT_IN_CHILD.
> +	* nptl/tst-join12.c: Wrap tst-join5.c with
> +	USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC.
> +	* nptl/tst-join13.c: Wrap tst-join5.c with
> +	USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC and WAIT_IN_CHILD.
> +	* sysdeps/unix/sysv/linux/aarch64/libpthread.abilist: Add
> +	pthread_clockjoin_np.
> +	* sysdeps/unix/sysv/linux/alpha/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/arm/be/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/arm/le/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/csky/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/hppa/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/i386/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/ia64/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/nios2/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist:
> +	Likewise.
> +	* sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist:
> +	Likewise.
> +	* sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist:
> +	Likewise.
> +	* sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/sh/be/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/sh/le/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist: Likewise.
> +	* sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist: Likewise.
> +
> +2019-09-18  Mike Crowe  <mac@mcrowe.com>
>  
>  	* manual/threads.texi: Add brief documentation for
>  	pthread_tryjoin_np and pthread_timedjoin_np.
> diff --git a/NEWS b/NEWS
> index d728684..bb1b07a 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -81,10 +81,11 @@ Major new features:
>  
>  * Add new POSIX-proposed pthread_cond_clockwait, pthread_mutex_clocklock,
>    pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock and sem_clockwait
> -  functions.  These behave similarly to their "timed" equivalents, but also
> -  accept a clockid_t parameter to determine which clock their timeout should
> -  be measured against.  All functions allow waiting against CLOCK_MONOTONIC
> -  and CLOCK_REALTIME.  The decision of which clock to be used is made at the
> +  functions along with glibc-specific pthread_clockjoin_np.  These behave
> +  similarly to their "timed" equivalents, but also accept a clockid_t
> +  parameter to determine which clock their timeout should be measured
> +  against.  All functions allow waiting against CLOCK_MONOTONIC and
> +  CLOCK_REALTIME.  The decision of which clock to be used is made at the
>    time of the wait (unlike with pthread_condattr_setclock, which requires
>    the clock choice at initialization time).

This will need to be a new point in 2.31 entry, with the text adjusted 
accordingly. 

>  
> diff --git a/manual/threads.texi b/manual/threads.texi
> index 8dcfc53..0055025 100644
> --- a/manual/threads.texi
> +++ b/manual/threads.texi
> @@ -751,6 +751,18 @@ reached if the thread has not terminated by that time and return
>  will wait forever in the same way as @code{pthread_join}.
>  @end deftypefun
>  
> +@comment pthread.h
> +@comment GNU extension
> +@deftypefun int pthread_clockjoin_np (pthread_t *@var{thread},
> +				      void **@var{thread_return},
> +                                      clockid_t @var{clockid},
> +				      const struct timespec *@var{abstime})
> +@standards{GNU, pthread.h}
> +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
> +Behaves like @code{pthread_timedjoin_np} except that time absolute time in
> +@var{abstime} is measured against the clock specified by @var{clockid}.
> +@end deftypefun
> +
>  @c FIXME these are undocumented:
>  @c pthread_atfork
>  @c pthread_attr_destroy

Ok.

> diff --git a/nptl/Makefile b/nptl/Makefile
> index 66f89f1..5521a58 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile
> @@ -51,7 +51,7 @@ pthread-compat-wrappers = \
>  libpthread-routines = nptl-init nptlfreeres vars events version pt-interp \
>  		      pthread_create pthread_exit pthread_detach \
>  		      pthread_join pthread_tryjoin pthread_timedjoin \
> -		      pthread_join_common pthread_yield \
> +		      pthread_clockjoin pthread_join_common pthread_yield \
>  		      pthread_getconcurrency pthread_setconcurrency \
>  		      pthread_getschedparam pthread_setschedparam \
>  		      pthread_setschedprio \

Ok.

> @@ -189,6 +189,7 @@ CFLAGS-forward.c += -fexceptions
>  CFLAGS-pthread_testcancel.c += -fexceptions
>  CFLAGS-pthread_join.c += -fexceptions -fasynchronous-unwind-tables
>  CFLAGS-pthread_timedjoin.c += -fexceptions -fasynchronous-unwind-tables
> +CFLAGS-pthread_clockjoin.c += -fexceptions -fasynchronous-unwind-tables
>  CFLAGS-pthread_once.c += $(uses-callbacks) -fexceptions \
>  			-fasynchronous-unwind-tables
>  CFLAGS-pthread_cond_wait.c += -fexceptions -fasynchronous-unwind-tables
> @@ -273,7 +274,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
>  	tst-kill1 tst-kill2 tst-kill3 tst-kill4 tst-kill5 tst-kill6 \
>  	tst-raise1 \
>  	tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 tst-join6 tst-join7 \
> -	tst-join8 tst-join9 \
> +	tst-join8 tst-join9 tst-join10 tst-join11 tst-join12 tst-join13 \
>  	tst-detach1 \
>  	tst-eintr2 tst-eintr3 tst-eintr4 tst-eintr5 \
>  	tst-tsd1 tst-tsd2 tst-tsd3 tst-tsd4 tst-tsd5 tst-tsd6 \

Ok.

> diff --git a/nptl/Versions b/nptl/Versions
> index 6f4d74f..c169400 100644
> --- a/nptl/Versions
> +++ b/nptl/Versions
> @@ -279,6 +279,10 @@ libpthread {
>      pthread_mutex_clocklock;
>    }
>  
> +  GLIBC_2.31 {
> +    pthread_clockjoin_np;
> +  }
> +
>    GLIBC_PRIVATE {
>      __pthread_initialize_minimal;
>      __pthread_clock_gettime; __pthread_clock_settime;

Ok.

> diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
> index 070b3af..19bd544 100644
> --- a/nptl/pthreadP.h
> +++ b/nptl/pthreadP.h
> @@ -475,7 +475,8 @@ extern int __pthread_setcanceltype (int type, int *oldtype);
>  extern int __pthread_enable_asynccancel (void) attribute_hidden;
>  extern void __pthread_disable_asynccancel (int oldtype) attribute_hidden;
>  extern void __pthread_testcancel (void);
> -extern int __pthread_timedjoin_ex (pthread_t, void **, const struct timespec *,
> +extern int __pthread_clockjoin_ex (pthread_t, void **,
> +                                   clockid_t, const struct timespec *,
>  				   bool);
>  
>  #if IS_IN (libpthread)
> @@ -495,7 +496,7 @@ hidden_proto (__pthread_setcancelstate)
>  hidden_proto (__pthread_testcancel)
>  hidden_proto (__pthread_mutexattr_init)
>  hidden_proto (__pthread_mutexattr_settype)
> -hidden_proto (__pthread_timedjoin_ex)
> +hidden_proto (__pthread_clockjoin_ex)
>  #endif
>  
>  extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond);

Ok.

> diff --git a/nptl/pthread_clockjoin.c b/nptl/pthread_clockjoin.c
> new file mode 100644
> index 0000000..fc1ef18
> --- /dev/null
> +++ b/nptl/pthread_clockjoin.c
> @@ -0,0 +1,28 @@

It misses the one line file description.

> +/* Copyright (C) 2019 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#include "pthreadP.h"
> +
> +int
> +__pthread_clockjoin_np (pthread_t threadid, void **thread_return,
> +			clockid_t clockid,
> +			const struct timespec *abstime)
> +{
> +  return __pthread_clockjoin_ex (threadid, thread_return,
> +                                 clockid, abstime, true);
> +}
> +weak_alias (__pthread_clockjoin_np, pthread_clockjoin_np)

Ok.

> diff --git a/nptl/pthread_join.c b/nptl/pthread_join.c
> index 3523b20..e189155 100644
> --- a/nptl/pthread_join.c
> +++ b/nptl/pthread_join.c
> @@ -21,6 +21,6 @@
>  int
>  __pthread_join (pthread_t threadid, void **thread_return)
>  {
> -  return __pthread_timedjoin_ex (threadid, thread_return, NULL, true);
> +  return __pthread_clockjoin_ex (threadid, thread_return, 0, NULL, true);
>  }
>  weak_alias (__pthread_join, pthread_join)

Maybe a comment stating clockid will be ignored in such case?

> diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c
> index 9545ae4..1871061 100644
> --- a/nptl/pthread_join_common.c
> +++ b/nptl/pthread_join_common.c
> @@ -36,7 +36,7 @@ cleanup (void *arg)
>     afterwards.  The kernel up to version 3.16.3 does not use the private futex
>     operations for futex wake-up when the clone terminates.  */
>  static int
> -timedwait_tid (pid_t *tidp, const struct timespec *abstime)
> +clockwait_tid (pid_t *tidp, clockid_t clockid, const struct timespec *abstime)
>  {
>    pid_t tid;
>  
> @@ -46,15 +46,17 @@ timedwait_tid (pid_t *tidp, const struct timespec *abstime)
>    /* Repeat until thread terminated.  */
>    while ((tid = *tidp) != 0)
>      {
> -      struct timeval tv;
> +      struct timespec ts;
>        struct timespec rt;
>  
> -      /* Get the current time.  */
> -      __gettimeofday (&tv, NULL);
> +      /* Get the current time. This can only fail if clockid is
> +         invalid. */
> +      if (__glibc_unlikely (__clock_gettime (clockid, &ts)))
> +        return EINVAL;
>  
>        /* Compute relative timeout.  */
> -      rt.tv_sec = abstime->tv_sec - tv.tv_sec;
> -      rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
> +      rt.tv_sec = abstime->tv_sec - ts.tv_sec;
> +      rt.tv_nsec = abstime->tv_nsec - ts.tv_nsec;
>        if (rt.tv_nsec < 0)
>          {
>            rt.tv_nsec += 1000000000;

Ok.

> @@ -77,7 +79,8 @@ timedwait_tid (pid_t *tidp, const struct timespec *abstime)
>  }
>  
>  int
> -__pthread_timedjoin_ex (pthread_t threadid, void **thread_return,
> +__pthread_clockjoin_ex (pthread_t threadid, void **thread_return,
> +                        clockid_t clockid,
>  			const struct timespec *abstime, bool block)
>  {
>    struct pthread *pd = (struct pthread *) threadid;
> @@ -122,7 +125,7 @@ __pthread_timedjoin_ex (pthread_t threadid, void **thread_return,
>  
>    /* BLOCK waits either indefinitely or based on an absolute time.  POSIX also
>       states a cancellation point shall occur for pthread_join, and we use the
> -     same rationale for posix_timedjoin_np.  Both timedwait_tid and the futex
> +     same rationale for posix_timedjoin_np.  Both clockwait_tid and the futex
>       call use the cancellable variant.  */
>    if (block)
>      {
> @@ -132,7 +135,7 @@ __pthread_timedjoin_ex (pthread_t threadid, void **thread_return,
>        pthread_cleanup_push (cleanup, &pd->joinid);
>  
>        if (abstime != NULL)
> -	result = timedwait_tid (&pd->tid, abstime);
> +	result = clockwait_tid (&pd->tid, clockid, abstime);
>        else
>  	{
>  	  pid_t tid;
> @@ -165,4 +168,4 @@ __pthread_timedjoin_ex (pthread_t threadid, void **thread_return,
>  
>    return result;
>  }
> -hidden_def (__pthread_timedjoin_ex)
> +hidden_def (__pthread_clockjoin_ex)

Ok.

> diff --git a/nptl/pthread_timedjoin.c b/nptl/pthread_timedjoin.c
> index bb48a1e..1890d1a 100644
> --- a/nptl/pthread_timedjoin.c
> +++ b/nptl/pthread_timedjoin.c
> @@ -22,6 +22,7 @@ int
>  __pthread_timedjoin_np (pthread_t threadid, void **thread_return,
>  			const struct timespec *abstime)
>  {
> -  return __pthread_timedjoin_ex (threadid, thread_return, abstime, true);
> +  return __pthread_clockjoin_ex (threadid, thread_return,
> +                                 CLOCK_REALTIME, abstime, true);
>  }
>  weak_alias (__pthread_timedjoin_np, pthread_timedjoin_np)

Ok.

> diff --git a/nptl/pthread_tryjoin.c b/nptl/pthread_tryjoin.c
> index 28e765b..ac53956 100644
> --- a/nptl/pthread_tryjoin.c
> +++ b/nptl/pthread_tryjoin.c
> @@ -28,5 +28,5 @@ pthread_tryjoin_np (pthread_t threadid, void **thread_return)
>  
>    /* If pd->tid == 0 then lll_wait_tid will not block on futex
>       operation.  */
> -  return __pthread_timedjoin_ex (threadid, thread_return, NULL, false);
> +  return __pthread_clockjoin_ex (threadid, thread_return, 0, NULL, false);
>  }

Maybe a comment stating clockid will be ignored in such case?

> diff --git a/nptl/thrd_join.c b/nptl/thrd_join.c
> index 497d0d2..10d9a72 100644
> --- a/nptl/thrd_join.c
> +++ b/nptl/thrd_join.c
> @@ -22,7 +22,7 @@ int
>  thrd_join (thrd_t thr, int *res)
>  {
>    void *pthread_res;
> -  int err_code = __pthread_timedjoin_ex (thr, &pthread_res, NULL, true);
> +  int err_code = __pthread_clockjoin_ex (thr, &pthread_res, 0, NULL, true);
>    if (res)
>     *res = (int) (uintptr_t) pthread_res;
>  

Ok.

> diff --git a/nptl/tst-join10.c b/nptl/tst-join10.c
> new file mode 100644
> index 0000000..a222dd1
> --- /dev/null
> +++ b/nptl/tst-join10.c
> @@ -0,0 +1,20 @@
> +/* Check if pthread_clockjoin_np is a cancellation entrypoint.
> +   Copyright (C) 2019 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#define USE_PTHREAD_CLOCKJOIN_NP_REALTIME 1
> +#include <nptl/tst-join5.c>

Ok.

> diff --git a/nptl/tst-join11.c b/nptl/tst-join11.c
> new file mode 100644
> index 0000000..341588a
> --- /dev/null
> +++ b/nptl/tst-join11.c
> @@ -0,0 +1,21 @@
> +/* Check if pthread_clockjoin_np is a cancellation entrypoint.
> +   Copyright (C) 2019 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#define USE_PTHREAD_CLOCKJOIN_NP_REALTIME 1
> +#define WAIT_IN_CHILD 1
> +#include <nptl/tst-join5.c>

Ok.

> diff --git a/nptl/tst-join12.c b/nptl/tst-join12.c
> new file mode 100644
> index 0000000..44592dc
> --- /dev/null
> +++ b/nptl/tst-join12.c
> @@ -0,0 +1,20 @@
> +/* Check if pthread_clockjoin_np is a cancellation entrypoint.
> +   Copyright (C) 2019 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#define USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC 1
> +#include <nptl/tst-join5.c>

Ok.

> diff --git a/nptl/tst-join13.c b/nptl/tst-join13.c
> new file mode 100644
> index 0000000..d4e49d5
> --- /dev/null
> +++ b/nptl/tst-join13.c
> @@ -0,0 +1,21 @@
> +/* Check if pthread_clockjoin_np is a cancellation entrypoint.
> +   Copyright (C) 2019 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#define USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC 1
> +#define WAIT_IN_CHILD 1
> +#include <nptl/tst-join5.c>

Ok.

> diff --git a/nptl/tst-join3.c b/nptl/tst-join3.c
> index a4ae459..c06e65a 100644
> --- a/nptl/tst-join3.c
> +++ b/nptl/tst-join3.c
> @@ -28,6 +28,8 @@
>  #include <support/xtime.h>
>  
>  
> +#define CLOCK_USE_TIMEDJOIN (-1)
> +
>  static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
>  
>  
> @@ -35,19 +37,23 @@ static void *
>  tf (void *arg)
>  {
>    xpthread_mutex_lock (&lock);
> +  xpthread_mutex_unlock (&lock);
>  

Maybe it would be better to move the unlock after the loop test, 
to mimic how the other unlock does?

>    return (void *) 42l;
>  }
>  
>  
>  static int
> -do_test (void)
> +do_test_clock (clockid_t clockid)
>  {
> +  const clockid_t clockid_for_get =
> +    (clockid == CLOCK_USE_TIMEDJOIN) ? CLOCK_REALTIME : clockid;
> +
>    xpthread_mutex_lock (&lock);
>    pthread_t th = xpthread_create (NULL, tf, NULL);
>  
>    void *status;
> -  struct timespec timeout = timespec_add (xclock_now (CLOCK_REALTIME),
> +  struct timespec timeout = timespec_add (xclock_now (clockid_for_get),
>                                            make_timespec (0, 200000000));
>  

Ok.

>    int val = pthread_timedjoin_np (th, &status, &timeout);
> @@ -57,10 +63,13 @@ do_test (void)
>  
>    while (1)
>      {
> -      timeout = timespec_add (xclock_now (CLOCK_REALTIME),
> +      timeout = timespec_add (xclock_now (clockid_for_get),
>                                make_timespec (0, 200000000));
>  
> -      val = pthread_timedjoin_np (th, &status, &timeout);
> +      if (clockid == CLOCK_USE_TIMEDJOIN)
> +        val = pthread_timedjoin_np (th, &status, &timeout);
> +      else
> +        val = pthread_clockjoin_np (th, &status, clockid, &timeout);
>        if (val == 0)
>  	break;
>  
> @@ -73,4 +82,13 @@ do_test (void)
>    return 0;
>  }
>  
> +static int
> +do_test (void)
> +{
> +  do_test_clock (CLOCK_USE_TIMEDJOIN);
> +  do_test_clock (CLOCK_REALTIME);
> +  do_test_clock (CLOCK_MONOTONIC);
> +  return 0;
> +}
> +
>  #include <support/test-driver.c>

Ok.

> diff --git a/nptl/tst-join5.c b/nptl/tst-join5.c
> index 41cacf1..1ee765c 100644
> --- a/nptl/tst-join5.c
> +++ b/nptl/tst-join5.c
> @@ -24,7 +24,9 @@
>  #include <unistd.h>
>  
>  #include <support/check.h>
> +#include <support/timespec.h>
>  #include <support/xthread.h>
> +#include <support/xtime.h>
>  
>  static void
>  wait_code (void)
> @@ -42,12 +44,18 @@ static pthread_barrier_t b;
>  static int
>  thread_join (pthread_t thread, void **retval)
>  {
> -#ifdef USE_PTHREAD_TIMEDJOIN_NP
> -  struct timespec tv;
> -  TEST_COMPARE (clock_gettime (CLOCK_REALTIME, &tv), 0);
> -  /* Arbitrary large timeout to make it act as pthread_join.  */
> -  tv.tv_sec += 1000;
> -  return pthread_timedjoin_np ((pthread_t) thread, retval, &tv);
> +#if defined USE_PTHREAD_TIMEDJOIN_NP
> +  const struct timespec ts = timespec_add (xclock_now (CLOCK_REALTIME),
> +                                           make_timespec (1000, 0));
> +  return pthread_timedjoin_np ((pthread_t) thread, retval, &ts);
> +#elif defined USE_PTHREAD_CLOCKJOIN_NP_REALTIME
> +  const struct timespec ts = timespec_add (xclock_now (CLOCK_REALTIME),
> +                                           make_timespec (1000, 0));
> +  return pthread_clockjoin_np ((pthread_t) thread, retval, CLOCK_REALTIME, &ts);
> +#elif defined USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC
> +  const struct timespec ts = timespec_add (xclock_now (CLOCK_MONOTONIC),
> +                                           make_timespec (1000, 0));
> +  return pthread_clockjoin_np ((pthread_t) thread, retval, CLOCK_MONOTONIC, &ts);
>  #else
>    return pthread_join ((pthread_t) thread, retval);
>  #endif

There is no need of casts here.

> diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h
> index ceb724d..35be74e 100644
> --- a/sysdeps/nptl/pthread.h
> +++ b/sysdeps/nptl/pthread.h
> @@ -263,6 +263,17 @@ extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
>     __THROW.  */
>  extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
>  				 const struct timespec *__abstime);
> +
> +/* Make calling thread wait for termination of the thread TH, but only
> +   until TIMEOUT measured against the clock specified by CLOCKID.  The
> +   exit status of the thread is stored in *THREAD_RETURN, if
> +   THREAD_RETURN is not NULL.
> +
> +   This function is a cancellation point and therefore not marked with
> +   __THROW.  */
> +extern int pthread_clockjoin_np (pthread_t __th, void **__thread_return,
> +                                 clockid_t clockid,
> +				 const struct timespec *__abstime);
>  #endif
>  
>  /* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
> diff --git a/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist b/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
> index cdc3ad5..e96fe0d 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
> @@ -239,3 +239,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F

OK.

> diff --git a/sysdeps/unix/sysv/linux/alpha/libpthread.abilist b/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
> index e2c8832..4e34197 100644
> --- a/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
> @@ -251,6 +251,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/arm/be/libpthread.abilist b/sysdeps/unix/sysv/linux/arm/be/libpthread.abilist
> index db670ef..01d8712 100644
> --- a/sysdeps/unix/sysv/linux/arm/be/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/be/libpthread.abilist
> @@ -32,6 +32,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 _IO_flockfile F
>  GLIBC_2.4 _IO_ftrylockfile F
>  GLIBC_2.4 _IO_funlockfile F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/arm/le/libpthread.abilist b/sysdeps/unix/sysv/linux/arm/le/libpthread.abilist
> index db670ef..01d8712 100644
> --- a/sysdeps/unix/sysv/linux/arm/le/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/le/libpthread.abilist
> @@ -32,6 +32,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 _IO_flockfile F
>  GLIBC_2.4 _IO_ftrylockfile F
>  GLIBC_2.4 _IO_funlockfile F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/csky/libpthread.abilist b/sysdeps/unix/sysv/linux/csky/libpthread.abilist
> index 44eedc7..44383c6 100644
> --- a/sysdeps/unix/sysv/linux/csky/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/csky/libpthread.abilist
> @@ -232,3 +232,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/hppa/libpthread.abilist b/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
> index 5454761..522356c 100644
> --- a/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
> @@ -241,6 +241,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/i386/libpthread.abilist b/sysdeps/unix/sysv/linux/i386/libpthread.abilist
> index f9e7821..d38b44f 100644
> --- a/sysdeps/unix/sysv/linux/i386/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/i386/libpthread.abilist
> @@ -249,6 +249,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/ia64/libpthread.abilist b/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
> index 5be0e0f..8772654 100644
> --- a/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
> @@ -243,6 +243,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
> index db670ef..01d8712 100644
> --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
> @@ -32,6 +32,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 _IO_flockfile F
>  GLIBC_2.4 _IO_ftrylockfile F
>  GLIBC_2.4 _IO_funlockfile F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
> index f9e7821..d38b44f 100644
> --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
> @@ -249,6 +249,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist
> index 7bee5b4..300d8de 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/be/libpthread.abilist
> @@ -239,3 +239,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist
> index 7bee5b4..300d8de 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/le/libpthread.abilist
> @@ -239,3 +239,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist b/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
> index e0390a6..68af03b 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
> @@ -250,6 +250,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist b/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
> index e0390a6..68af03b 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
> @@ -250,6 +250,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/nios2/libpthread.abilist b/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
> index 21abc95..6c26192 100644
> --- a/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
> @@ -239,3 +239,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
> index c410fa8..55f3161 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
> @@ -251,6 +251,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist
> index a0a8058..475eec2 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libpthread.abilist
> @@ -242,6 +242,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist
> index cdc3ad5..e96fe0d 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libpthread.abilist
> @@ -239,3 +239,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist
> index aa6f793..94b478e 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist
> @@ -234,3 +234,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
> index c504fbf..c9c833d 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
> @@ -251,6 +251,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
> index 933f202..5bfa892 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
> @@ -243,6 +243,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/sh/be/libpthread.abilist b/sysdeps/unix/sysv/linux/sh/be/libpthread.abilist
> index 5454761..522356c 100644
> --- a/sysdeps/unix/sysv/linux/sh/be/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/be/libpthread.abilist
> @@ -241,6 +241,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/sh/le/libpthread.abilist b/sysdeps/unix/sysv/linux/sh/le/libpthread.abilist
> index 5454761..522356c 100644
> --- a/sysdeps/unix/sysv/linux/sh/le/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/le/libpthread.abilist
> @@ -241,6 +241,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
> index e2c8832..4e34197 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
> @@ -251,6 +251,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
> index 5be0e0f..8772654 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
> @@ -243,6 +243,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
> index 87be582..72a9396 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
> @@ -241,6 +241,7 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
>  GLIBC_2.4 pthread_mutex_consistent_np F
>  GLIBC_2.4 pthread_mutex_getprioceiling F
>  GLIBC_2.4 pthread_mutex_setprioceiling F

Ok.

> diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
> index 5539c4e..6b80eda 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
> @@ -239,3 +239,4 @@ GLIBC_2.30 pthread_mutex_clocklock F
>  GLIBC_2.30 pthread_rwlock_clockrdlock F
>  GLIBC_2.30 pthread_rwlock_clockwrlock F
>  GLIBC_2.30 sem_clockwait F
> +GLIBC_2.31 pthread_clockjoin_np F
> 

Ok.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 4/4] nptl: Add pthread_timedjoin_np, pthread_clockjoin_np NULL timeout test
  2019-09-18 12:30 ` [PATCH v2 4/4] nptl: Add pthread_timedjoin_np, pthread_clockjoin_np NULL timeout test Mike Crowe
@ 2019-09-26 23:30   ` Adhemerval Zanella
  0 siblings, 0 replies; 23+ messages in thread
From: Adhemerval Zanella @ 2019-09-26 23:30 UTC (permalink / raw)
  To: libc-alpha



On 18/09/2019 05:30, Mike Crowe wrote:
> Passing NULL as the timeout parameter to pthread_timedjoin_np has resulted
> in it behaving like pthread_join for a long time. Since that is now the
> documented behaviour, we ought to test that both it and the new
> pthread_clockjoin_np support it.
> 
> 	* nptl/tst-join14.c: Test passing NULL as abstime parameter of
> 	pthread_timedjoin_np and pthread_clockjoin_np.
> 	* nptl/Makefile: Add tst-join14.c.

LGTM with small nits below.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

> ---
>  ChangeLog         |  5 +++-
>  nptl/Makefile     |  1 +-
>  nptl/tst-join14.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  3 files changed, 79 insertions(+)
>  create mode 100644 nptl/tst-join14.c
> 
> diff --git a/ChangeLog b/ChangeLog
> index 8a2166d..048c4b2 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,4 +1,9 @@
>  2019-09-18  Mike Crowe  <mac@mcrowe.com>
> +	* nptl/tst-join14.c: Test passing NULL as abstime parameter of
> +	pthread_timedjoin_np and pthread_clockjoin_np.
> +	* nptl/Makefile: Add tst-join14.c.
> +
> +2019-09-18  Mike Crowe  <mac@mcrowe.com>
>  	* NEWS: Mention addition of pthread_clockjoin_np along with other
>  	"clock" variants of existing "timed" functions.
>  	* sysdeps/nptl/pthread.h: Add declaration of pthread_clockjoin_np.
> diff --git a/nptl/Makefile b/nptl/Makefile
> index 5521a58..3e05b79 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile
> @@ -275,6 +275,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
>  	tst-raise1 \
>  	tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 tst-join6 tst-join7 \
>  	tst-join8 tst-join9 tst-join10 tst-join11 tst-join12 tst-join13 \
> +	tst-join14 \
>  	tst-detach1 \
>  	tst-eintr2 tst-eintr3 tst-eintr4 tst-eintr5 \
>  	tst-tsd1 tst-tsd2 tst-tsd3 tst-tsd4 tst-tsd5 tst-tsd6 \

Ok.

> diff --git a/nptl/tst-join14.c b/nptl/tst-join14.c
> new file mode 100644
> index 0000000..261b919
> --- /dev/null
> +++ b/nptl/tst-join14.c
> @@ -0,0 +1,73 @@

Missing one line comment.

> +/* Copyright (C) 2019 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <errno.h>
> +#include <pthread.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <sys/time.h>
> +#include <support/check.h>
> +#include <support/timespec.h>
> +#include <support/xthread.h>
> +#include <support/xtime.h>
> +
> +
> +#define CLOCK_USE_TIMEDJOIN (-1)
> +
> +
> +static void *
> +tf (void *arg)
> +{
> +  struct timespec ts = make_timespec(0, 100000);
> +  nanosleep(&ts, NULL);
> +
> +  return (void *) 42l;
> +}
> +

Missing space before parenthesis.

> +
> +/* Check that pthread_timedjoin_np and pthread_clockjoin_np wait "forever" if
> + * passed a timeout parameter of NULL. We can't actually wait forever, but we
> + * can be sure that we did at least wait for some time by checking the exit
> + * status of the thread. */
> +static int
> +do_test_clock (clockid_t clockid)
> +{
> +  pthread_t th = xpthread_create (NULL, tf, NULL);
> +
> +  void *status;
> +  int val = (clockid == CLOCK_USE_TIMEDJOIN)
> +    ? pthread_timedjoin_np (th, &status, NULL)
> +    : pthread_clockjoin_np (th, &status, clockid, NULL);
> +  TEST_COMPARE (val, 0);
> +
> +  if (status != (void *) 42l)
> +    FAIL_EXIT1 ("return value %p, expected %p\n", status, (void *) 42l);
> +
> +  return 0;
> +}
> +
> +static int
> +do_test (void)
> +{
> +  do_test_clock (CLOCK_USE_TIMEDJOIN);
> +  do_test_clock (CLOCK_REALTIME);
> +  do_test_clock (CLOCK_MONOTONIC);
> +  return 0;
> +}
> +
> +#include <support/test-driver.c>
> 

Ok.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 2/4] manual: Add documentation for pthread_tryjoin_np and pthread_timedjoin_np
  2019-09-26 21:26   ` Adhemerval Zanella
@ 2019-09-27  9:08     ` Yann Droneaud
  2019-09-28  8:53     ` Mike Crowe
  1 sibling, 0 replies; 23+ messages in thread
From: Yann Droneaud @ 2019-09-27  9:08 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

Hi,

Le jeudi 26 septembre 2019 à 14:26 -0700, Adhemerval Zanella a écrit :
> 
> On 18/09/2019 05:30, Mike Crowe wrote:
> > This documentation isn't perfect, but it's better than nothing and can
> > hopefully act as a basis for future improvement. In particular, although
> > I'm certain that the functions are MT-Safe, I'm not sure about the rest of
> > the @safety line.
> > 
> > Yann Droneaud pointed out that pthread_timedjoin_np would wait forever if
> > the timeout parameter is passed as NULL. Since it's now too late to change
> > that, I've documented it.
> 
> To which semantic do you think it would be better to change? Since this
> symbol are not yet in POSIX there still the possibility to change it
> by using a new plus a compat symbol.
> 

I think it's the behavior we want in order to accomodate for every
needs with a single interface:

- wait forever (aka. pthread_join())        : pass NULL
- wait:        (aka. pthread_timedjoin_np()): pass deadline
- don't wait   (aka. pthread_tryjoin_np())  : pass current time

The later could be made more usuable if (struct timespec){ 0, 0 } would
have a special meaning, but it cannot, as timestamp can overflow ...

Regards.

-- 
Yann Droneaud
OPTEYA



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 2/4] manual: Add documentation for pthread_tryjoin_np and pthread_timedjoin_np
  2019-09-26 21:26   ` Adhemerval Zanella
  2019-09-27  9:08     ` Yann Droneaud
@ 2019-09-28  8:53     ` Mike Crowe
  2019-10-14 19:15       ` Adhemerval Zanella
  1 sibling, 1 reply; 23+ messages in thread
From: Mike Crowe @ 2019-09-28  8:53 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Thursday 26 September 2019 at 14:26:00 -0700, Adhemerval Zanella wrote:
> On 18/09/2019 05:30, Mike Crowe wrote:
> > This documentation isn't perfect, but it's better than nothing and can
> > hopefully act as a basis for future improvement. In particular, although
> > I'm certain that the functions are MT-Safe, I'm not sure about the rest of
> > the @safety line.
> > 
> > Yann Droneaud pointed out that pthread_timedjoin_np would wait forever if
> > the timeout parameter is passed as NULL. Since it's now too late to change
> > that, I've documented it.
> 
> To which semantic do you think it would be better to change? Since this
> symbol are not yet in POSIX there still the possibility to change it
> by using a new plus a compat symbol.

The alternative would be to mark the timeout parameter as __nonnull and not
permit it to be NULL, as is the case for the other pthread timed*/clock*
functions. I imagine that if the functions were ever standardised then this
would be the case - but that doesn't look like it's on the horizon.

Although we wouldn't break existing binaries if we change the behaviour and
add a compat symbol, we could break people compiling existing source. I
don't think it's a serious enough problem for it to be worth even doing
that.

However, if others feel strongly about it then I'm prepared to make that
change.

Thanks.

Mike.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 3/4] nptl: Add pthread_clockjoin_np
  2019-09-26 23:17   ` Adhemerval Zanella
@ 2019-09-28 19:45     ` Mike Crowe
  2019-10-14 19:16       ` Adhemerval Zanella
  0 siblings, 1 reply; 23+ messages in thread
From: Mike Crowe @ 2019-09-28 19:45 UTC (permalink / raw)
  To: libc-alpha

On Thursday 26 September 2019 at 16:17:53 -0700, Adhemerval Zanella wrote:
> > diff --git a/nptl/tst-join3.c b/nptl/tst-join3.c
> > index a4ae459..c06e65a 100644
> > --- a/nptl/tst-join3.c
> > +++ b/nptl/tst-join3.c
> > @@ -28,6 +28,8 @@
> >  #include <support/xtime.h>
> >  
> >  
> > +#define CLOCK_USE_TIMEDJOIN (-1)
> > +
> >  static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
> >  
> >  
> > @@ -35,19 +37,23 @@ static void *
> >  tf (void *arg)
> >  {
> >    xpthread_mutex_lock (&lock);
> > +  xpthread_mutex_unlock (&lock);
> >  
> 
> Maybe it would be better to move the unlock after the loop test, 
> to mimic how the other unlock does?

Do you mean that I should unlock the mutex after the loop inside
do_test_clock? If so, that would mean unlocking it on a different thread
and that doesn't sound like it's guaranteed to be safe.

Or perhaps you meant something different?

(The use of a mutex for this test works, but it's non-obvious. Perhaps a
semaphore would be clearer?)

Thanks for the rest of the review. I will make the changes you describe.

Mike.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 3/4] nptl: Add pthread_clockjoin_np
  2019-09-18 12:30 ` [PATCH v2 3/4] nptl: Add pthread_clockjoin_np Mike Crowe
  2019-09-26 23:17   ` Adhemerval Zanella
@ 2019-10-08  8:26   ` Mike Crowe
  1 sibling, 0 replies; 23+ messages in thread
From: Mike Crowe @ 2019-10-08  8:26 UTC (permalink / raw)
  To: libc-alpha

On Wednesday 18 September 2019 at 13:30:55 +0100, Mike Crowe wrote:
> Introduce pthread_clockjoin_np as a version of pthread_timedjoin_np that
> accepts a clockid_t parameter to indicate which clock the timeout should be
> measured against. This mirrors the recently-added POSIX-proposed "clock"
> wait functions.

[snip]

> diff --git a/nptl/tst-join3.c b/nptl/tst-join3.c
> index a4ae459..c06e65a 100644
> --- a/nptl/tst-join3.c
> +++ b/nptl/tst-join3.c
> @@ -28,6 +28,8 @@
>  #include <support/xtime.h>
>  
>  
> +#define CLOCK_USE_TIMEDJOIN (-1)
> +
>  static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
>  
>  
> @@ -35,19 +37,23 @@ static void *
>  tf (void *arg)
>  {
>    xpthread_mutex_lock (&lock);
> +  xpthread_mutex_unlock (&lock);
>  
>    return (void *) 42l;
>  }
>  
>  
>  static int
> -do_test (void)
> +do_test_clock (clockid_t clockid)
>  {
> +  const clockid_t clockid_for_get =
> +    (clockid == CLOCK_USE_TIMEDJOIN) ? CLOCK_REALTIME : clockid;
> +
>    xpthread_mutex_lock (&lock);
>    pthread_t th = xpthread_create (NULL, tf, NULL);
>  
>    void *status;
> -  struct timespec timeout = timespec_add (xclock_now (CLOCK_REALTIME),
> +  struct timespec timeout = timespec_add (xclock_now (clockid_for_get),
>                                            make_timespec (0, 200000000));
>  
>    int val = pthread_timedjoin_np (th, &status, &timeout);

This needs to call pthread_clockjoin_np if clockid indicates so, as below.

> @@ -57,10 +63,13 @@ do_test (void)
>  
>    while (1)
>      {
> -      timeout = timespec_add (xclock_now (CLOCK_REALTIME),
> +      timeout = timespec_add (xclock_now (clockid_for_get),
>                                make_timespec (0, 200000000));
>  
> -      val = pthread_timedjoin_np (th, &status, &timeout);
> +      if (clockid == CLOCK_USE_TIMEDJOIN)
> +        val = pthread_timedjoin_np (th, &status, &timeout);
> +      else
> +        val = pthread_clockjoin_np (th, &status, clockid, &timeout);
>        if (val == 0)
>  	break;
>  
> @@ -73,4 +82,13 @@ do_test (void)
>    return 0;
>  }
>  
> +static int
> +do_test (void)
> +{
> +  do_test_clock (CLOCK_USE_TIMEDJOIN);
> +  do_test_clock (CLOCK_REALTIME);
> +  do_test_clock (CLOCK_MONOTONIC);
> +  return 0;
> +}
> +
>  #include <support/test-driver.c>

Mike.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 2/4] manual: Add documentation for pthread_tryjoin_np and pthread_timedjoin_np
  2019-09-28  8:53     ` Mike Crowe
@ 2019-10-14 19:15       ` Adhemerval Zanella
  2019-10-18 16:28         ` Mike Crowe
  0 siblings, 1 reply; 23+ messages in thread
From: Adhemerval Zanella @ 2019-10-14 19:15 UTC (permalink / raw)
  To: Mike Crowe; +Cc: libc-alpha, Yann Droneaud



On 28/09/2019 05:53, Mike Crowe wrote:
> On Thursday 26 September 2019 at 14:26:00 -0700, Adhemerval Zanella wrote:
>> On 18/09/2019 05:30, Mike Crowe wrote:
>>> This documentation isn't perfect, but it's better than nothing and can
>>> hopefully act as a basis for future improvement. In particular, although
>>> I'm certain that the functions are MT-Safe, I'm not sure about the rest of
>>> the @safety line.
>>>
>>> Yann Droneaud pointed out that pthread_timedjoin_np would wait forever if
>>> the timeout parameter is passed as NULL. Since it's now too late to change
>>> that, I've documented it.
>>
>> To which semantic do you think it would be better to change? Since this
>> symbol are not yet in POSIX there still the possibility to change it
>> by using a new plus a compat symbol.
> 
> The alternative would be to mark the timeout parameter as __nonnull and not
> permit it to be NULL, as is the case for the other pthread timed*/clock*
> functions. I imagine that if the functions were ever standardised then this
> would be the case - but that doesn't look like it's on the horizon.
> 
> Although we wouldn't break existing binaries if we change the behaviour and
> add a compat symbol, we could break people compiling existing source. I
> don't think it's a serious enough problem for it to be worth even doing
> that.
> 
> However, if others feel strongly about it then I'm prepared to make that
> change.

At least other pthread interfaces that uses a timespec as input argument
add a nonnull on their interfaces. However they handle a null not equal:

  - pthread_mutex_{clock,timed}lock will trigger a SEGFAULT due 
    lll_timedlock_wait.c:31 for the contended case, it works for
    uncontended case (where an userspace atomic operation is suffice).

  - pthread_cond_timedwait will also trigger a SEGFAULT due
    nptl/pthread_cond_wait.c:648.

  - pthread_{rw,rd}lock_{clock,timed}lock will handle it as unbounded
    time (since both pthread_rwlock_common.c and futexes call check if
    abstime is NULL).

> - wait forever (aka. pthread_join())        : pass NULL
> - wait:        (aka. pthread_timedjoin_np()): pass deadline
> - don't wait   (aka. pthread_tryjoin_np())  : pass current time

I don't see that making pthread_timedjoin_np behaves differently than
other pthread interfaces a good move forward. So I would avoid support
both 'wait forever' and 'don't wait' semantic in this case.

And POSIX also is not specific regarding timeout handling in aforementioned
pthread interfaces. And systems that implement them do differ, for instance:

  - FreeBSD 11.1 does not trigger any build warning or runtime error for
    NULL argument for neither pthread_mutex_timedlock or
    pthread_{rw,rd}lock_lock.  The pthread_cond_timedwait does return
    EINVAL though.

  - Solaris 11.4 seems to behave as glibc, it triggers a SEGFAULT for
    pthread_mutex_timedlock (for *both* contended and non-contended case),
    pthread_{rw,rd}lock_timedlock, *and* for pthread_cond_timedwait.

  - AIX 7.2 returns EINVAL for contended pthread_mutex_timedlock case and
    works for non-contended case. It does not trigger any runtime issue
    for {rw,rd}lock and also returns EINVAL for pthread_cond_timedwait.

So trying to come up with a portable error handling does not seem to
that valuable, it leads to believe common usage is to *not* use NULL 
value for timeout arguments.

So I would suggest to sync with current practice and fail early for
invalid inputs either by EINVAL or by assuming valid pointer (which
trigger an invalid memory access and warns user that this is an invalid
usage).

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 3/4] nptl: Add pthread_clockjoin_np
  2019-09-28 19:45     ` Mike Crowe
@ 2019-10-14 19:16       ` Adhemerval Zanella
  0 siblings, 0 replies; 23+ messages in thread
From: Adhemerval Zanella @ 2019-10-14 19:16 UTC (permalink / raw)
  To: libc-alpha



On 28/09/2019 16:45, Mike Crowe wrote:
> On Thursday 26 September 2019 at 16:17:53 -0700, Adhemerval Zanella wrote:
>>> diff --git a/nptl/tst-join3.c b/nptl/tst-join3.c
>>> index a4ae459..c06e65a 100644
>>> --- a/nptl/tst-join3.c
>>> +++ b/nptl/tst-join3.c
>>> @@ -28,6 +28,8 @@
>>>  #include <support/xtime.h>
>>>  
>>>  
>>> +#define CLOCK_USE_TIMEDJOIN (-1)
>>> +
>>>  static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
>>>  
>>>  
>>> @@ -35,19 +37,23 @@ static void *
>>>  tf (void *arg)
>>>  {
>>>    xpthread_mutex_lock (&lock);
>>> +  xpthread_mutex_unlock (&lock);
>>>  
>>
>> Maybe it would be better to move the unlock after the loop test, 
>> to mimic how the other unlock does?
> 
> Do you mean that I should unlock the mutex after the loop inside
> do_test_clock? If so, that would mean unlocking it on a different thread
> and that doesn't sound like it's guaranteed to be safe.

Yeah, but it is not really a strong opinion.  It just make the patch
change less code in the original test.  

> 
> Or perhaps you meant something different?
> 
> (The use of a mutex for this test works, but it's non-obvious. Perhaps a
> semaphore would be clearer?)
> 
> Thanks for the rest of the review. I will make the changes you describe.
> 
> Mike.
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 2/4] manual: Add documentation for pthread_tryjoin_np and pthread_timedjoin_np
  2019-10-14 19:15       ` Adhemerval Zanella
@ 2019-10-18 16:28         ` Mike Crowe
  2019-10-21 18:15           ` Adhemerval Zanella
  0 siblings, 1 reply; 23+ messages in thread
From: Mike Crowe @ 2019-10-18 16:28 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Mike Crowe, libc-alpha, Yann Droneaud

On Monday 14 October 2019 at 16:15:11 -0300, Adhemerval Zanella wrote:
> On 28/09/2019 05:53, Mike Crowe wrote:
> > On Thursday 26 September 2019 at 14:26:00 -0700, Adhemerval Zanella wrote:
> >> On 18/09/2019 05:30, Mike Crowe wrote:
> >>> This documentation isn't perfect, but it's better than nothing and can
> >>> hopefully act as a basis for future improvement. In particular, although
> >>> I'm certain that the functions are MT-Safe, I'm not sure about the rest of
> >>> the @safety line.
> >>>
> >>> Yann Droneaud pointed out that pthread_timedjoin_np would wait forever if
> >>> the timeout parameter is passed as NULL. Since it's now too late to change
> >>> that, I've documented it.
> >>
> >> To which semantic do you think it would be better to change? Since this
> >> symbol are not yet in POSIX there still the possibility to change it
> >> by using a new plus a compat symbol.
> > 
> > The alternative would be to mark the timeout parameter as __nonnull and not
> > permit it to be NULL, as is the case for the other pthread timed*/clock*
> > functions. I imagine that if the functions were ever standardised then this
> > would be the case - but that doesn't look like it's on the horizon.
> > 
> > Although we wouldn't break existing binaries if we change the behaviour and
> > add a compat symbol, we could break people compiling existing source. I
> > don't think it's a serious enough problem for it to be worth even doing
> > that.
> > 
> > However, if others feel strongly about it then I'm prepared to make that
> > change.
> 
> At least other pthread interfaces that uses a timespec as input argument
> add a nonnull on their interfaces. However they handle a null not equal:
> 
>   - pthread_mutex_{clock,timed}lock will trigger a SEGFAULT due 
>     lll_timedlock_wait.c:31 for the contended case, it works for
>     uncontended case (where an userspace atomic operation is suffice).
> 
>   - pthread_cond_timedwait will also trigger a SEGFAULT due
>     nptl/pthread_cond_wait.c:648.
> 
>   - pthread_{rw,rd}lock_{clock,timed}lock will handle it as unbounded
>     time (since both pthread_rwlock_common.c and futexes call check if
>     abstime is NULL).
> 
> > - wait forever (aka. pthread_join())        : pass NULL
> > - wait:        (aka. pthread_timedjoin_np()): pass deadline
> > - don't wait   (aka. pthread_tryjoin_np())  : pass current time
> 
> I don't see that making pthread_timedjoin_np behaves differently than
> other pthread interfaces a good move forward. So I would avoid support
> both 'wait forever' and 'don't wait' semantic in this case.
>
> And POSIX also is not specific regarding timeout handling in aforementioned
> pthread interfaces. And systems that implement them do differ, for instance:
> 
>   - FreeBSD 11.1 does not trigger any build warning or runtime error for
>     NULL argument for neither pthread_mutex_timedlock or
>     pthread_{rw,rd}lock_lock.  The pthread_cond_timedwait does return
>     EINVAL though.
> 
>   - Solaris 11.4 seems to behave as glibc, it triggers a SEGFAULT for
>     pthread_mutex_timedlock (for *both* contended and non-contended case),
>     pthread_{rw,rd}lock_timedlock, *and* for pthread_cond_timedwait.
> 
>   - AIX 7.2 returns EINVAL for contended pthread_mutex_timedlock case and
>     works for non-contended case. It does not trigger any runtime issue
>     for {rw,rd}lock and also returns EINVAL for pthread_cond_timedwait.
> 
> So trying to come up with a portable error handling does not seem to
> that valuable, it leads to believe common usage is to *not* use NULL 
> value for timeout arguments.
> 
> So I would suggest to sync with current practice and fail early for
> invalid inputs either by EINVAL or by assuming valid pointer (which
> trigger an invalid memory access and warns user that this is an invalid
> usage).

Since pthread_timedjoin_np is not new, we risk changing the behaviour of
existing code that may have come to rely on the behaviour when passing
NULL. Even if we use symbol versioning to ensure that code compiled against
old glibc continues to behave as it always did, we still risk changing the
behaviour when code is compiled against the newer glibc. If that code is
compiled with -Wnonnull and the compiler is able to determine that NULL is
being passed (which it may not if the code in question is using a wrapper
function) then a warning would be emitted which may help, but does not
guarantee that the change will be noticed.

pthread_clockjoin_np is new, so it doesn't have any legacy behaviour. We
can mark the timeout as __nonnull. We could check the argument against NULL
and return EINVAL, but it seems that the compiler warns when checking
__nonnull arguments and just throws the check away[1] so we're probably
stuck with potentially faulting in that situation.

In my view, changing the behaviour of pthread_timedjoin_np now is of little
benefit compared to the risk of breaking existing code. That ship has
sailed. Having decided that, I thought that making pthread_clockjoin_np
behave differently to pthread_timedjoin_np would be confusing, so I settled
on it behaving the same way.

So, what are you proposing we should do? Change the behaviour of the
existing pthread_timedjoin_np function and the new pthread_clockjoin_np
function or only of the latter?

Thanks.

Mike.

[1] https://godbolt.org/z/Msw9vk

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 2/4] manual: Add documentation for pthread_tryjoin_np and pthread_timedjoin_np
  2019-10-18 16:28         ` Mike Crowe
@ 2019-10-21 18:15           ` Adhemerval Zanella
  0 siblings, 0 replies; 23+ messages in thread
From: Adhemerval Zanella @ 2019-10-21 18:15 UTC (permalink / raw)
  To: Mike Crowe; +Cc: libc-alpha, Yann Droneaud



On 18/10/2019 13:28, Mike Crowe wrote:
> Since pthread_timedjoin_np is not new, we risk changing the behaviour of
> existing code that may have come to rely on the behaviour when passing
> NULL. Even if we use symbol versioning to ensure that code compiled against
> old glibc continues to behave as it always did, we still risk changing the
> behaviour when code is compiled against the newer glibc. If that code is
> compiled with -Wnonnull and the compiler is able to determine that NULL is
> being passed (which it may not if the code in question is using a wrapper
> function) then a warning would be emitted which may help, but does not
> guarantee that the change will be noticed.

At least for code built against a new symbol we can not only add the nonnull
but at result EINVAL for invalid abstime. It would be semantic change, but
it is what compat symbol are used mainly.

> 
> pthread_clockjoin_np is new, so it doesn't have any legacy behaviour. We
> can mark the timeout as __nonnull. We could check the argument against NULL
> and return EINVAL, but it seems that the compiler warns when checking
> __nonnull arguments and just throws the check away[1] so we're probably
> stuck with potentially faulting in that situation.
> 
> In my view, changing the behaviour of pthread_timedjoin_np now is of little
> benefit compared to the risk of breaking existing code. That ship has
> sailed. Having decided that, I thought that making pthread_clockjoin_np
> behave differently to pthread_timedjoin_np would be confusing, so I settled
> on it behaving the same way.
> 
> So, what are you proposing we should do? Change the behaviour of the
> existing pthread_timedjoin_np function and the new pthread_clockjoin_np
> function or only of the latter?

I agree with your rationale that we should not change pthread_timedjoin_np
and mimic its behaviour for pthread_clockjoin_np (in fact I acked the patches
already).

This discussion was mostly due the proposition Yann Droneaud brought to you
and you mentioned in the email.  I think the patchset is good to be pushed
upstream.


> 
> Thanks.
> 
> Mike.
> 
> [1] https://godbolt.org/z/Msw9vk
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 0/4] nptl: Add pthread_clockjoin_np
  2019-09-18 12:30 [PATCH v2 0/4] nptl: Add pthread_clockjoin_np Mike Crowe
                   ` (3 preceding siblings ...)
  2019-09-18 12:30 ` [PATCH v2 4/4] nptl: Add pthread_timedjoin_np, pthread_clockjoin_np NULL timeout test Mike Crowe
@ 2019-10-31 14:31 ` Adhemerval Zanella
  2019-10-31 19:38   ` Mike Crowe
  4 siblings, 1 reply; 23+ messages in thread
From: Adhemerval Zanella @ 2019-10-31 14:31 UTC (permalink / raw)
  To: libc-alpha, Mike Crowe



On 18/09/2019 09:30, Mike Crowe wrote:
> The aim of this series is to add pthread_clockjoin_np, which works
> like pthread_timedjoin_np except it accepts an additional parameter to
> indicate which clock the timeout should be measured against.
> 
> The naming matches the pthread_cond_clockwait,
> pthread_mutex_clocklock, sem_clockwait, etc. functions added in glibc
> v2.30 and documented at http://austingroupbugs.net/view.php?id=1216.
> 
> The series also includes some minimal documentation for
> pthread_tryjoin_np and pthread_timedjoin_np, along with some new
> tests.
> 
> Thanks to everyone who provided feedback for the first version[1] of
> this series.
> 
> [1] https://sourceware.org/ml/libc-alpha/2019-06/msg00911.html

Hi Mike,

I think your patchset it ready to push upstream.  I have fixed the small
nits I brought on the review along with some more specific changes below:

  - Move the NEWS entry for pthread_clockjoin_np to its own bullet on
    2.31.

  - Moved __pthread_clockjoin_ex to a hidden definition and removed the
    hidden_{proto,def}.

  - Added some missing one line file description.

I also pushed the set on a personal branch [1]. If you are ok with this 
set, I would like to push it upstream.

[1] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/azanella/pthread_clockjoin_np

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 0/4] nptl: Add pthread_clockjoin_np
  2019-10-31 14:31 ` [PATCH v2 0/4] nptl: Add pthread_clockjoin_np Adhemerval Zanella
@ 2019-10-31 19:38   ` Mike Crowe
  2019-10-31 20:51     ` Adhemerval Zanella
  0 siblings, 1 reply; 23+ messages in thread
From: Mike Crowe @ 2019-10-31 19:38 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Thursday 31 October 2019 at 11:31:30 -0300, Adhemerval Zanella wrote:
> On 18/09/2019 09:30, Mike Crowe wrote:
> > The aim of this series is to add pthread_clockjoin_np, which works
> > like pthread_timedjoin_np except it accepts an additional parameter to
> > indicate which clock the timeout should be measured against.
> > 
> > The naming matches the pthread_cond_clockwait,
> > pthread_mutex_clocklock, sem_clockwait, etc. functions added in glibc
> > v2.30 and documented at http://austingroupbugs.net/view.php?id=1216.
> > 
> > The series also includes some minimal documentation for
> > pthread_tryjoin_np and pthread_timedjoin_np, along with some new
> > tests.
> > 
> > Thanks to everyone who provided feedback for the first version[1] of
> > this series.
> > 
> > [1] https://sourceware.org/ml/libc-alpha/2019-06/msg00911.html
> 
> Hi Mike,
> 
> I think your patchset it ready to push upstream.  I have fixed the small
> nits I brought on the review along with some more specific changes below:
> 
>   - Move the NEWS entry for pthread_clockjoin_np to its own bullet on
>     2.31.
> 
>   - Moved __pthread_clockjoin_ex to a hidden definition and removed the
>     hidden_{proto,def}.
> 
>   - Added some missing one line file description.
> 
> I also pushed the set on a personal branch [1]. If you are ok with this 
> set, I would like to push it upstream.
> 
> [1] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/azanella/pthread_clockjoin_np

Hi Adhemerval,

Thanks for doing all that. I thought that I'd addressed the nits, but I
must have missed or lost some. :(

Your branch looks great, except it appears to be missing this hunk from the
"nptl: Add pthread_clockjoin_np" change:

diff --git a/nptl/tst-join3.c b/nptl/tst-join3.c
index c06e65a247..faf7683eaa 100644
--- a/nptl/tst-join3.c
+++ b/nptl/tst-join3.c
@@ -56,7 +56,12 @@ do_test_clock (clockid_t clockid)
   struct timespec timeout = timespec_add (xclock_now (clockid_for_get),
                                           make_timespec (0, 200000000));

-  int val = pthread_timedjoin_np (th, &status, &timeout);
+  int val;
+  if (clockid == CLOCK_USE_TIMEDJOIN)
+    val = pthread_timedjoin_np (th, &status, &timeout);
+  else
+    val = pthread_clockjoin_np (th, &status, clockid, &timeout);
+
   TEST_COMPARE (val, ETIMEDOUT);

   xpthread_mutex_unlock (&lock);


I suspect that it's not causing the test to fail because the existing call
to pthread_timedjoin_np will just time out immediately if passed the
relatively small absolute CLOCK_MONOTONIC time. I shall see if I can
improve this test to catch that in the future.

Thanks again.

Mike.

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 0/4] nptl: Add pthread_clockjoin_np
  2019-10-31 19:38   ` Mike Crowe
@ 2019-10-31 20:51     ` Adhemerval Zanella
  2019-11-01 21:05       ` Joseph Myers
  2019-11-01 23:01       ` Rafal Luzynski
  0 siblings, 2 replies; 23+ messages in thread
From: Adhemerval Zanella @ 2019-10-31 20:51 UTC (permalink / raw)
  To: Mike Crowe; +Cc: libc-alpha



On 31/10/2019 16:38, Mike Crowe wrote:
> On Thursday 31 October 2019 at 11:31:30 -0300, Adhemerval Zanella wrote:
>> On 18/09/2019 09:30, Mike Crowe wrote:
>>> The aim of this series is to add pthread_clockjoin_np, which works
>>> like pthread_timedjoin_np except it accepts an additional parameter to
>>> indicate which clock the timeout should be measured against.
>>>
>>> The naming matches the pthread_cond_clockwait,
>>> pthread_mutex_clocklock, sem_clockwait, etc. functions added in glibc
>>> v2.30 and documented at http://austingroupbugs.net/view.php?id=1216.
>>>
>>> The series also includes some minimal documentation for
>>> pthread_tryjoin_np and pthread_timedjoin_np, along with some new
>>> tests.
>>>
>>> Thanks to everyone who provided feedback for the first version[1] of
>>> this series.
>>>
>>> [1] https://sourceware.org/ml/libc-alpha/2019-06/msg00911.html
>>
>> Hi Mike,
>>
>> I think your patchset it ready to push upstream.  I have fixed the small
>> nits I brought on the review along with some more specific changes below:
>>
>>   - Move the NEWS entry for pthread_clockjoin_np to its own bullet on
>>     2.31.
>>
>>   - Moved __pthread_clockjoin_ex to a hidden definition and removed the
>>     hidden_{proto,def}.
>>
>>   - Added some missing one line file description.
>>
>> I also pushed the set on a personal branch [1]. If you are ok with this 
>> set, I would like to push it upstream.
>>
>> [1] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/azanella/pthread_clockjoin_np
> 
> Hi Adhemerval,
> 
> Thanks for doing all that. I thought that I'd addressed the nits, but I
> must have missed or lost some. :(
> 
> Your branch looks great, except it appears to be missing this hunk from the
> "nptl: Add pthread_clockjoin_np" change:
> 
> diff --git a/nptl/tst-join3.c b/nptl/tst-join3.c
> index c06e65a247..faf7683eaa 100644
> --- a/nptl/tst-join3.c
> +++ b/nptl/tst-join3.c
> @@ -56,7 +56,12 @@ do_test_clock (clockid_t clockid)
>    struct timespec timeout = timespec_add (xclock_now (clockid_for_get),
>                                            make_timespec (0, 200000000));
> 
> -  int val = pthread_timedjoin_np (th, &status, &timeout);
> +  int val;
> +  if (clockid == CLOCK_USE_TIMEDJOIN)
> +    val = pthread_timedjoin_np (th, &status, &timeout);
> +  else
> +    val = pthread_clockjoin_np (th, &status, clockid, &timeout);
> +
>    TEST_COMPARE (val, ETIMEDOUT);
> 
>    xpthread_mutex_unlock (&lock);
> 
> 
> I suspect that it's not causing the test to fail because the existing call
> to pthread_timedjoin_np will just time out immediately if passed the
> relatively small absolute CLOCK_MONOTONIC time. I shall see if I can
> improve this test to catch that in the future.
> 
> Thanks again.
> 
> Mike.

Right, I have updated my personal branch with the missing change, thanks
for spotting it.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 0/4] nptl: Add pthread_clockjoin_np
  2019-10-31 20:51     ` Adhemerval Zanella
@ 2019-11-01 21:05       ` Joseph Myers
  2019-11-01 23:01       ` Rafal Luzynski
  1 sibling, 0 replies; 23+ messages in thread
From: Joseph Myers @ 2019-11-01 21:05 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Mike Crowe, libc-alpha

These changes introduce a testsuite build failure for hppa because they 
fail to update the separate hppa pthread.h.

tst-join3.c: In function 'do_test_clock':
tst-join3.c:63:11: error: implicit declaration of function 'pthread_clockjoin_np'; did you mean 'pthread_timedjoin_np'? [-Werror=implicit-function-declaration]
   63 |     val = pthread_clockjoin_np (th, &status, clockid, &timeout);
      |           ^~~~~~~~~~~~~~~~~~~~
      |           pthread_timedjoin_np
cc1: all warnings being treated as errors


-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 0/4] nptl: Add pthread_clockjoin_np
  2019-10-31 20:51     ` Adhemerval Zanella
  2019-11-01 21:05       ` Joseph Myers
@ 2019-11-01 23:01       ` Rafal Luzynski
  2019-11-02  9:14         ` Mike Crowe
  1 sibling, 1 reply; 23+ messages in thread
From: Rafal Luzynski @ 2019-11-01 23:01 UTC (permalink / raw)
  To: Adhemerval Zanella, Mike Crowe; +Cc: libc-alpha

Mike, Adhemerval,

This patch series contains this excerpt:

> commit 69ca4b54c151cec42ccca5e05790efc1a8206b47
> Author: Mike Crowe <mac@mcrowe.com>
> Date:   Thu Oct 31 10:03:21 2019 -0300
> 
>     nptl: Add pthread_clockjoin_np
>     
>     Introduce pthread_clockjoin_np as a version of pthread_timedjoin_np
> that
>     accepts a clockid_t parameter to indicate which clock the timeout
> should be
>     measured against. This mirrors the recently-added POSIX-proposed
> "clock"
>     wait functions.
>     
>     Checked on x86_64-linux-gnu.
>     
>     Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> 
> diff --git a/NEWS b/NEWS
> index 75b380c0f8..3006b1a8e4 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -34,6 +34,10 @@ Major new features:
>    will always receive a 'struct timezone' whose tz_minuteswest and
>    tz_dsttime fields are zero.
>  
> +* The function pthread_clockjoin_np has been added, enabling join with a
> +  terminated thread with an specific clock.  It allows waiting against

I think: "with a specific" -^^

> [...]
> diff --git a/manual/threads.texi b/manual/threads.texi
> index c0b504dc1f..e40b55c090 100644
> --- a/manual/threads.texi
> +++ b/manual/threads.texi
> @@ -751,6 +751,18 @@ reached if the thread has not terminated by that time
> and return
>  will wait forever in the same way as @code{pthread_join}.
>  @end deftypefun
>  
> +@comment pthread.h
> +@comment GNU extension
> +@deftypefun int pthread_clockjoin_np (pthread_t *@var{thread},
> +                                     void **@var{thread_return},
> +                                      clockid_t @var{clockid},
> +                                     const struct timespec
> *@var{abstime})
> +@standards{GNU, pthread.h}
> +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
> +Behaves like @code{pthread_timedjoin_np} except that time absolute time
> in

Did you mean "that the absolute"? ----------------------^^^^

Regards,

Rafal

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 0/4] nptl: Add pthread_clockjoin_np
  2019-11-01 23:01       ` Rafal Luzynski
@ 2019-11-02  9:14         ` Mike Crowe
  0 siblings, 0 replies; 23+ messages in thread
From: Mike Crowe @ 2019-11-02  9:14 UTC (permalink / raw)
  To: Rafal Luzynski, Joseph Myers; +Cc: Adhemerval Zanella, libc-alpha

Hi Rafal & Joseph,

On Saturday 02 November 2019 at 00:01:37 +0100, Rafal Luzynski wrote:
> Mike, Adhemerval,
>
> This patch series contains this excerpt:
>
> > commit 69ca4b54c151cec42ccca5e05790efc1a8206b47
> > Author: Mike Crowe <mac@mcrowe.com>
> > Date:   Thu Oct 31 10:03:21 2019 -0300
> >
> >     nptl: Add pthread_clockjoin_np
> >
> >     Introduce pthread_clockjoin_np as a version of pthread_timedjoin_np
> > that
> >     accepts a clockid_t parameter to indicate which clock the timeout
> > should be
> >     measured against. This mirrors the recently-added POSIX-proposed
> > "clock"
> >     wait functions.
> >
> >     Checked on x86_64-linux-gnu.
> >
> >     Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> >
> > diff --git a/NEWS b/NEWS
> > index 75b380c0f8..3006b1a8e4 100644
> > --- a/NEWS
> > +++ b/NEWS
> > @@ -34,6 +34,10 @@ Major new features:
> >    will always receive a 'struct timezone' whose tz_minuteswest and
> >    tz_dsttime fields are zero.
> >
> > +* The function pthread_clockjoin_np has been added, enabling join with a
> > +  terminated thread with an specific clock.  It allows waiting against
>
> I think: "with a specific" -^^
>
> > [...]
> > diff --git a/manual/threads.texi b/manual/threads.texi
> > index c0b504dc1f..e40b55c090 100644
> > --- a/manual/threads.texi
> > +++ b/manual/threads.texi
> > @@ -751,6 +751,18 @@ reached if the thread has not terminated by that time
> > and return
> >  will wait forever in the same way as @code{pthread_join}.
> >  @end deftypefun
> >
> > +@comment pthread.h
> > +@comment GNU extension
> > +@deftypefun int pthread_clockjoin_np (pthread_t *@var{thread},
> > +                                     void **@var{thread_return},
> > +                                      clockid_t @var{clockid},
> > +                                     const struct timespec
> > *@var{abstime})
> > +@standards{GNU, pthread.h}
> > +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
> > +Behaves like @code{pthread_timedjoin_np} except that time absolute time
> > in
>
> Did you mean "that the absolute"? ----------------------^^^^

I've posted a patch that fixes this, and the hppa-specific
pthread.h change at
https://sourceware.org/ml/libc-alpha/2019-11/msg00020.html .

Thanks for reviewing this.

Mike.

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2019-11-02  9:14 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18 12:30 [PATCH v2 0/4] nptl: Add pthread_clockjoin_np Mike Crowe
2019-09-18 12:30 ` [PATCH v2 1/4] nptl: Convert tst-join3 to use libsupport Mike Crowe
2019-09-26 20:45   ` Adhemerval Zanella
2019-09-18 12:30 ` [PATCH v2 2/4] manual: Add documentation for pthread_tryjoin_np and pthread_timedjoin_np Mike Crowe
2019-09-26 21:26   ` Adhemerval Zanella
2019-09-27  9:08     ` Yann Droneaud
2019-09-28  8:53     ` Mike Crowe
2019-10-14 19:15       ` Adhemerval Zanella
2019-10-18 16:28         ` Mike Crowe
2019-10-21 18:15           ` Adhemerval Zanella
2019-09-18 12:30 ` [PATCH v2 3/4] nptl: Add pthread_clockjoin_np Mike Crowe
2019-09-26 23:17   ` Adhemerval Zanella
2019-09-28 19:45     ` Mike Crowe
2019-10-14 19:16       ` Adhemerval Zanella
2019-10-08  8:26   ` Mike Crowe
2019-09-18 12:30 ` [PATCH v2 4/4] nptl: Add pthread_timedjoin_np, pthread_clockjoin_np NULL timeout test Mike Crowe
2019-09-26 23:30   ` Adhemerval Zanella
2019-10-31 14:31 ` [PATCH v2 0/4] nptl: Add pthread_clockjoin_np Adhemerval Zanella
2019-10-31 19:38   ` Mike Crowe
2019-10-31 20:51     ` Adhemerval Zanella
2019-11-01 21:05       ` Joseph Myers
2019-11-01 23:01       ` Rafal Luzynski
2019-11-02  9:14         ` Mike Crowe

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).