unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v8 0/8] Add support for ISO C threads.h
@ 2018-02-02 17:04 Adhemerval Zanella
  2018-02-02 17:04 ` [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions Adhemerval Zanella
                   ` (8 more replies)
  0 siblings, 9 replies; 80+ messages in thread
From: Adhemerval Zanella @ 2018-02-02 17:04 UTC (permalink / raw)
  To: libc-alpha

This is a new update for C11 threads support based on my previous [1]
version.  The main changes from previous version are:
 
  - Rebase against 2.28.

  - Add RISCV abilist symbols.
 
  - Adjusted copyright dates for 2018.
 
  - Remove some redundant comments.
 
I tested this without regression with a full make/check on
x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabihf,
sparc64-linux-gnu, and sparcv9-linux-gnu.
 
[1] https://sourceware.org/ml/libc-alpha/2017-09/msg00871.html

Adhemerval Zanella (7):
  nptl: Add C11 threads thrd_* functions
  nptl: Add C11 threads mtx_* functions
  nptl: Add C11 threads call_once functions
  nptl: Add C11 threads cnd_* functions
  nptl: Add C11 threads tss_* functions
  nptl: Add abilist symbols for C11 threads
  nptl: Add test cases for ISO C11 threads

Juan Manuel Torres Palma (1):
  Add manual documentation for threads.h

 ChangeLog                                          | 175 ++++++++++
 conform/Makefile                                   |   7 +-
 conform/data/threads.h-data                        |  57 ++++
 include/stdc-predef.h                              |   3 -
 manual/Makefile                                    |   2 +-
 manual/isothreads.texi                             | 355 +++++++++++++++++++++
 nptl/Makefile                                      |  15 +-
 nptl/Versions                                      |   9 +
 nptl/call_once.c                                   |  31 ++
 nptl/cnd_broadcast.c                               |  26 ++
 nptl/cnd_destroy.c                                 |  26 ++
 nptl/cnd_init.c                                    |  32 ++
 nptl/cnd_signal.c                                  |  26 ++
 nptl/cnd_timedwait.c                               |  29 ++
 nptl/cnd_wait.c                                    |  27 ++
 nptl/descr.h                                       |   2 +
 nptl/mtx_destroy.c                                 |  26 ++
 nptl/mtx_init.c                                    |  52 +++
 nptl/mtx_lock.c                                    |  26 ++
 nptl/mtx_timedlock.c                               |  28 ++
 nptl/mtx_trylock.c                                 |  26 ++
 nptl/mtx_unlock.c                                  |  26 ++
 nptl/pthreadP.h                                    |   3 +
 nptl/pthread_create.c                              |  18 +-
 nptl/thrd_create.c                                 |  29 ++
 nptl/thrd_current.c                                |  25 ++
 nptl/thrd_detach.c                                 |  28 ++
 nptl/thrd_equal.c                                  |  25 ++
 nptl/thrd_exit.c                                   |  25 ++
 nptl/thrd_join.c                                   |  30 ++
 nptl/thrd_priv.h                                   |  45 +++
 nptl/thrd_sleep.c                                  |  38 +++
 nptl/thrd_yield.c                                  |  26 ++
 nptl/tss_create.c                                  |  28 ++
 nptl/tss_delete.c                                  |  25 ++
 nptl/tss_get.c                                     |  25 ++
 nptl/tss_set.c                                     |  26 ++
 nptl/tst-call-once.c                               |  66 ++++
 nptl/tst-cnd-basic.c                               |  68 ++++
 nptl/tst-cnd-broadcast.c                           |  83 +++++
 nptl/tst-cnd-timedwait.c                           |  70 ++++
 nptl/tst-mtx-basic.c                               |  73 +++++
 nptl/tst-mtx-recursive.c                           |  45 +++
 nptl/tst-mtx-timedlock.c                           |  98 ++++++
 nptl/tst-mtx-trylock.c                             |  90 ++++++
 nptl/tst-thrd-detach.c                             |  52 +++
 nptl/tst-thrd-sleep.c                              |  51 +++
 nptl/tst-tss-basic.c                               |  75 +++++
 sysdeps/nptl/threads.h                             | 200 ++++++++++++
 sysdeps/unix/sysv/linux/aarch64/libpthread.abilist |  26 ++
 sysdeps/unix/sysv/linux/alpha/libpthread.abilist   |  26 ++
 sysdeps/unix/sysv/linux/arm/libpthread.abilist     |  26 ++
 sysdeps/unix/sysv/linux/hppa/libpthread.abilist    |  26 ++
 sysdeps/unix/sysv/linux/i386/libpthread.abilist    |  26 ++
 sysdeps/unix/sysv/linux/ia64/libpthread.abilist    |  26 ++
 .../sysv/linux/m68k/coldfire/libpthread.abilist    |  26 ++
 .../unix/sysv/linux/m68k/m680x0/libpthread.abilist |  26 ++
 .../unix/sysv/linux/microblaze/libpthread.abilist  |  26 ++
 .../unix/sysv/linux/mips/mips32/libpthread.abilist |  26 ++
 .../unix/sysv/linux/mips/mips64/libpthread.abilist |  26 ++
 sysdeps/unix/sysv/linux/nios2/libpthread.abilist   |  26 ++
 .../linux/powerpc/powerpc32/libpthread.abilist     |  26 ++
 .../linux/powerpc/powerpc64/libpthread-le.abilist  |  26 ++
 .../linux/powerpc/powerpc64/libpthread.abilist     |  26 ++
 .../unix/sysv/linux/riscv/rv64/libpthread.abilist  |  26 ++
 .../sysv/linux/s390/s390-32/libpthread.abilist     |  26 ++
 .../sysv/linux/s390/s390-64/libpthread.abilist     |  26 ++
 sysdeps/unix/sysv/linux/sh/libpthread.abilist      |  26 ++
 .../sysv/linux/sparc/sparc32/libpthread.abilist    |  26 ++
 .../sysv/linux/sparc/sparc64/libpthread.abilist    |  26 ++
 .../sysv/linux/tile/tilegx32/libpthread.abilist    |  26 ++
 .../sysv/linux/tile/tilegx64/libpthread.abilist    |  26 ++
 .../unix/sysv/linux/x86_64/64/libpthread.abilist   |  26 ++
 .../unix/sysv/linux/x86_64/x32/libpthread.abilist  |  26 ++
 74 files changed, 3011 insertions(+), 12 deletions(-)
 create mode 100644 conform/data/threads.h-data
 create mode 100644 manual/isothreads.texi
 create mode 100644 nptl/call_once.c
 create mode 100644 nptl/cnd_broadcast.c
 create mode 100644 nptl/cnd_destroy.c
 create mode 100644 nptl/cnd_init.c
 create mode 100644 nptl/cnd_signal.c
 create mode 100644 nptl/cnd_timedwait.c
 create mode 100644 nptl/cnd_wait.c
 create mode 100644 nptl/mtx_destroy.c
 create mode 100644 nptl/mtx_init.c
 create mode 100644 nptl/mtx_lock.c
 create mode 100644 nptl/mtx_timedlock.c
 create mode 100644 nptl/mtx_trylock.c
 create mode 100644 nptl/mtx_unlock.c
 create mode 100644 nptl/thrd_create.c
 create mode 100644 nptl/thrd_current.c
 create mode 100644 nptl/thrd_detach.c
 create mode 100644 nptl/thrd_equal.c
 create mode 100644 nptl/thrd_exit.c
 create mode 100644 nptl/thrd_join.c
 create mode 100644 nptl/thrd_priv.h
 create mode 100644 nptl/thrd_sleep.c
 create mode 100644 nptl/thrd_yield.c
 create mode 100644 nptl/tss_create.c
 create mode 100644 nptl/tss_delete.c
 create mode 100644 nptl/tss_get.c
 create mode 100644 nptl/tss_set.c
 create mode 100644 nptl/tst-call-once.c
 create mode 100644 nptl/tst-cnd-basic.c
 create mode 100644 nptl/tst-cnd-broadcast.c
 create mode 100644 nptl/tst-cnd-timedwait.c
 create mode 100644 nptl/tst-mtx-basic.c
 create mode 100644 nptl/tst-mtx-recursive.c
 create mode 100644 nptl/tst-mtx-timedlock.c
 create mode 100644 nptl/tst-mtx-trylock.c
 create mode 100644 nptl/tst-thrd-detach.c
 create mode 100644 nptl/tst-thrd-sleep.c
 create mode 100644 nptl/tst-tss-basic.c
 create mode 100644 sysdeps/nptl/threads.h

-- 
2.7.4



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

* [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-02-02 17:04 [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
@ 2018-02-02 17:04 ` Adhemerval Zanella
  2018-02-08 13:49   ` Gabriel F. T. Gomes
                     ` (5 more replies)
  2018-02-02 17:04 ` [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions Adhemerval Zanella
                   ` (7 subsequent siblings)
  8 siblings, 6 replies; 80+ messages in thread
From: Adhemerval Zanella @ 2018-02-02 17:04 UTC (permalink / raw)
  To: libc-alpha

This patch adds the thrd_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically thrd_create, thrd_curent, rhd_detach, thrd_equal,
thrd_exit, thrd_join, thrd_sleep, thrd_yield, and required types.

Mostly of the definitions are composed based on POSIX conterparts, such as
thrd_t (using pthread_t).  For thrd_* function internally direct
POSIX pthread call are used with the exceptions:

  1. thrd_start uses pthread_create internal implementation, but changes
     how to actually calls the start routine.  This is due the difference
     in signature between POSIX and C11, where former return a 'void *'
     and latter 'int'.
     To avoid calling convention issues due 'void *' to int cast, routines
     from C11 threads are started slight different than default pthread one.
     Explicit cast to expected return are used internally on pthread_create
     and the result is stored back to void also with an explicit cast.

  2. thrd_sleep uses nanosleep internal direct syscall to avoid clobbering
     errno, to handle expected standard return codes, and to avoid making
     the call a POSIX cancellation entrypoint.

  3. thrd_yield also uses internal direct syscall to avoid errno clobbering.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	* conform/Makefile (conformtest-headers-ISO11): Add threads.h.
	(linknamespace-libs-ISO11): Add libpthread.a.
	* conform/data/threads.h-data: New file: add C11 thrd_* types and
	functions.
	* include/stdc-predef.h (__STDC_NO_THREADS__): Remove definition.
	* nptl/Makefile (headers): Add threads.h.
	(libpthread-routines): Add new C11 thread thrd_create, thrd_current,
	thrd_detach, thrd_equal, thrd_exit, thrd_join, thrd_sleep, and
	thrd_yield.
	* nptl/Versions (libpthread) [GLIBC_2.27]): Add new C11 thread
	thrd_create, thrd_current, thrd_detach, thrd_equal, thrd_exit,
	thrd_join, thrd_sleep, and thrd_yield symbols.
	* nptl/descr.h (struct pthread): Add c11 field.
	* nptl/pthreadP.h (ATTR_C11_THREAD): New define.
	* nptl/pthread_create.c (START_THREAD_DEFN): Call C11 thread start
	routine with expected function prototype.
	(__pthread_create_2_1): Add C11 threads check based on attribute
	value.
	* nptl/thrd_create.c: New file.
	* nptl/thrd_current.c: Likewise.
	* nptl/thrd_detach.c: Likewise.
	* nptl/thrd_equal.c: Likewise.
	* nptl/thrd_exit.c: Likewise.
	* nptl/thrd_join.c: Likewise.
	* nptl/thrd_priv.h: Likewise.
	* nptl/thrd_sleep.c: Likewise.
	* nptl/thrd_yield.c: Likewise.
	* sysdeps/nptl/threads.h: Likewise.
---
 ChangeLog                   | 31 ++++++++++++++++
 conform/Makefile            |  7 ++--
 conform/data/threads.h-data | 23 ++++++++++++
 include/stdc-predef.h       |  3 --
 nptl/Makefile               |  6 ++-
 nptl/Versions               |  6 +++
 nptl/descr.h                |  2 +
 nptl/pthreadP.h             |  3 ++
 nptl/pthread_create.c       | 18 ++++++++-
 nptl/thrd_create.c          | 29 +++++++++++++++
 nptl/thrd_current.c         | 25 +++++++++++++
 nptl/thrd_detach.c          | 28 ++++++++++++++
 nptl/thrd_equal.c           | 25 +++++++++++++
 nptl/thrd_exit.c            | 25 +++++++++++++
 nptl/thrd_join.c            | 30 +++++++++++++++
 nptl/thrd_priv.h            | 45 +++++++++++++++++++++++
 nptl/thrd_sleep.c           | 38 +++++++++++++++++++
 nptl/thrd_yield.c           | 26 +++++++++++++
 sysdeps/nptl/threads.h      | 90 +++++++++++++++++++++++++++++++++++++++++++++
 19 files changed, 450 insertions(+), 10 deletions(-)
 create mode 100644 conform/data/threads.h-data
 create mode 100644 nptl/thrd_create.c
 create mode 100644 nptl/thrd_current.c
 create mode 100644 nptl/thrd_detach.c
 create mode 100644 nptl/thrd_equal.c
 create mode 100644 nptl/thrd_exit.c
 create mode 100644 nptl/thrd_join.c
 create mode 100644 nptl/thrd_priv.h
 create mode 100644 nptl/thrd_sleep.c
 create mode 100644 nptl/thrd_yield.c
 create mode 100644 sysdeps/nptl/threads.h

diff --git a/conform/Makefile b/conform/Makefile
index 864fdec..82248ab 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -34,9 +34,9 @@ conformtest-headers-ISO := assert.h ctype.h errno.h float.h limits.h locale.h \
 conformtest-headers-ISO99 := $(conformtest-headers-ISO) complex.h fenv.h \
 			     inttypes.h iso646.h stdbool.h stdint.h tgmath.h \
 			     wchar.h wctype.h
-# Missing ISO11 expectations for: stdatomic.h threads.h.
+# Missing ISO11 expectations for: stdatomic.h
 conformtest-headers-ISO11 := $(conformtest-headers-ISO99) stdalign.h \
-			     stdnoreturn.h uchar.h
+			     stdnoreturn.h threads.h uchar.h
 conformtest-headers-POSIX := $(conformtest-headers-ISO) aio.h dirent.h \
 			     fcntl.h fnmatch.h glob.h grp.h mqueue.h \
 			     pthread.h pwd.h regex.h sched.h semaphore.h \
@@ -197,7 +197,8 @@ linknamespace-libs-xsi = $(linknamespace-libs-posix) \
 			 $(common-objpfx)crypt/libcrypt.a
 linknamespace-libs-ISO = $(linknamespace-libs-isoc)
 linknamespace-libs-ISO99 = $(linknamespace-libs-isoc)
-linknamespace-libs-ISO11 = $(linknamespace-libs-isoc)
+linknamespace-libs-ISO11 = $(linknamespace-libs-isoc) \
+			   $(common-objpfx)nptl/libpthread.a
 linknamespace-libs-XPG4 = $(linknamespace-libs-isoc) \
 			  $(common-objpfx)crypt/libcrypt.a
 linknamespace-libs-XPG42 = $(linknamespace-libs-XPG4)
diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data
new file mode 100644
index 0000000..bc2d857
--- /dev/null
+++ b/conform/data/threads.h-data
@@ -0,0 +1,23 @@
+#if defined ISO11
+
+constant thrd_success
+constant thrd_busy
+constant thrd_error
+constant thrd_nomem
+constant thrd_timedout
+
+type thrd_t
+type thrd_start_t
+
+function int thrd_create (thrd_t*, thrd_start_t, void*)
+function int thrd_equal (thrd_t, thrd_t)
+function thrd_t thrd_current (void)
+function int thrd_sleep (const struct timespec*, struct timespec*)
+function void thrd_exit (int)
+function int thrd_detach (thrd_t)
+function int thrd_join (thrd_t, int*)
+function void thrd_yield (void)
+
+#include "time.h-data"
+
+#endif
diff --git a/include/stdc-predef.h b/include/stdc-predef.h
index c569759..c2ab78a 100644
--- a/include/stdc-predef.h
+++ b/include/stdc-predef.h
@@ -57,7 +57,4 @@
    - 3 additional Zanabazar Square characters */
 #define __STDC_ISO_10646__		201706L
 
-/* We do not support C11 <threads.h>.  */
-#define __STDC_NO_THREADS__		1
-
 #endif
diff --git a/nptl/Makefile b/nptl/Makefile
index 6fc2c8b..a853c46 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -22,7 +22,7 @@ subdir	:= nptl
 
 include ../Makeconfig
 
-headers := pthread.h semaphore.h bits/semaphore.h
+headers := pthread.h semaphore.h bits/semaphore.h threads.h
 
 extra-libs := libpthread
 extra-libs-others := $(extra-libs)
@@ -139,7 +139,9 @@ libpthread-routines = nptl-init vars events version pt-interp \
 		      pthread_mutex_getprioceiling \
 		      pthread_mutex_setprioceiling \
 		      pthread_setname pthread_getname \
-		      pthread_setattr_default_np pthread_getattr_default_np
+		      pthread_setattr_default_np pthread_getattr_default_np \
+		      thrd_create thrd_current thrd_detach thrd_equal \
+		      thrd_exit thrd_join thrd_sleep thrd_yield
 #		      pthread_setuid pthread_seteuid pthread_setreuid \
 #		      pthread_setresuid \
 #		      pthread_setgid pthread_setegid pthread_setregid \
diff --git a/nptl/Versions b/nptl/Versions
index 0ae5def..4905c84 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -265,6 +265,12 @@ libpthread {
   GLIBC_2.22 {
   }
 
+  # C11 thread symbols.
+  GLIBC_2.28 {
+    thrd_create; thrd_current; thrd_detach; thrd_equal; thrd_exit; thrd_join;
+    thrd_sleep; thrd_yield;
+  }
+
   GLIBC_PRIVATE {
     __pthread_initialize_minimal;
     __pthread_clock_gettime; __pthread_clock_settime;
diff --git a/nptl/descr.h b/nptl/descr.h
index 64ba29e..f00e2c0 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -371,6 +371,8 @@ struct pthread
      to the function.  */
   void *(*start_routine) (void *);
   void *arg;
+  /* Indicates whether is a C11 thread created by thrd_creat.  */
+  bool c11;
 
   /* Debug state.  */
   td_eventbuf_t eventbuf;
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index 583515f..83b730c 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -173,6 +173,9 @@ enum
 #define __PTHREAD_ONCE_DONE		2
 #define __PTHREAD_ONCE_FORK_GEN_INCR	4
 
+/* Attribute to indicate thread creation was issued from C11 thrd_create.  */
+#define ATTR_C11_THREAD ((void*)(uintptr_t)-1)
+
 
 /* Condition variable definitions.  See __pthread_cond_wait_common.
    Need to be defined here so there is one place from which
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index caaf07c..74e773a 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -460,7 +460,19 @@ START_THREAD_DEFN
       LIBC_PROBE (pthread_start, 3, (pthread_t) pd, pd->start_routine, pd->arg);
 
       /* Run the code the user provided.  */
-      THREAD_SETMEM (pd, result, pd->start_routine (pd->arg));
+      void *ret;
+      if (pd->c11)
+	{
+	  /* The function pointer of the c11 thread start is cast to an incorrect
+	     type on __pthread_create_2_1 call, however it is casted back to correct
+	     one so the call behavior is well-defined (it is assumed that pointers
+	     to void are able to represent all values of int.  */
+	  int (*start)(void*) = (int (*) (void*)) pd->start_routine;
+	  ret = (void*) (intptr_t) start (pd->arg);
+	}
+      else
+	ret = pd->start_routine (pd->arg);
+      THREAD_SETMEM (pd, result, ret);
     }
 
   /* Call destructors for the thread_local TLS variables.  */
@@ -613,7 +625,8 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
   const struct pthread_attr *iattr = (struct pthread_attr *) attr;
   struct pthread_attr default_attr;
   bool free_cpuset = false;
-  if (iattr == NULL)
+  bool c11 = (attr == ATTR_C11_THREAD);
+  if (iattr == NULL || c11)
     {
       lll_lock (__default_pthread_attr_lock, LLL_PRIVATE);
       default_attr = __default_pthread_attr;
@@ -671,6 +684,7 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
      get the information from its thread descriptor.  */
   pd->start_routine = start_routine;
   pd->arg = arg;
+  pd->c11 = c11;
 
   /* Copy the thread attribute flags.  */
   struct pthread *self = THREAD_SELF;
diff --git a/nptl/thrd_create.c b/nptl/thrd_create.c
new file mode 100644
index 0000000..d39034c
--- /dev/null
+++ b/nptl/thrd_create.c
@@ -0,0 +1,29 @@
+/* C11 threads thread creation implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+thrd_create (thrd_t *thr, thrd_start_t func, void *arg)
+{
+  _Static_assert (sizeof (thr) == sizeof (pthread_t), "thrd_t size");
+
+  int err_code = __pthread_create_2_1 (thr, ATTR_C11_THREAD,
+				       (void* (*) (void*))func, arg);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/thrd_current.c b/nptl/thrd_current.c
new file mode 100644
index 0000000..a1c73b2
--- /dev/null
+++ b/nptl/thrd_current.c
@@ -0,0 +1,25 @@
+/* C11 threads current thread implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+thrd_t
+thrd_current (void)
+{
+  return (thrd_t) THREAD_SELF;
+}
diff --git a/nptl/thrd_detach.c b/nptl/thrd_detach.c
new file mode 100644
index 0000000..be2c3e1
--- /dev/null
+++ b/nptl/thrd_detach.c
@@ -0,0 +1,28 @@
+/* C11 threads thread detach implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+thrd_detach (thrd_t thr)
+{
+  int err_code;
+
+  err_code = __pthread_detach (thr);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/thrd_equal.c b/nptl/thrd_equal.c
new file mode 100644
index 0000000..951ab40
--- /dev/null
+++ b/nptl/thrd_equal.c
@@ -0,0 +1,25 @@
+/* C11 threads thread equality check implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+thrd_equal (thrd_t lhs, thrd_t rhs)
+{
+  return __pthread_equal (lhs, rhs);
+}
diff --git a/nptl/thrd_exit.c b/nptl/thrd_exit.c
new file mode 100644
index 0000000..6b37774
--- /dev/null
+++ b/nptl/thrd_exit.c
@@ -0,0 +1,25 @@
+/* C11 threads thread exit implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+_Noreturn void
+thrd_exit (int res)
+{
+  __pthread_exit ((void*)(uintptr_t) res);
+}
diff --git a/nptl/thrd_join.c b/nptl/thrd_join.c
new file mode 100644
index 0000000..d3dbcdb
--- /dev/null
+++ b/nptl/thrd_join.c
@@ -0,0 +1,30 @@
+/* C11 threads thread join implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+thrd_join (thrd_t thr, int *res)
+{
+  void *pthread_res;
+  int err_code = __pthread_join (thr, &pthread_res);
+  if (res)
+   *res = (int)((uintptr_t) pthread_res);
+
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/thrd_priv.h b/nptl/thrd_priv.h
new file mode 100644
index 0000000..97f4102
--- /dev/null
+++ b/nptl/thrd_priv.h
@@ -0,0 +1,45 @@
+/* Internal C11 threads definitions.
+   Copyright (C) 2018 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/>.  */
+
+#ifndef THRD_PRIV_H
+# define THRD_PRIV_H
+
+#include <features.h>
+#include <threads.h>
+#include <errno.h>
+#include "pthreadP.h"	/* For pthread_{mutex,cond}_t definitions.  */
+
+static __always_inline int
+thrd_err_map (int err_code)
+{
+  switch (err_code)
+  {
+    case 0:
+      return thrd_success;
+    case ENOMEM:
+      return thrd_nomem;
+    case ETIMEDOUT:
+      return thrd_timedout;
+    case EBUSY:
+      return thrd_busy;
+    default:
+      return thrd_error;
+  }
+}
+
+#endif
diff --git a/nptl/thrd_sleep.c b/nptl/thrd_sleep.c
new file mode 100644
index 0000000..9f5a28f
--- /dev/null
+++ b/nptl/thrd_sleep.c
@@ -0,0 +1,38 @@
+/* C11 threads thread sleep implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+#include <time.h>
+
+int
+thrd_sleep (const struct timespec* time_point, struct timespec* remaining)
+{
+  /* It calls the syscalls directly to avoid cancellable version.  */
+  INTERNAL_SYSCALL_DECL (err);
+  int ret = INTERNAL_SYSCALL_CALL (nanosleep, err, time_point, remaining);
+  if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+    {
+      /* C11 states thrd_sleep function returns -1 if it has been interrupted
+         by a signal, or a negative value if it fails.  */
+      ret = INTERNAL_SYSCALL_ERRNO (ret, err);
+      if (ret == EINTR)
+	return -1;
+      return -2;
+    }
+  return 0;
+}
diff --git a/nptl/thrd_yield.c b/nptl/thrd_yield.c
new file mode 100644
index 0000000..9ebcbae
--- /dev/null
+++ b/nptl/thrd_yield.c
@@ -0,0 +1,26 @@
+/* C11 threads thread yield implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+void
+thrd_yield (void)
+{
+  INTERNAL_SYSCALL_DECL (err);
+  INTERNAL_SYSCALL_CALL (sched_yield, err);
+}
diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h
new file mode 100644
index 0000000..6adcac4
--- /dev/null
+++ b/sysdeps/nptl/threads.h
@@ -0,0 +1,90 @@
+/* ISO C11 Standard: 7.26 - Thread support library  <threads.h>.
+   Copyright (C) 2018 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/>.  */
+
+#ifndef _THREADS_H
+#define _THREADS_H	1
+
+#include <features.h>
+#include <time.h>
+
+__BEGIN_DECLS
+
+#include <bits/types/struct_timespec.h>
+
+typedef unsigned long int thrd_t;
+typedef int (*thrd_start_t) (void*);
+
+/* Exit and error codes.  */
+enum
+{
+  thrd_success  = 0,
+  thrd_busy     = 1,
+  thrd_error    = 2,
+  thrd_nomem    = 3,
+  thrd_timedout = 4
+};
+
+/* Threads functions.  */
+
+/* Create a new thread executing the function __FUNC.  Arguments for __FUNC
+   are passed through __ARG.  If succesful, __THR is set to new thread
+   identifier.  */
+extern int thrd_create (thrd_t *__thr, thrd_start_t __func, void *__arg);
+
+/* Check if __LHS and __RHS point to the same thread.  */
+extern int thrd_equal (thrd_t __lhs, thrd_t __rhs);
+
+/* Return current thread identifier.  */
+extern thrd_t thrd_current (void);
+
+/* Block current thread execution for at least the time pointed by
+   __TIME_POINT.  The current thread may resume if receives a signal.  In
+   that case, if __REMAINING is not NULL, the remaining time is stored in
+   the object pointed by it.  */
+extern int thrd_sleep (const struct timespec *__time_point,
+		       struct timespec *__remaining);
+
+/* Terminate current thread execution, cleaning up any thread local
+   storage and freeing resources.  Returns the value specified in __RES.  */
+extern void thrd_exit (int __res) __attribute__ ((__noreturn__));
+
+/* Detach the thread identified by __THR from the current environment
+   (tt does not allow join or wait for it).  */
+extern int thrd_detach (thrd_t __thr);
+
+/* Block current thread until execution of __THR is complete.  In case that
+   __RES is not NULL, will store the return value of __THR when exiting.  */
+extern int thrd_join (thrd_t __thr, int *__res);
+
+/* Stop current thread execution and call the scheduler to decide which
+   thread should execute next.  The current thread may be selected by the
+   scheduler to keep running.  */
+extern void thrd_yield (void);
+
+#ifdef __USE_EXTERN_INLINES
+/* Optimizations.  */
+__extern_inline int
+thrd_equal (thrd_t __thread1, thrd_t __thread2)
+{
+  return __thread1 == __thread2;
+}
+#endif
+
+__END_DECLS
+
+#endif /* _THREADS_H */
-- 
2.7.4



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

* [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions
  2018-02-02 17:04 [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
  2018-02-02 17:04 ` [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions Adhemerval Zanella
@ 2018-02-02 17:04 ` Adhemerval Zanella
  2018-07-06 12:51   ` Florian Weimer
  2018-07-24 12:04   ` Adhemerval Zanella
  2018-02-02 17:04 ` [PATCH v8 3/8] nptl: Add C11 threads call_once functions Adhemerval Zanella
                   ` (6 subsequent siblings)
  8 siblings, 2 replies; 80+ messages in thread
From: Adhemerval Zanella @ 2018-02-02 17:04 UTC (permalink / raw)
  To: libc-alpha

This patch adds the mtx_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically mtx_init, mtx_destroy, mtx_lock, mtx_timedlock, mtx_trylock,
mtx_unlock, and required types.

Mostly of the definitions are composed based on POSIX conterparts, and mtx_t
is also based on internal pthread fields, but with a distinct internal layout
to avoid possible issues with code interchange (such as trying to pass POSIX
structure on C11 functions and to avoid inclusion of pthread.h).  The idea
is to make possible to share POSIX internal implementations for mostly of
the code (and making adjustment only when required).

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	* conform/data/threads.h-data (mtx_plain): New constant.
	(mtx_recursive): Likewise.
	(mtx_timed): Likewise.
	(mtx_t): New type.
	(mtx_init): New function.
	(mtx_lock): Likewise.
	(mtx_timedlock): Likewise.
	(mtx_trylock): Likewise.
	(mtx_unlock): Likewise.
	(mtx_destroy): Likewise.
	* nptl/Makefile (libpthread-routines): Add mtx_destroy, mtx_init,
	mtx_lock, mtx_timedlock, mtx_trylock, and mtx_unlock object.
	* nptl/Versions (libpthread) [GLIBC_2.27]): Add mtx_init, mtx_lock,
	mtx_timedlock, mtx_trylock, mtx_unlock, and mtx_destroy.
	* nptl/mtx_destroy.c: New file.
	* nptl/mtx_init.c: Likewise.
	* nptl/mtx_lock.c: Likewise.
	* nptl/mtx_timedlock.c: Likewise.
	* nptl/mtx_trylock.c: Likewise.
	* nptl/mtx_unlock.c: Likewise.
	* sysdeps/nptl/threads.h (mtx_plain): New enumeration.
	(mtx_recursive): Likewise.
	(mtx_timed): Likewise.
	(mtx_t): New type.
	(mtx_init): New prototype.
	(mtx_lock): Likewise.
	(mtx_timedlock): Likewise.
	(mtx_trylock): Likewise.
	(mtx_unlock): Likewise.
	(mtx_destroy): Likewise.
---
 ChangeLog                   | 31 +++++++++++++++++++++++++++
 conform/data/threads.h-data | 12 +++++++++++
 nptl/Makefile               |  4 +++-
 nptl/Versions               |  3 ++-
 nptl/mtx_destroy.c          | 26 +++++++++++++++++++++++
 nptl/mtx_init.c             | 52 +++++++++++++++++++++++++++++++++++++++++++++
 nptl/mtx_lock.c             | 26 +++++++++++++++++++++++
 nptl/mtx_timedlock.c        | 28 ++++++++++++++++++++++++
 nptl/mtx_trylock.c          | 26 +++++++++++++++++++++++
 nptl/mtx_unlock.c           | 26 +++++++++++++++++++++++
 sysdeps/nptl/threads.h      | 44 ++++++++++++++++++++++++++++++++++++++
 11 files changed, 276 insertions(+), 2 deletions(-)
 create mode 100644 nptl/mtx_destroy.c
 create mode 100644 nptl/mtx_init.c
 create mode 100644 nptl/mtx_lock.c
 create mode 100644 nptl/mtx_timedlock.c
 create mode 100644 nptl/mtx_trylock.c
 create mode 100644 nptl/mtx_unlock.c

diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data
index bc2d857..bb5ca75 100644
--- a/conform/data/threads.h-data
+++ b/conform/data/threads.h-data
@@ -6,8 +6,13 @@ constant thrd_error
 constant thrd_nomem
 constant thrd_timedout
 
+constant mtx_plain
+constant mtx_recursive
+constant mtx_timed
+
 type thrd_t
 type thrd_start_t
+type mtx_t
 
 function int thrd_create (thrd_t*, thrd_start_t, void*)
 function int thrd_equal (thrd_t, thrd_t)
@@ -18,6 +23,13 @@ function int thrd_detach (thrd_t)
 function int thrd_join (thrd_t, int*)
 function void thrd_yield (void)
 
+function int mtx_init (mtx_t*, int)
+function int mtx_lock (mtx_t*)
+function int mtx_timedlock (mtx_t*, const struct timespec*)
+function int mtx_trylock (mtx_t*)
+function int mtx_unlock (mtx_t*)
+function void mtx_destroy (mtx_t*)
+
 #include "time.h-data"
 
 #endif
diff --git a/nptl/Makefile b/nptl/Makefile
index a853c46..1b8a6a8 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -141,7 +141,9 @@ libpthread-routines = nptl-init vars events version pt-interp \
 		      pthread_setname pthread_getname \
 		      pthread_setattr_default_np pthread_getattr_default_np \
 		      thrd_create thrd_current thrd_detach thrd_equal \
-		      thrd_exit thrd_join thrd_sleep thrd_yield
+		      thrd_exit thrd_join thrd_sleep thrd_yield \
+		      mtx_destroy mtx_init mtx_lock mtx_timedlock \
+		      mtx_trylock mtx_unlock
 #		      pthread_setuid pthread_seteuid pthread_setreuid \
 #		      pthread_setresuid \
 #		      pthread_setgid pthread_setegid pthread_setregid \
diff --git a/nptl/Versions b/nptl/Versions
index 4905c84..a1969e3 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -268,7 +268,8 @@ libpthread {
   # C11 thread symbols.
   GLIBC_2.28 {
     thrd_create; thrd_current; thrd_detach; thrd_equal; thrd_exit; thrd_join;
-    thrd_sleep; thrd_yield;
+    thrd_sleep; thrd_yield; mtx_init; mtx_lock; mtx_timedlock; mtx_trylock;
+    mtx_unlock; mtx_destroy;
   }
 
   GLIBC_PRIVATE {
diff --git a/nptl/mtx_destroy.c b/nptl/mtx_destroy.c
new file mode 100644
index 0000000..15bc022
--- /dev/null
+++ b/nptl/mtx_destroy.c
@@ -0,0 +1,26 @@
+/* C11 threads mutex destroy implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+#include "pthreadP.h"
+
+void
+mtx_destroy (mtx_t *mutex)
+{
+  __pthread_mutex_destroy ((pthread_mutex_t *) mutex);
+}
diff --git a/nptl/mtx_init.c b/nptl/mtx_init.c
new file mode 100644
index 0000000..594dbf3
--- /dev/null
+++ b/nptl/mtx_init.c
@@ -0,0 +1,52 @@
+/* C11 threads mutex initialization implementation.
+   Copyright (C) 2018 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 <stdalign.h>
+
+#include "thrd_priv.h"
+
+int
+mtx_init (mtx_t *mutex, int type)
+{
+  _Static_assert (sizeof (mtx_t) == sizeof (pthread_mutex_t), "mtx_t size");
+  _Static_assert (alignof (mtx_t) == alignof (pthread_mutex_t),
+		  "mtx_t alignment");
+
+  pthread_mutexattr_t attr;
+
+  __pthread_mutexattr_init (&attr);
+
+  /* Another possible solution would be to set the flags directly in
+     mutex object. */
+  switch (type)
+  {
+    case mtx_plain | mtx_recursive:
+    case mtx_timed | mtx_recursive:
+      __pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
+      break;
+    case mtx_plain:
+    case mtx_timed: /* No difference between both in standard */
+    default:
+      __pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_NORMAL);
+      break;
+  }
+
+  int err_code = __pthread_mutex_init ((pthread_mutex_t *) mutex, &attr);
+  /* pthread_mutexattr_destroy implementation is a noop.  */
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/mtx_lock.c b/nptl/mtx_lock.c
new file mode 100644
index 0000000..9b3e6cd
--- /dev/null
+++ b/nptl/mtx_lock.c
@@ -0,0 +1,26 @@
+/* C11 threads mutex lock implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+mtx_lock (mtx_t *mutex)
+{
+  int err_code = __pthread_mutex_lock ((pthread_mutex_t *) mutex);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/mtx_timedlock.c b/nptl/mtx_timedlock.c
new file mode 100644
index 0000000..0972622
--- /dev/null
+++ b/nptl/mtx_timedlock.c
@@ -0,0 +1,28 @@
+/* C11 threads mutex timed lock implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+mtx_timedlock (mtx_t *restrict mutex,
+	       const struct timespec *restrict time_point)
+{
+  int err_code = __pthread_mutex_timedlock ((pthread_mutex_t *)mutex,
+					    time_point);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/mtx_trylock.c b/nptl/mtx_trylock.c
new file mode 100644
index 0000000..f9b6a69
--- /dev/null
+++ b/nptl/mtx_trylock.c
@@ -0,0 +1,26 @@
+/* C11 threads mutex try lock implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+mtx_trylock (mtx_t *mutex)
+{
+  int err_code = __pthread_mutex_trylock ((pthread_mutex_t *) mutex);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/mtx_unlock.c b/nptl/mtx_unlock.c
new file mode 100644
index 0000000..07f68f6
--- /dev/null
+++ b/nptl/mtx_unlock.c
@@ -0,0 +1,26 @@
+/* C11 threads mutex unlock implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+mtx_unlock (mtx_t *mutex)
+{
+  int err_code = __pthread_mutex_unlock ((pthread_mutex_t *) mutex);
+  return thrd_err_map (err_code);
+}
diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h
index 6adcac4..42d9b5c 100644
--- a/sysdeps/nptl/threads.h
+++ b/sysdeps/nptl/threads.h
@@ -24,6 +24,7 @@
 
 __BEGIN_DECLS
 
+#include <bits/pthreadtypes-arch.h>
 #include <bits/types/struct_timespec.h>
 
 typedef unsigned long int thrd_t;
@@ -39,6 +40,20 @@ enum
   thrd_timedout = 4
 };
 
+/* Mutex types.  */
+enum
+{
+  mtx_plain     = 0,
+  mtx_recursive = 1,
+  mtx_timed     = 2
+};
+
+typedef union
+{
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];
+  long int __align __LOCK_ALIGNMENT;
+} mtx_t;
+
 /* Threads functions.  */
 
 /* Create a new thread executing the function __FUNC.  Arguments for __FUNC
@@ -85,6 +100,35 @@ thrd_equal (thrd_t __thread1, thrd_t __thread2)
 }
 #endif
 
+
+/* Mutex functions.  */
+
+/* Creates a new mutex object with type __TYPE.  If successful the new
+   object is pointed by __MUTEX.  */
+extern int mtx_init (mtx_t *__mutex, int __type);
+
+/* Block the current thread until the mutex pointed to by __MUTEX is
+   unlocked.  In that case current thread will not be blocked.  */
+extern int mtx_lock (mtx_t *__mutex);
+
+/* Block the current thread until the mutex pointed by __MUTEX is unlocked
+   or time pointed by __TIME_POINT is reached.  In case the mutex is unlock,
+   the current thread will not be blocked.  */
+extern int mtx_timedlock (mtx_t *__restrict __mutex,
+			  const struct timespec *__restrict __time_point);
+
+/* Try to lock the mutex pointed by __MUTEX without blocking.  If the mutex
+   is free the current threads takes control of it, otherwise it returns
+   immediately.  */
+extern int mtx_trylock (mtx_t *__mutex);
+
+/* Unlock the mutex pointed by __MUTEX.  It may potentially awake other
+   threads waiting on this mutex.  */
+extern int mtx_unlock (mtx_t *__mutex);
+
+/* Destroy the mutex object pointed by __MUTEX.  */
+extern void mtx_destroy (mtx_t *__mutex);
+
 __END_DECLS
 
 #endif /* _THREADS_H */
-- 
2.7.4



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

* [PATCH v8 3/8] nptl: Add C11 threads call_once functions
  2018-02-02 17:04 [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
  2018-02-02 17:04 ` [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions Adhemerval Zanella
  2018-02-02 17:04 ` [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions Adhemerval Zanella
@ 2018-02-02 17:04 ` Adhemerval Zanella
  2018-07-13  9:32   ` Florian Weimer
  2018-02-02 17:04 ` [PATCH v8 4/8] nptl: Add C11 threads cnd_* functions Adhemerval Zanella
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-02-02 17:04 UTC (permalink / raw)
  To: libc-alpha

This patch adds the call_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically call_once and required types.

Mostly of the definitions are composed based on POSIX conterparts,including
once_flag (pthread_once_t).  The idea is to make possible to share POSIX
internal implementations for mostly of the code (and making adjustment only
when required).

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	* conform/data/threads.h-data (ONCE_FLAG_INIT): New macro.
	(once_flag): New type.
	(call_once): New function.
	* nptl/Makefile (libpthread-routines): Add call_once object.
	* nptl/Versions (libphread) [GLIBC_2.27]: Add call_once symbol.
	* nptl/call_once.c: New file.
	* sysdeps/nptl/threads.h (ONCE_FLAG_INIT): New define.
	(once_flag): New type.
	(call_once): New prototype.
---
 ChangeLog                   | 10 ++++++++++
 conform/data/threads.h-data |  5 +++++
 nptl/Makefile               |  2 +-
 nptl/Versions               |  2 +-
 nptl/call_once.c            | 31 +++++++++++++++++++++++++++++++
 sysdeps/nptl/threads.h      |  8 ++++++++
 6 files changed, 56 insertions(+), 2 deletions(-)
 create mode 100644 nptl/call_once.c

diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data
index bb5ca75..70b2fe0 100644
--- a/conform/data/threads.h-data
+++ b/conform/data/threads.h-data
@@ -1,5 +1,7 @@
 #if defined ISO11
 
+macro ONCE_FLAG_INIT
+
 constant thrd_success
 constant thrd_busy
 constant thrd_error
@@ -13,6 +15,7 @@ constant mtx_timed
 type thrd_t
 type thrd_start_t
 type mtx_t
+type once_flag
 
 function int thrd_create (thrd_t*, thrd_start_t, void*)
 function int thrd_equal (thrd_t, thrd_t)
@@ -30,6 +33,8 @@ function int mtx_trylock (mtx_t*)
 function int mtx_unlock (mtx_t*)
 function void mtx_destroy (mtx_t*)
 
+function void call_once (once_flag*, void (*)(void))
+
 #include "time.h-data"
 
 #endif
diff --git a/nptl/Makefile b/nptl/Makefile
index 1b8a6a8..e539df8 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -143,7 +143,7 @@ libpthread-routines = nptl-init vars events version pt-interp \
 		      thrd_create thrd_current thrd_detach thrd_equal \
 		      thrd_exit thrd_join thrd_sleep thrd_yield \
 		      mtx_destroy mtx_init mtx_lock mtx_timedlock \
-		      mtx_trylock mtx_unlock
+		      mtx_trylock mtx_unlock call_once
 #		      pthread_setuid pthread_seteuid pthread_setreuid \
 #		      pthread_setresuid \
 #		      pthread_setgid pthread_setegid pthread_setregid \
diff --git a/nptl/Versions b/nptl/Versions
index a1969e3..f09e295 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -269,7 +269,7 @@ libpthread {
   GLIBC_2.28 {
     thrd_create; thrd_current; thrd_detach; thrd_equal; thrd_exit; thrd_join;
     thrd_sleep; thrd_yield; mtx_init; mtx_lock; mtx_timedlock; mtx_trylock;
-    mtx_unlock; mtx_destroy;
+    mtx_unlock; mtx_destroy; call_once;
   }
 
   GLIBC_PRIVATE {
diff --git a/nptl/call_once.c b/nptl/call_once.c
new file mode 100644
index 0000000..d66d728
--- /dev/null
+++ b/nptl/call_once.c
@@ -0,0 +1,31 @@
+/* C11 threads call once implementation.
+   Copyright (C) 2018 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 <stdalign.h>
+
+#include "thrd_priv.h"
+
+void
+call_once (once_flag *flag, void (*func)(void))
+{
+  _Static_assert (sizeof (once_flag) == sizeof (pthread_once_t),
+		  "once_flag size");
+  _Static_assert (alignof (once_flag) == alignof (pthread_once_t),
+		  "once_flag alignment");
+  __pthread_once (flag, func);
+}
diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h
index 42d9b5c..6c9c3ef 100644
--- a/sysdeps/nptl/threads.h
+++ b/sysdeps/nptl/threads.h
@@ -27,8 +27,11 @@ __BEGIN_DECLS
 #include <bits/pthreadtypes-arch.h>
 #include <bits/types/struct_timespec.h>
 
+#define ONCE_FLAG_INIT 0
+
 typedef unsigned long int thrd_t;
 typedef int (*thrd_start_t) (void*);
+typedef int __ONCE_ALIGNMENT once_flag;
 
 /* Exit and error codes.  */
 enum
@@ -129,6 +132,11 @@ extern int mtx_unlock (mtx_t *__mutex);
 /* Destroy the mutex object pointed by __MUTEX.  */
 extern void mtx_destroy (mtx_t *__mutex);
 
+
+/* Call function __FUNC exactly once, even if invoked from several threads.
+   All calls must be made with the same __FLAGS object.  */
+extern void call_once (once_flag *__flag, void (*__func)(void));
+
 __END_DECLS
 
 #endif /* _THREADS_H */
-- 
2.7.4



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

* [PATCH v8 4/8] nptl: Add C11 threads cnd_* functions
  2018-02-02 17:04 [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
                   ` (2 preceding siblings ...)
  2018-02-02 17:04 ` [PATCH v8 3/8] nptl: Add C11 threads call_once functions Adhemerval Zanella
@ 2018-02-02 17:04 ` Adhemerval Zanella
  2018-02-02 17:04 ` [PATCH v8 5/8] nptl: Add C11 threads tss_* functions Adhemerval Zanella
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella @ 2018-02-02 17:04 UTC (permalink / raw)
  To: libc-alpha

This patch adds the cnd_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically cnd_broadcast, cnd_destroy, cnd_init, cnd_signal,
cnd_timedwait, cnd_wait, and required types.

Mostly of the definitions are composed based on POSIX conterparts, and
cnd_t is also based on internal pthreads fields, but with distinct internal
layout to avoid possible issues with code interchange (such as trying to pass
POSIX structure on C11 functions and to avoid inclusion of pthread.h).  The
idea is to make it possible to share POSIX internal implementation for mostly
of the code making adjust where only required.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	* conform/data/threads.h-data (cnd_t): New type.
	(cnd_init): New function.
	(cnd_signal): Likewise.
	(cnd_broadcast): Likewise.
	(cnd_wait): Likewise.
	(cnd_timedwait): Likewise.
	(cnd_destroy): Likewise.
	* nptl/Makefile (libpthread-routines): Add cnd_broadcast,
	cnd_destroy, cnd_init, cnd_signal, cnd_timedwait, and cnd_wait
	object.
	* nptl/Versions (libpthread) [GLIBC_2.27]: Likewise.
	* nptl/cnd_broadcast.c: New file.
	* nptl/cnd_destroy.c: Likewise.
	* nptl/cnd_init.c: Likewise.
	* nptl/cnd_signal.c: Likewise.
	* nptl/cnd_timedwait.c: Likewise.
	* nptl/cnd_wait.c: Likewise.
	* sysdeps/nptl/threads.h (cnd_t): New type.
	(cnd_init): New prototype.
	(cnd_signa): Likewise.
	(cnd_broadcast): Likewise.
	(cnd_wait): Likewise.
	(cnd_timedwait): Likewise.
	(cnd_destroy): Likewise.
---
 ChangeLog                   | 25 +++++++++++++++++++++++++
 conform/data/threads.h-data |  8 ++++++++
 nptl/Makefile               |  3 ++-
 nptl/Versions               |  3 ++-
 nptl/cnd_broadcast.c        | 26 ++++++++++++++++++++++++++
 nptl/cnd_destroy.c          | 26 ++++++++++++++++++++++++++
 nptl/cnd_init.c             | 32 ++++++++++++++++++++++++++++++++
 nptl/cnd_signal.c           | 26 ++++++++++++++++++++++++++
 nptl/cnd_timedwait.c        | 29 +++++++++++++++++++++++++++++
 nptl/cnd_wait.c             | 27 +++++++++++++++++++++++++++
 sysdeps/nptl/threads.h      | 34 ++++++++++++++++++++++++++++++++++
 11 files changed, 237 insertions(+), 2 deletions(-)
 create mode 100644 nptl/cnd_broadcast.c
 create mode 100644 nptl/cnd_destroy.c
 create mode 100644 nptl/cnd_init.c
 create mode 100644 nptl/cnd_signal.c
 create mode 100644 nptl/cnd_timedwait.c
 create mode 100644 nptl/cnd_wait.c

diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data
index 70b2fe0..d7c562e 100644
--- a/conform/data/threads.h-data
+++ b/conform/data/threads.h-data
@@ -16,6 +16,7 @@ type thrd_t
 type thrd_start_t
 type mtx_t
 type once_flag
+type cnd_t
 
 function int thrd_create (thrd_t*, thrd_start_t, void*)
 function int thrd_equal (thrd_t, thrd_t)
@@ -35,6 +36,13 @@ function void mtx_destroy (mtx_t*)
 
 function void call_once (once_flag*, void (*)(void))
 
+function int cnd_init (cnd_t*)
+function int cnd_signal (cnd_t*)
+function int cnd_broadcast (cnd_t*)
+function int cnd_wait (cnd_t*, mtx_t*)
+function int cnd_timedwait (cnd_t*, mtx_t*, const struct timespec*)
+function void cnd_destroy (cnd_t*)
+
 #include "time.h-data"
 
 #endif
diff --git a/nptl/Makefile b/nptl/Makefile
index e539df8..e13c07a 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -143,7 +143,8 @@ libpthread-routines = nptl-init vars events version pt-interp \
 		      thrd_create thrd_current thrd_detach thrd_equal \
 		      thrd_exit thrd_join thrd_sleep thrd_yield \
 		      mtx_destroy mtx_init mtx_lock mtx_timedlock \
-		      mtx_trylock mtx_unlock call_once
+		      mtx_trylock mtx_unlock call_once cnd_broadcast \
+		      cnd_destroy cnd_init cnd_signal cnd_timedwait cnd_wait
 #		      pthread_setuid pthread_seteuid pthread_setreuid \
 #		      pthread_setresuid \
 #		      pthread_setgid pthread_setegid pthread_setregid \
diff --git a/nptl/Versions b/nptl/Versions
index f09e295..0672286 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -269,7 +269,8 @@ libpthread {
   GLIBC_2.28 {
     thrd_create; thrd_current; thrd_detach; thrd_equal; thrd_exit; thrd_join;
     thrd_sleep; thrd_yield; mtx_init; mtx_lock; mtx_timedlock; mtx_trylock;
-    mtx_unlock; mtx_destroy; call_once;
+    mtx_unlock; mtx_destroy; call_once; cnd_broadcast; cnd_destroy; cnd_init;
+    cnd_signal; cnd_timedwait; cnd_wait; mtx_destroy;
   }
 
   GLIBC_PRIVATE {
diff --git a/nptl/cnd_broadcast.c b/nptl/cnd_broadcast.c
new file mode 100644
index 0000000..889f88e
--- /dev/null
+++ b/nptl/cnd_broadcast.c
@@ -0,0 +1,26 @@
+/* C11 thread conditional broadcast implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+cnd_broadcast (cnd_t *cond)
+{
+  int err_code = __pthread_cond_broadcast ((pthread_cond_t*) cond);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/cnd_destroy.c b/nptl/cnd_destroy.c
new file mode 100644
index 0000000..37df9e9
--- /dev/null
+++ b/nptl/cnd_destroy.c
@@ -0,0 +1,26 @@
+/* C11 threads conditional destroy implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+#include "pthreadP.h"
+
+void
+cnd_destroy (cnd_t *cond)
+{
+  __pthread_cond_destroy ((pthread_cond_t *) cond);
+}
diff --git a/nptl/cnd_init.c b/nptl/cnd_init.c
new file mode 100644
index 0000000..2d9f5c0
--- /dev/null
+++ b/nptl/cnd_init.c
@@ -0,0 +1,32 @@
+/* C11 thread conditional initialization implementation.
+   Copyright (C) 2018 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 <stdalign.h>
+
+#include "thrd_priv.h"
+
+int
+cnd_init (cnd_t *cond)
+{
+  _Static_assert (sizeof (cnd_t) == sizeof (pthread_cond_t), "cnd_t size");
+  _Static_assert (alignof (cnd_t) == alignof (pthread_cond_t),
+		  "cnd_t alignment");
+
+  int err_code = __pthread_cond_init ((pthread_cond_t *)cond, NULL);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/cnd_signal.c b/nptl/cnd_signal.c
new file mode 100644
index 0000000..8ae650b
--- /dev/null
+++ b/nptl/cnd_signal.c
@@ -0,0 +1,26 @@
+/* C11 threads conditional signal implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+cnd_signal (cnd_t *cond)
+{
+  int err_code = __pthread_cond_signal ((pthread_cond_t *) cond);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/cnd_timedwait.c b/nptl/cnd_timedwait.c
new file mode 100644
index 0000000..75358fe
--- /dev/null
+++ b/nptl/cnd_timedwait.c
@@ -0,0 +1,29 @@
+/* C11 threads conditional timed wait implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+cnd_timedwait (cnd_t *restrict cond, mtx_t *restrict mutex,
+	       const struct timespec* restrict time_point)
+{
+  int err_code = __pthread_cond_timedwait ((pthread_cond_t *) cond,
+					   (pthread_mutex_t *) mutex,
+					   time_point);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/cnd_wait.c b/nptl/cnd_wait.c
new file mode 100644
index 0000000..727d9bb
--- /dev/null
+++ b/nptl/cnd_wait.c
@@ -0,0 +1,27 @@
+/* C11 threads conditional wait implementaiton.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+cnd_wait (cnd_t *cond, mtx_t *mutex)
+{
+  int err_code = __pthread_cond_wait ((pthread_cond_t *) cond,
+				      (pthread_mutex_t *) mutex);
+  return thrd_err_map (err_code);
+}
diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h
index 6c9c3ef..eb89b0a 100644
--- a/sysdeps/nptl/threads.h
+++ b/sysdeps/nptl/threads.h
@@ -57,6 +57,12 @@ typedef union
   long int __align __LOCK_ALIGNMENT;
 } mtx_t;
 
+typedef union
+{
+  char __size[__SIZEOF_PTHREAD_COND_T];
+  __extension__ long long int __align __LOCK_ALIGNMENT;
+} cnd_t;
+
 /* Threads functions.  */
 
 /* Create a new thread executing the function __FUNC.  Arguments for __FUNC
@@ -137,6 +143,34 @@ extern void mtx_destroy (mtx_t *__mutex);
    All calls must be made with the same __FLAGS object.  */
 extern void call_once (once_flag *__flag, void (*__func)(void));
 
+
+/* Condition variable functions.  */
+
+/* Initialize new condition variable pointed by __COND.  */
+extern int cnd_init (cnd_t *__cond);
+
+/* Unblock one thread that currently waits on condition variable pointed
+   by __COND.  */
+extern int cnd_signal (cnd_t *__cond);
+
+/* Unblock all threads currently waiting on condition variable pointed by
+   __COND.  */
+extern int cnd_broadcast (cnd_t *__cond);
+
+/* Block current thread on the condition variable pointed by __COND.  */
+extern int cnd_wait (cnd_t *__cond, mtx_t *__mutex);
+
+/* Block current thread on the condition variable until condition variable
+   pointed by __COND is signaled or time pointed by __TIME_POINT is
+   reached.  */
+extern int cnd_timedwait (cnd_t *__restrict __cond,
+			  mtx_t *__restrict __mutex,
+			  const struct timespec *__restrict __time_point);
+
+/* Destroy condition variable pointed by __cond and free all of its
+   resources.  */
+extern void cnd_destroy (cnd_t *__COND);
+
 __END_DECLS
 
 #endif /* _THREADS_H */
-- 
2.7.4



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

* [PATCH v8 5/8] nptl: Add C11 threads tss_* functions
  2018-02-02 17:04 [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
                   ` (3 preceding siblings ...)
  2018-02-02 17:04 ` [PATCH v8 4/8] nptl: Add C11 threads cnd_* functions Adhemerval Zanella
@ 2018-02-02 17:04 ` Adhemerval Zanella
  2018-07-12 16:48   ` Florian Weimer
  2018-02-02 17:04 ` [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads Adhemerval Zanella
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-02-02 17:04 UTC (permalink / raw)
  To: libc-alpha

This patch adds the tss_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically tss_create, tss_delete, tss_get, tss_set, and required
types.

Mostly of the definitions are composed based on POSIX conterparts, including
tss_t (pthread_key_t).

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	* conform/data/threads.h-data (thread_local): New macro.
	(TSS_DTOR_ITERATIONS): Likewise.
	(tss_t): New type.
	(tss_dtor_t): Likewise.
	(tss_create): New function.
	(tss_get): Likewise.
	(tss_set): Likewise.
	(tss_delete): Likewise.
	* nptl/Makefile (libpthread-routines): Add tss_create, tss_delete,
	tss_get, and tss_set objects.
	* nptl/Versions (libpthread) [GLIBC_2.27]: Likewise.
	* nptl/tss_create.c: New file.
	* nptl/tss_delete.c: Likewise.
	* nptl/tss_get.c: Likewise.
	* nptl/tss_set.c: Likewise.
	* sysdeps/nptl/threads.h (thread_local): New define.
	(TSS_DTOR_ITERATIONS): Likewise.
	(tss_t): New typedef.
	(tss_dtor_t): Likewise.
	(tss_create): New prototype.
	(tss_get): Likewise.
	(tss_set): Likewise.
	(tss_delete): Likewise.
---
 ChangeLog                   | 24 ++++++++++++++++++++++++
 conform/data/threads.h-data |  9 +++++++++
 nptl/Makefile               |  3 ++-
 nptl/Versions               |  3 ++-
 nptl/tss_create.c           | 28 ++++++++++++++++++++++++++++
 nptl/tss_delete.c           | 25 +++++++++++++++++++++++++
 nptl/tss_get.c              | 25 +++++++++++++++++++++++++
 nptl/tss_set.c              | 26 ++++++++++++++++++++++++++
 sysdeps/nptl/threads.h      | 24 ++++++++++++++++++++++++
 9 files changed, 165 insertions(+), 2 deletions(-)
 create mode 100644 nptl/tss_create.c
 create mode 100644 nptl/tss_delete.c
 create mode 100644 nptl/tss_get.c
 create mode 100644 nptl/tss_set.c

diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data
index d7c562e..406e497 100644
--- a/conform/data/threads.h-data
+++ b/conform/data/threads.h-data
@@ -1,6 +1,8 @@
 #if defined ISO11
 
 macro ONCE_FLAG_INIT
+macro thread_local
+macro-int-constant TSS_DTOR_ITERATIONS
 
 constant thrd_success
 constant thrd_busy
@@ -17,6 +19,8 @@ type thrd_start_t
 type mtx_t
 type once_flag
 type cnd_t
+type tss_t
+type tss_dtor_t
 
 function int thrd_create (thrd_t*, thrd_start_t, void*)
 function int thrd_equal (thrd_t, thrd_t)
@@ -43,6 +47,11 @@ function int cnd_wait (cnd_t*, mtx_t*)
 function int cnd_timedwait (cnd_t*, mtx_t*, const struct timespec*)
 function void cnd_destroy (cnd_t*)
 
+function int tss_create (tss_t*, tss_dtor_t)
+function {void*} tss_get (tss_t)
+function int tss_set (tss_t, void*)
+function void tss_delete (tss_t)
+
 #include "time.h-data"
 
 #endif
diff --git a/nptl/Makefile b/nptl/Makefile
index e13c07a..4ee1db0 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -144,7 +144,8 @@ libpthread-routines = nptl-init vars events version pt-interp \
 		      thrd_exit thrd_join thrd_sleep thrd_yield \
 		      mtx_destroy mtx_init mtx_lock mtx_timedlock \
 		      mtx_trylock mtx_unlock call_once cnd_broadcast \
-		      cnd_destroy cnd_init cnd_signal cnd_timedwait cnd_wait
+		      cnd_destroy cnd_init cnd_signal cnd_timedwait cnd_wait \
+		      tss_create tss_delete tss_get tss_set
 #		      pthread_setuid pthread_seteuid pthread_setreuid \
 #		      pthread_setresuid \
 #		      pthread_setgid pthread_setegid pthread_setregid \
diff --git a/nptl/Versions b/nptl/Versions
index 0672286..3df32db 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -270,7 +270,8 @@ libpthread {
     thrd_create; thrd_current; thrd_detach; thrd_equal; thrd_exit; thrd_join;
     thrd_sleep; thrd_yield; mtx_init; mtx_lock; mtx_timedlock; mtx_trylock;
     mtx_unlock; mtx_destroy; call_once; cnd_broadcast; cnd_destroy; cnd_init;
-    cnd_signal; cnd_timedwait; cnd_wait; mtx_destroy;
+    cnd_signal; cnd_timedwait; cnd_wait; mtx_destroy; tss_create; tss_delete;
+    tss_get; tss_set;
   }
 
   GLIBC_PRIVATE {
diff --git a/nptl/tss_create.c b/nptl/tss_create.c
new file mode 100644
index 0000000..da1c91a
--- /dev/null
+++ b/nptl/tss_create.c
@@ -0,0 +1,28 @@
+/* C11 threads thread-specific creation implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+tss_create (tss_t *tss_id, tss_dtor_t destructor)
+{
+  _Static_assert (sizeof (tss_t) == sizeof (pthread_key_t), "tss_t size");
+
+  int err_code = __pthread_key_create (tss_id, destructor);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/tss_delete.c b/nptl/tss_delete.c
new file mode 100644
index 0000000..0fc2975
--- /dev/null
+++ b/nptl/tss_delete.c
@@ -0,0 +1,25 @@
+/* C11 threads thread-specific delete implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+void
+tss_delete (tss_t tss_id)
+{
+  __pthread_key_delete (tss_id);
+}
diff --git a/nptl/tss_get.c b/nptl/tss_get.c
new file mode 100644
index 0000000..5e09766
--- /dev/null
+++ b/nptl/tss_get.c
@@ -0,0 +1,25 @@
+/* C11 threads thread-specific get implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+void *
+tss_get (tss_t tss_id)
+{
+  return __pthread_getspecific (tss_id);
+}
diff --git a/nptl/tss_set.c b/nptl/tss_set.c
new file mode 100644
index 0000000..03973d9
--- /dev/null
+++ b/nptl/tss_set.c
@@ -0,0 +1,26 @@
+/* C11 threads thread-specific set implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+tss_set (tss_t tss_id, void *val)
+{
+  int err_code = __pthread_setspecific (tss_id, val);
+  return thrd_err_map (err_code);
+}
diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h
index eb89b0a..6a807ee 100644
--- a/sysdeps/nptl/threads.h
+++ b/sysdeps/nptl/threads.h
@@ -28,6 +28,10 @@ __BEGIN_DECLS
 #include <bits/types/struct_timespec.h>
 
 #define ONCE_FLAG_INIT 0
+#define thread_local _Thread_local
+#define TSS_DTOR_ITERATIONS 4
+typedef unsigned int tss_t;
+typedef void (*tss_dtor_t) (void*);
 
 typedef unsigned long int thrd_t;
 typedef int (*thrd_start_t) (void*);
@@ -171,6 +175,26 @@ extern int cnd_timedwait (cnd_t *__restrict __cond,
    resources.  */
 extern void cnd_destroy (cnd_t *__COND);
 
+
+/* Thread specific storage functions.  */
+
+/* Create new thread-specific storage key and stores it in the object pointed
+   by __TSS_ID.  If __DESTRUCTOR is not NULL, the function will be called when
+   the thread terminates.  */
+extern int tss_create (tss_t *__tss_id, tss_dtor_t __destructor);
+
+/* Return the value held in thread-specific storage for the current thread
+   identified by __TSS_ID.  */
+extern void *tss_get (tss_t __tss_id);
+
+/* Sets the value of the thread-specific storage identified by __TSS_ID for
+   the current thread to __VAL.  */
+extern int tss_set (tss_t __tss_id, void *__val);
+
+/* Destroys the thread-specific storage identified by __TSS_ID.  The
+   destructor is not called until thrd_exit is called.  */
+extern void tss_delete (tss_t __tss_id);
+
 __END_DECLS
 
 #endif /* _THREADS_H */
-- 
2.7.4



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

* [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads
  2018-02-02 17:04 [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
                   ` (4 preceding siblings ...)
  2018-02-02 17:04 ` [PATCH v8 5/8] nptl: Add C11 threads tss_* functions Adhemerval Zanella
@ 2018-02-02 17:04 ` Adhemerval Zanella
  2018-07-13  9:50   ` Florian Weimer
  2018-02-02 17:04 ` [PATCH v8 7/8] nptl: Add test cases for ISO " Adhemerval Zanella
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-02-02 17:04 UTC (permalink / raw)
  To: libc-alpha

This patch adds the required abilist symbols for C11 thread support.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	* sysdeps/unix/sysv/linux/aarch64/libpthread.abilist: Add C11 thread
	symbols.
	* sysdeps/unix/sysv/linux/alpha/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/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/m680x0/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/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/libpthread-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist: Likewise.
	* sysdpes/unix/sysv/linux/s390/s390-32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/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/tile/tilegx/tilegx32/libpthread.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist: Likewise.
---
 ChangeLog                                          | 33 ++++++++++++++++++++++
 sysdeps/unix/sysv/linux/aarch64/libpthread.abilist | 26 +++++++++++++++++
 sysdeps/unix/sysv/linux/alpha/libpthread.abilist   | 26 +++++++++++++++++
 sysdeps/unix/sysv/linux/arm/libpthread.abilist     | 26 +++++++++++++++++
 sysdeps/unix/sysv/linux/hppa/libpthread.abilist    | 26 +++++++++++++++++
 sysdeps/unix/sysv/linux/i386/libpthread.abilist    | 26 +++++++++++++++++
 sysdeps/unix/sysv/linux/ia64/libpthread.abilist    | 26 +++++++++++++++++
 .../sysv/linux/m68k/coldfire/libpthread.abilist    | 26 +++++++++++++++++
 .../unix/sysv/linux/m68k/m680x0/libpthread.abilist | 26 +++++++++++++++++
 .../unix/sysv/linux/microblaze/libpthread.abilist  | 26 +++++++++++++++++
 .../unix/sysv/linux/mips/mips32/libpthread.abilist | 26 +++++++++++++++++
 .../unix/sysv/linux/mips/mips64/libpthread.abilist | 26 +++++++++++++++++
 sysdeps/unix/sysv/linux/nios2/libpthread.abilist   | 26 +++++++++++++++++
 .../linux/powerpc/powerpc32/libpthread.abilist     | 26 +++++++++++++++++
 .../linux/powerpc/powerpc64/libpthread-le.abilist  | 26 +++++++++++++++++
 .../linux/powerpc/powerpc64/libpthread.abilist     | 26 +++++++++++++++++
 .../unix/sysv/linux/riscv/rv64/libpthread.abilist  | 26 +++++++++++++++++
 .../sysv/linux/s390/s390-32/libpthread.abilist     | 26 +++++++++++++++++
 .../sysv/linux/s390/s390-64/libpthread.abilist     | 26 +++++++++++++++++
 sysdeps/unix/sysv/linux/sh/libpthread.abilist      | 26 +++++++++++++++++
 .../sysv/linux/sparc/sparc32/libpthread.abilist    | 26 +++++++++++++++++
 .../sysv/linux/sparc/sparc64/libpthread.abilist    | 26 +++++++++++++++++
 .../sysv/linux/tile/tilegx32/libpthread.abilist    | 26 +++++++++++++++++
 .../sysv/linux/tile/tilegx64/libpthread.abilist    | 26 +++++++++++++++++
 .../unix/sysv/linux/x86_64/64/libpthread.abilist   | 26 +++++++++++++++++
 .../unix/sysv/linux/x86_64/x32/libpthread.abilist  | 26 +++++++++++++++++
 26 files changed, 683 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist b/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
index 0cf30ee..c3cecf7 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
@@ -224,3 +224,29 @@ GLIBC_2.17 write F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
diff --git a/sysdeps/unix/sysv/linux/alpha/libpthread.abilist b/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
index 7e121d4..d284de9 100644
--- a/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
@@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/arm/libpthread.abilist b/sysdeps/unix/sysv/linux/arm/libpthread.abilist
index 91545c1..f2746bd 100644
--- a/sysdeps/unix/sysv/linux/arm/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/arm/libpthread.abilist
@@ -9,6 +9,32 @@ GLIBC_2.12 pthread_setname_np F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 _IO_flockfile F
 GLIBC_2.4 _IO_ftrylockfile F
diff --git a/sysdeps/unix/sysv/linux/hppa/libpthread.abilist b/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
index a73aa43..7fb95d6 100644
--- a/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
@@ -204,6 +204,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/i386/libpthread.abilist b/sysdeps/unix/sysv/linux/i386/libpthread.abilist
index 8f9c325..eea1461 100644
--- a/sysdeps/unix/sysv/linux/i386/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libpthread.abilist
@@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/ia64/libpthread.abilist b/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
index d4c8ded..bca4e1f 100644
--- a/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
@@ -204,6 +204,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
index 91545c1..f2746bd 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
@@ -9,6 +9,32 @@ GLIBC_2.12 pthread_setname_np F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 _IO_flockfile F
 GLIBC_2.4 _IO_ftrylockfile F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
index 8f9c325..eea1461 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
@@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/microblaze/libpthread.abilist b/sysdeps/unix/sysv/linux/microblaze/libpthread.abilist
index 00d948b..c6b2d70 100644
--- a/sysdeps/unix/sysv/linux/microblaze/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/libpthread.abilist
@@ -223,3 +223,29 @@ GLIBC_2.18 vfork F
 GLIBC_2.18 wait F
 GLIBC_2.18 waitpid F
 GLIBC_2.18 write F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist b/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
index 280d99d..ab466e0 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
@@ -213,6 +213,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist b/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
index ad55bdd..382ffd8 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
@@ -213,6 +213,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/nios2/libpthread.abilist b/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
index a10bbde..6548e25 100644
--- a/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
@@ -221,3 +221,29 @@ GLIBC_2.21 tcdrain F
 GLIBC_2.21 wait F
 GLIBC_2.21 waitpid F
 GLIBC_2.21 write F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
index 14c3a86..5721f0e 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
@@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist
index 0cf30ee..dceef50 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist
@@ -224,3 +224,29 @@ GLIBC_2.17 write F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.27 GLIBC_2.27 A
+GLIBC_2.27 call_once F
+GLIBC_2.27 cnd_broadcast F
+GLIBC_2.27 cnd_destroy F
+GLIBC_2.27 cnd_init F
+GLIBC_2.27 cnd_signal F
+GLIBC_2.27 cnd_timedwait F
+GLIBC_2.27 cnd_wait F
+GLIBC_2.27 mtx_destroy F
+GLIBC_2.27 mtx_init F
+GLIBC_2.27 mtx_lock F
+GLIBC_2.27 mtx_timedlock F
+GLIBC_2.27 mtx_trylock F
+GLIBC_2.27 mtx_unlock F
+GLIBC_2.27 thrd_create F
+GLIBC_2.27 thrd_current F
+GLIBC_2.27 thrd_detach F
+GLIBC_2.27 thrd_equal F
+GLIBC_2.27 thrd_exit F
+GLIBC_2.27 thrd_join F
+GLIBC_2.27 thrd_sleep F
+GLIBC_2.27 thrd_yield F
+GLIBC_2.27 tss_create F
+GLIBC_2.27 tss_delete F
+GLIBC_2.27 tss_get F
+GLIBC_2.27 tss_set F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist
index 464b91a..c9d9b38 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist
@@ -9,6 +9,32 @@ GLIBC_2.12 pthread_setname_np F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 _IO_flockfile F
 GLIBC_2.3 _IO_ftrylockfile F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist
index fcc14ed..0e88e95 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist
@@ -215,3 +215,29 @@ GLIBC_2.27 tcdrain F
 GLIBC_2.27 wait F
 GLIBC_2.27 waitpid F
 GLIBC_2.27 write F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
index 3c5e11a..ea13d4d 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
@@ -219,6 +219,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
index 83a1fcd..89d0e40 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
@@ -207,6 +207,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/sh/libpthread.abilist b/sysdeps/unix/sysv/linux/sh/libpthread.abilist
index a73aa43..7fb95d6 100644
--- a/sysdeps/unix/sysv/linux/sh/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sh/libpthread.abilist
@@ -204,6 +204,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
index 7e121d4..d284de9 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
@@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
index d4c8ded..bca4e1f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
@@ -204,6 +204,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/tile/tilegx32/libpthread.abilist b/sysdeps/unix/sysv/linux/tile/tilegx32/libpthread.abilist
index d16158f..85af22e 100644
--- a/sysdeps/unix/sysv/linux/tile/tilegx32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilegx32/libpthread.abilist
@@ -224,3 +224,29 @@ GLIBC_2.12 write F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
diff --git a/sysdeps/unix/sysv/linux/tile/tilegx64/libpthread.abilist b/sysdeps/unix/sysv/linux/tile/tilegx64/libpthread.abilist
index d16158f..85af22e 100644
--- a/sysdeps/unix/sysv/linux/tile/tilegx64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilegx64/libpthread.abilist
@@ -224,3 +224,29 @@ GLIBC_2.12 write F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
index 85365c0..e02aa58 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
@@ -203,6 +203,32 @@ GLIBC_2.2.5 waitpid F
 GLIBC_2.2.5 write F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
index 6cd0fc3..30fad02 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
@@ -224,3 +224,29 @@ GLIBC_2.16 write F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.28 GLIBC_2.28 A
+GLIBC_2.28 call_once F
+GLIBC_2.28 cnd_broadcast F
+GLIBC_2.28 cnd_destroy F
+GLIBC_2.28 cnd_init F
+GLIBC_2.28 cnd_signal F
+GLIBC_2.28 cnd_timedwait F
+GLIBC_2.28 cnd_wait F
+GLIBC_2.28 mtx_destroy F
+GLIBC_2.28 mtx_init F
+GLIBC_2.28 mtx_lock F
+GLIBC_2.28 mtx_timedlock F
+GLIBC_2.28 mtx_trylock F
+GLIBC_2.28 mtx_unlock F
+GLIBC_2.28 thrd_create F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_detach F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_exit F
+GLIBC_2.28 thrd_join F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F
+GLIBC_2.28 tss_create F
+GLIBC_2.28 tss_delete F
+GLIBC_2.28 tss_get F
+GLIBC_2.28 tss_set F
-- 
2.7.4



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

* [PATCH v8 7/8] nptl: Add test cases for ISO C11 threads
  2018-02-02 17:04 [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
                   ` (5 preceding siblings ...)
  2018-02-02 17:04 ` [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads Adhemerval Zanella
@ 2018-02-02 17:04 ` Adhemerval Zanella
  2018-07-13  9:31   ` Florian Weimer
  2018-02-02 17:04 ` [PATCH v8 8/8] Add manual documentation for threads.h Adhemerval Zanella
  2018-06-27 13:39 ` [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
  8 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-02-02 17:04 UTC (permalink / raw)
  To: libc-alpha

This patch adds to testsuite new test cases to test all new introduced
C11 threads functions, types and macros are tested.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	Adhemerval Zanella  <adhemerval.zanella@linaro.org>
	Juan Manuel Torres Palma  <jmtorrespalma@gmail.com>

	* nptl/Makefile (tests): Add new test files.
	* nptl/tst-call-once.c : New file. Tests C11 functions and types.
	* nptl/tst-cnd-basic.c: Likewise.
	* nptl/tst-cnd-broadcast.c: Likewise.
	* nptl/tst-cnd-timedwait.c: Likewise.
	* nptl/tst-mtx-basic.c: Likewise.
	* nptl/tst-mtx-recursive.c: Likewise.
	* nptl/tst-mtx-timedlock.c: Likewise.
	* nptl/tst-mtx-trylock.c: Likewise.
	* nptl/tst-thrd-basic.c: Likewise.
	* nptl/tst-thrd-detach.c: Likewise.
	* nptl/tst-thrd-sleep.c: Likewise.
	* nptl/tst-tss-basic.c: Likewise.
---
 ChangeLog                | 17 +++++++++
 nptl/Makefile            |  5 ++-
 nptl/tst-call-once.c     | 66 ++++++++++++++++++++++++++++++++
 nptl/tst-cnd-basic.c     | 68 +++++++++++++++++++++++++++++++++
 nptl/tst-cnd-broadcast.c | 83 ++++++++++++++++++++++++++++++++++++++++
 nptl/tst-cnd-timedwait.c | 70 ++++++++++++++++++++++++++++++++++
 nptl/tst-mtx-basic.c     | 73 ++++++++++++++++++++++++++++++++++++
 nptl/tst-mtx-recursive.c | 45 ++++++++++++++++++++++
 nptl/tst-mtx-timedlock.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++
 nptl/tst-mtx-trylock.c   | 90 ++++++++++++++++++++++++++++++++++++++++++++
 nptl/tst-thrd-detach.c   | 52 +++++++++++++++++++++++++
 nptl/tst-thrd-sleep.c    | 51 +++++++++++++++++++++++++
 nptl/tst-tss-basic.c     | 75 ++++++++++++++++++++++++++++++++++++
 13 files changed, 792 insertions(+), 1 deletion(-)
 create mode 100644 nptl/tst-call-once.c
 create mode 100644 nptl/tst-cnd-basic.c
 create mode 100644 nptl/tst-cnd-broadcast.c
 create mode 100644 nptl/tst-cnd-timedwait.c
 create mode 100644 nptl/tst-mtx-basic.c
 create mode 100644 nptl/tst-mtx-recursive.c
 create mode 100644 nptl/tst-mtx-timedlock.c
 create mode 100644 nptl/tst-mtx-trylock.c
 create mode 100644 nptl/tst-thrd-detach.c
 create mode 100644 nptl/tst-thrd-sleep.c
 create mode 100644 nptl/tst-tss-basic.c

diff --git a/nptl/Makefile b/nptl/Makefile
index 4ee1db0..7416275 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -315,7 +315,10 @@ tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
 	tst-thread_local1 tst-mutex-errorcheck tst-robust10 \
 	tst-robust-fork tst-create-detached tst-memstream \
 	tst-thread-exit-clobber tst-minstack-cancel tst-minstack-exit \
-	tst-minstack-throw
+	tst-minstack-throw \
+	tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
+	tst-cnd-timedwait tst-thrd-detach tst-mtx-basic tst-thrd-sleep \
+	tst-mtx-recursive tst-tss-basic tst-call-once tst-mtx-timedlock
 
 tests-internal := tst-rwlock19 tst-rwlock20 \
 		  tst-sem11 tst-sem12 tst-sem13 \
diff --git a/nptl/tst-call-once.c b/nptl/tst-call-once.c
new file mode 100644
index 0000000..b677181
--- /dev/null
+++ b/nptl/tst-call-once.c
@@ -0,0 +1,66 @@
+/* C11 threads call_once test.
+   Copyright (C) 2018 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 <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Flag that controls the first thread access.  */
+static once_flag flag = ONCE_FLAG_INIT;
+
+static int value = 0;
+
+static void
+do_once (void)
+{
+  value++;
+}
+
+static int
+func (void* data)
+{
+  call_once (&flag, do_once);
+  thrd_exit (thrd_success);
+}
+
+#define N 20
+
+int
+do_test (void)
+{
+  thrd_t ids[N];
+
+  for (int i = 0; i < N; ++i)
+    {
+      if (thrd_create (&ids[i], func, NULL) != thrd_success)
+	FAIL_EXIT1 ("thrd_create failed");
+    }
+
+  /* Join threads.  */
+  for (int i = 0; i < N; ++i)
+    {
+      if (thrd_join (ids[i], NULL) != thrd_success)
+	FAIL_EXIT1 ("thrd_join failed");
+    }
+
+  return (value != 1);
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-cnd-basic.c b/nptl/tst-cnd-basic.c
new file mode 100644
index 0000000..84b7f5f
--- /dev/null
+++ b/nptl/tst-cnd-basic.c
@@ -0,0 +1,68 @@
+/* C11 threads condition variable tests.
+   Copyright (C) 2018 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 <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Shared condition variable between child and parent.  */
+static cnd_t cond;
+
+/* Mutex needed to signal and wait threads.  */
+static mtx_t mutex;
+
+static int
+signal_parent (void)
+{
+  if (cnd_signal (&cond) != thrd_success)
+    FAIL_EXIT1 ("cnd_signal");
+
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  thrd_t id;
+
+  if (cnd_init (&cond) != thrd_success)
+    FAIL_EXIT1 ("cnd_init failed");
+  if (mtx_init (&mutex, mtx_plain) != thrd_success)
+    FAIL_EXIT1 ("mtx_init failed");
+
+  if (thrd_create (&id, (thrd_start_t) signal_parent, NULL)
+      != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  if (cnd_wait (&cond, &mutex) != thrd_success)
+    FAIL_EXIT1 ("cnd_wait failed");
+
+  /* Joining is not mandatory here, but still done to assure child thread
+     ends correctly.  */
+  if (thrd_join (id, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_join failed");
+
+  mtx_destroy (&mutex);
+  cnd_destroy (&cond);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-cnd-broadcast.c b/nptl/tst-cnd-broadcast.c
new file mode 100644
index 0000000..90d6843
--- /dev/null
+++ b/nptl/tst-cnd-broadcast.c
@@ -0,0 +1,83 @@
+/* C11 threads condition broadcast variable tests.
+   Copyright (C) 2018 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 <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Condition variable where child threads will wait.  */
+static cnd_t cond;
+
+/* Mutex to control wait on cond.  */
+static mtx_t mutex;
+
+/* Code executed by each thread.  */
+static int
+child_wait (void* data)
+{
+  /* Wait until parent thread sends broadcast here.  */
+  mtx_lock (&mutex);
+  cnd_wait (&cond, &mutex);
+  mtx_unlock (&mutex);
+
+  thrd_exit (thrd_success);
+}
+
+#define N 5
+
+static int
+do_test (void)
+{
+  thrd_t ids[N];
+  unsigned char i;
+
+  if (cnd_init (&cond) != thrd_success)
+    FAIL_EXIT1 ("cnd_init failed");
+  if (mtx_init (&mutex, mtx_plain) != thrd_success)
+    FAIL_EXIT1 ("mtx_init failed");
+
+  /* Create N new threads.  */
+  for (i = 0; i < N; ++i)
+    {
+      if (thrd_create (&ids[i], child_wait, NULL) != thrd_success)
+	FAIL_EXIT1 ("thrd_create failed");
+    }
+
+  /* Wait for other threads to reach their wait func.  */
+  thrd_sleep (&((struct timespec){.tv_sec = 2}), NULL);
+
+  mtx_lock (&mutex);
+  if (cnd_broadcast (&cond) != thrd_success)
+    FAIL_EXIT1 ("cnd_broadcast failed");
+  mtx_unlock (&mutex);
+
+  for (i = 0; i < N; ++i)
+    {
+      if (thrd_join (ids[i], NULL) != thrd_success)
+	FAIL_EXIT1 ("thrd_join failed");
+    }
+
+  mtx_destroy (&mutex);
+  cnd_destroy (&cond);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-cnd-timedwait.c b/nptl/tst-cnd-timedwait.c
new file mode 100644
index 0000000..45a1512
--- /dev/null
+++ b/nptl/tst-cnd-timedwait.c
@@ -0,0 +1,70 @@
+/* C11 threads condition timed wait variable tests.
+   Copyright (C) 2018 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 <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Shared condition variable between child and parent.  */
+static cnd_t cond;
+
+/* Mutex needed to signal and wait threads.  */
+static mtx_t mutex;
+
+static int
+signal_parent (void *arg)
+{
+  if (cnd_signal (&cond) != thrd_success)
+    FAIL_EXIT1 ("cnd_signal failed");
+
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  thrd_t id;
+  struct timespec w_time;
+
+  if (cnd_init (&cond) != thrd_success)
+    FAIL_EXIT1 ("cnd_init failed");
+  if (mtx_init (&mutex, mtx_plain) != thrd_success)
+    FAIL_EXIT1 ("mtx_init failed");
+
+  if (clock_gettime (CLOCK_REALTIME, &w_time) != 0)
+    FAIL_EXIT1 ("clock_gettime failed");
+  w_time.tv_nsec += 150000;
+
+  if (thrd_create (&id, signal_parent, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  if (cnd_timedwait (&cond, &mutex, &w_time) != thrd_success)
+    FAIL_EXIT1 ("cnd_timedwait failed");
+
+  if (thrd_join (id, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_join failed");
+
+  mtx_destroy (&mutex);
+  cnd_destroy (&cond);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-mtx-basic.c b/nptl/tst-mtx-basic.c
new file mode 100644
index 0000000..8507312
--- /dev/null
+++ b/nptl/tst-mtx-basic.c
@@ -0,0 +1,73 @@
+/* C11 threads basic mutex tests.
+   Copyright (C) 2018 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 <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Shared mutex between child and parent.  */
+static mtx_t mutex;
+
+/* Shared counter to check possible race conditions.  */
+static int counter;
+
+static int
+child_add (void *arg)
+{
+  if (mtx_lock (&mutex) != thrd_success)
+    FAIL_EXIT1 ("mtx_lock failed");
+
+  counter++;
+
+  if (mtx_unlock (&mutex) != thrd_success)
+    FAIL_EXIT1 ("mtx_unlock failed");
+
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  mtx_init (&mutex, mtx_plain);
+
+  thrd_t id;
+  if (thrd_create (&id, child_add, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  if (mtx_lock (&mutex) != thrd_success)
+    FAIL_EXIT1 ("mtx_lock failed");
+
+  counter++;
+
+  if (mtx_unlock (&mutex) != thrd_success)
+    FAIL_EXIT1 ("mtx_unlock failed");
+
+  if (thrd_join (id, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_join failed");
+
+  if (counter != 2)
+    FAIL_EXIT1 ("counter (%d) != 2", counter);
+
+  mtx_destroy (&mutex);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-mtx-recursive.c b/nptl/tst-mtx-recursive.c
new file mode 100644
index 0000000..7a6bfc2
--- /dev/null
+++ b/nptl/tst-mtx-recursive.c
@@ -0,0 +1,45 @@
+/* C11 threads recursive mutex tests.
+   Copyright (C) 2018 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 <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+  static mtx_t mutex;
+
+  if (mtx_init (&mutex, mtx_recursive) != thrd_success)
+    FAIL_EXIT1 ("mtx_init failed");
+
+  if (mtx_lock (&mutex) != thrd_success)
+    FAIL_EXIT1 ("mtx_lock failed");
+
+  /* Lock mutex second time, if not recursive should deadlock.  */
+  if (mtx_lock (&mutex) != thrd_success)
+    FAIL_EXIT1 ("mtx_lock failed");
+
+  mtx_destroy (&mutex);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-mtx-timedlock.c b/nptl/tst-mtx-timedlock.c
new file mode 100644
index 0000000..dcae828
--- /dev/null
+++ b/nptl/tst-mtx-timedlock.c
@@ -0,0 +1,98 @@
+/* C11 threads timed mutex tests.
+   Copyright (C) 2018 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 <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Shared mutex between child and parent.  */
+static mtx_t mutex;
+
+/* Shared counter to check possible race conditions.  */
+static char shrd_counter;
+
+/* Maximum amount of time waiting for mutex.  */
+static struct timespec wait_time;
+
+/* Function to choose an action to do, depending on mtx_timedlock
+   return value.  */
+static inline void
+choose_action (int action, char* thread_name)
+{
+  switch (action)
+    {
+      case thrd_success:
+        ++shrd_counter;
+
+	if (mtx_unlock (&mutex) != thrd_success)
+	  FAIL_EXIT1 ("mtx_unlock failed");
+      break;
+
+      case thrd_timedout:
+        break;
+
+      case thrd_error:
+	FAIL_EXIT1 ("%s lock error", thread_name);
+        break;
+    }
+}
+
+static int
+child_add (void *arg)
+{
+  char child_name[] = "child";
+
+  /* Try to lock mutex.  */
+  choose_action (mtx_timedlock (&mutex, &wait_time), child_name);
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  thrd_t id;
+  char parent_name[] = "parent";
+
+  if (mtx_init (&mutex, mtx_timed) != thrd_success)
+    FAIL_EXIT1 ("mtx_init failed");
+
+  if (clock_gettime (CLOCK_REALTIME, &wait_time) != 0)
+    FAIL_EXIT1 ("clock_gettime failed");
+  /* Tiny amount of time, to assure that if any thread finds it busy.
+     It will receive thrd_timedout.  */
+  wait_time.tv_nsec += 1;
+
+  if (thrd_create (&id, child_add, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  choose_action (mtx_timedlock (&mutex, &wait_time), parent_name);
+
+  if (thrd_join (id, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_join failed");
+
+  if (shrd_counter != 2 && shrd_counter != 1)
+    FAIL_EXIT1 ("shrd_counter != {1,2} (%d)", shrd_counter);
+
+  mtx_destroy (&mutex);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-mtx-trylock.c b/nptl/tst-mtx-trylock.c
new file mode 100644
index 0000000..9df84a3
--- /dev/null
+++ b/nptl/tst-mtx-trylock.c
@@ -0,0 +1,90 @@
+/* C11 threads trylock mutex tests.
+   Copyright (C) 2018 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 <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Shared mutex between child and parent.  */
+static mtx_t mutex;
+
+/* Shared counter to check possible race conditions.  */
+static char shrd_counter;
+
+/* Function to choose an action to do, depending on mtx_trylock
+   return value.  */
+static inline void
+choose_action (int action, char* thread_name)
+{
+  switch (action)
+    {
+      case thrd_success:
+        ++shrd_counter;
+
+	if (mtx_unlock (&mutex) != thrd_success)
+	  FAIL_EXIT1 ("mtx_unlock failed");
+      break;
+
+      case thrd_busy:
+        break;
+
+      case thrd_error:
+	FAIL_EXIT1 ("%s lock error", thread_name);
+        break;
+    }
+}
+
+static int
+child_add (void *arg)
+{
+  char child_name[] = "child";
+
+  /* Try to lock mutex.  */
+  choose_action (mtx_trylock (&mutex), child_name);
+
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  thrd_t id;
+  char parent_name[] = "parent";
+
+  if (mtx_init (&mutex, mtx_timed) != thrd_success)
+    FAIL_EXIT1 ("mtx_init failed");
+
+  if (thrd_create (&id, child_add, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  choose_action (mtx_trylock (&mutex), parent_name);
+
+  if (thrd_join (id, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_join failed");
+
+  if (shrd_counter != 2 && shrd_counter != 1)
+    FAIL_EXIT1 ("shrd_counter != {1,2} (%d)", shrd_counter);
+
+  mtx_destroy (&mutex);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-thrd-detach.c b/nptl/tst-thrd-detach.c
new file mode 100644
index 0000000..72ba845
--- /dev/null
+++ b/nptl/tst-thrd-detach.c
@@ -0,0 +1,52 @@
+/* C11 threads thread detach tests.
+   Copyright (C) 2018 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 <threads.h>
+#include <time.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+static int
+detach_thrd (void *arg)
+{
+  if (thrd_detach (thrd_current ()) != thrd_success)
+    FAIL_EXIT1 ("thrd_detach failed");
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  thrd_t id;
+
+  /* Create new thread.  */
+  if (thrd_create (&id, detach_thrd, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  /* Give some time so the thread can finish.  */
+  thrd_sleep (&(struct timespec) {.tv_sec = 2}, NULL);
+
+  if (thrd_join (id, NULL) == thrd_success)
+    FAIL_EXIT1 ("thrd_join succeed where it should fail");
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-thrd-sleep.c b/nptl/tst-thrd-sleep.c
new file mode 100644
index 0000000..3805671
--- /dev/null
+++ b/nptl/tst-thrd-sleep.c
@@ -0,0 +1,51 @@
+/* C11 threads thread sleep tests.
+   Copyright (C) 2018 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 <threads.h>
+#include <time.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+static int
+sleep_thrd (void *arg)
+{
+  struct timespec const *tl = (struct timespec const *) arg;
+  if (thrd_sleep (tl, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_sleep failed");
+
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  thrd_t id;
+  struct timespec wait_time = {.tv_sec = 3};
+
+  if (thrd_create (&id, sleep_thrd, (void *) (&wait_time)) != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  if (thrd_join (id, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd failed");
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-tss-basic.c b/nptl/tst-tss-basic.c
new file mode 100644
index 0000000..e82edad
--- /dev/null
+++ b/nptl/tst-tss-basic.c
@@ -0,0 +1,75 @@
+/* C11 threads specific storage tests.
+   Copyright (C) 2018 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 <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Thread specific storage.  */
+static tss_t key;
+
+#define TSS_VALUE (void*) 0xFF
+
+static int
+tss_thrd (void *arg)
+{
+  if (tss_create (&key, NULL) != thrd_success)
+    FAIL_EXIT1 ("tss_create failed");
+
+  if (tss_set (key, TSS_VALUE))
+    FAIL_EXIT1 ("tss_set failed");
+
+  void *value = tss_get (key);
+  if (value == 0)
+    FAIL_EXIT1 ("tss_get failed");
+  if (value != TSS_VALUE)
+    FAIL_EXIT1 ("tss_get returned %p, expected %p", value, TSS_VALUE);
+
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  /* Setting an invalid key should return an error.  */
+  if (tss_set (key, TSS_VALUE) == thrd_success)
+    FAIL_EXIT1 ("tss_set succeed where it should have failed");
+
+  if (tss_create (&key, NULL) != thrd_success)
+    FAIL_EXIT1 ("tss_create failed");
+
+  thrd_t id;
+  if (thrd_create (&id, tss_thrd, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  if (thrd_join (id, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd failed");
+
+  /* The value set in tss_thrd should not be visible here.  */
+  void *value = tss_get (key);
+  if (value != 0)
+    FAIL_EXIT1 ("tss_get succeed where it should have failed");
+
+  tss_delete (key);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
2.7.4



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

* [PATCH v8 8/8] Add manual documentation for threads.h
  2018-02-02 17:04 [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
                   ` (6 preceding siblings ...)
  2018-02-02 17:04 ` [PATCH v8 7/8] nptl: Add test cases for ISO " Adhemerval Zanella
@ 2018-02-02 17:04 ` Adhemerval Zanella
  2018-06-27 13:39 ` [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
  8 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella @ 2018-02-02 17:04 UTC (permalink / raw)
  To: libc-alpha; +Cc: Juan Manuel Torres Palma

From: Juan Manuel Torres Palma <j.m.torrespalma@gmail.com>

This patch updates the manual and adds a new chapter to the manual,
explaining types macros, constants and functions defined by ISO C11
threads.h standard.

	* manual/Makefile (chapters): Add isothreads.texi.
	* manual/isothreads.texi: New file. Add new chapter for ISO C11
	threads documentation.
---
 ChangeLog              |   4 +
 manual/Makefile        |   2 +-
 manual/isothreads.texi | 355 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 360 insertions(+), 1 deletion(-)
 create mode 100644 manual/isothreads.texi

diff --git a/manual/Makefile b/manual/Makefile
index c275664..7fb64d7 100644
--- a/manual/Makefile
+++ b/manual/Makefile
@@ -39,7 +39,7 @@ chapters = $(addsuffix .texi, \
 		       pipe socket terminal syslog math arith time	\
 		       resource setjmp signal startup process ipc job	\
 		       nss users sysinfo conf crypt debug threads	\
-		       probes tunables)
+		       probes tunables isothreads)
 appendices = lang.texi header.texi install.texi maint.texi platform.texi \
 	     contrib.texi
 licenses = freemanuals.texi lgpl-2.1.texi fdl-1.3.texi
diff --git a/manual/isothreads.texi b/manual/isothreads.texi
new file mode 100644
index 0000000..bcdf127
--- /dev/null
+++ b/manual/isothreads.texi
@@ -0,0 +1,355 @@
+@node ISO Threads, , , Top
+@chapter ISO C11 threads
+
+This chapter describes @theglibc{} ISO C11 threads implementation.
+To have a deeper understanding of this API, is strongly recomended
+to read ISO/IEC 9899:2011, section 7.26 where ISO C11 threads
+are specified.
+All types and function prototypes are declared in
+@file{threads.h} header.
+@pindex threads.h
+
+@menu
+* Thread Creation and Control:: Support for basic threading.
+* Call Once:: Single call macros and functions.
+* Mutex:: Low level mechanism for mutual exclusion.
+* Condition variable:: High level objects for thread synchronization.
+* Thread-local storage:: Functions to support thread-local storage.
+* C11 error types:: Symbolic constants that represent functions return value.
+@end menu
+
+@node Thread Creation and Control, Call Once, , ISO Threads
+@section Thread Creation and Control
+
+@Theglibc{} implements a set of functions that allow the user to easily
+create and use threads. Many extra functionalities are provided to control
+the behaviour of threads.  The following functions and types are defined:
+
+@deftp {Data Type} {thrd_t}
+Unique object that identifies a thread unequivocally.
+@end deftp
+
+@deftp {Data Type} {thrd_start_t}
+It is a (@code{int (*)(void *)}) typedef that is passed to @code{thrd_create}
+when creating a new thread.  Should point to the first function that thread
+will run.
+@end deftp
+
+@deftypefun int thrd_create (thrd_t *@var{thr}, thrd_start_t @var{func}, void *@var{arg})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Create a new thread executing the function @var{func}.  The object pointed
+by @var{arg} will be taken as @var{func} arguments.  If successful,
+@var{thr} is set to the new thread identifier.
+@end deftypefun
+
+@deftypefun int thrd_equal (thrd_t @var{lhs}, thrd_t @var{rhs})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Checks whether @var{lhs} and @var{rhs} refer to the same thread.
+@end deftypefun
+
+@deftypefun thrd_t thrd_current (void)
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Returns the identifier of the calling thread.
+@end deftypefun
+
+@deftypefun int thrd_sleep (const struct timespec *@var{time_point}, struct timespec *@var{remaining})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Blocks the execution of the current thread for at least until the wall-clock
+time point pointed to by @var{time_point} has been reached.  This function
+does not take an absolute time, but a duration that the thread is required
+to be blocked.
+
+The sleep may resume earlier if a signal that is not ignored is received.
+In such case, if remaining is not NULL, the remaining time duration is stored
+into the object pointed to by @var{remaining}
+@end deftypefun
+
+@deftypefun void thrd_yield (void)
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Provides a hint to the implementation to reschedule the execution of threads,
+allowing other threads to run.
+@end deftypefun
+
+@deftypefun _Noreturn void thrd_exit (int @var{res})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Terminates execution of the calling thread and sets its result code to
+@var{res}.
+If this function is called from a single thread process, the call to this
+function is equivalent to @code{exit(0)}.  Returning from a thread-start
+function is equivalent to calling @code{thrd_exit}.
+@end deftypefun
+
+@deftypefun int thrd_detach (thrd_t @var{thr})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Detaches the thread identified by @var{thr} from the current control thread.
+The resources held by the thread will be freed automatically once the thread
+exits.  The parent thread will never be notified by any @var{thr} signal.
+@end deftypefun
+
+@deftypefun int thrd_join (thrd_t @var{thr}, int *@var{res})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Blocks the current thread until the thread identified by @var{thr} finishes
+execution.  If @var{res} is not a null pointer, the result code of the thread
+is put to the location pointed to by @var{res}.  The termination of the thread
+synchronizes-with the completion of this function.
+The behavior is undefined if the thread was previously detached or joined by
+another thread.
+@end deftypefun
+
+@node Call Once, Mutex, Thread Creation and Control, ISO Threads
+@section Call Once
+
+In order to guarantee single access to a function, @theglibc implements a call
+once function to allow unique access in case a function is required to be
+called only once in presence of several threads.
+
+@deftp {Data Type} {once_flag}
+Complete object type capable of holding a flag used by @code{call_once}
+@end deftp
+
+@deftypevr Macro {} ONCE_FLAG_INIT
+Value established to initialize an object of type @code{once_flag}.
+@end deftypevr
+
+@deftypefun void call_once (once_flag *@var{flag}, void (*@var{func})(void))
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Calls function @var{func} exactly once, even if invoked from several threads.
+The completion of the function @var{func} synchronizes with all previous or
+subsequent calls to @code{call_once} with the same @var{flag} variable.
+@end deftypefun
+
+@node Mutex, Condition variable, Call Once, ISO Threads
+@section Mutex
+
+To have a better control of resources and how threads access them, @theglibc{}
+also implements a mutex object, that allows to avoid race conditions and some
+other concurrency issues.
+
+@deftp {Data Type} {mtx_t}
+Mutex object identifier.
+@end deftp
+
+@deftypefun int mtx_init (mtx_t *@var{mutex}, int @var{type})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Creates a new mutex object with type @var{type}. The object pointed to by
+@var{mutex} is set to an identifier of the newly created mutex.
+@end deftypefun
+
+@deftypefun int mtx_lock (mtx_t *@var{mutex})
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}} Blocks
+the current thread until the mutex pointed to by @var{mutex} is locked.
+The behavior is undefined if the current thread has already locked the mutex
+and the mutex is not recursive.
+Prior calls to @code{mtx_unlock} on the same mutex synchronize-with this
+operation, and all lock/unlock operations on any given mutex form a single
+total order (similar to the modification order of an atomic).
+@end deftypefun
+
+@deftypefun int mtx_timedlock (mtx_t *restrict @var{mutex}, const struct timespec *restrict @var{time_point})
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Blocks the current thread until the mutex pointed to by @var{mutex} is locked
+or until the wall-clock time pointed to by @var{time_point} has been reached.
+This function takes an absolute time, so if a duration is required, must be
+calculated manually and passed to this function.
+
+The behavior is undefined if the current thread has already locked the mutex
+and the mutex is not recursive.  The behavior is undefined if the mutex does
+not support timeout.
+Prior calls to @code{mtx_unlock} on the same mutex synchronize-with this
+operation (if this operation succeeds), and all lock/unlock operations on any
+given mutex form a single total order (similar to the modification order of
+an atomic).
+@end deftypefun
+
+@deftypefun int mtx_trylock (mtx_t *@var{mutex})
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Tries to lock the mutex pointed to by @var{mutex} without blocking.  Returns
+immediately if the mutex is already locked.
+Prior calls to @code{mtx_unlock} on the same mutex synchronize-with this
+operation (if this operation succeeds), and all lock/unlock operations on any
+given mutex form a single total order (similar to the modification order of
+an atomic).
+@end deftypefun
+
+@deftypefun int mtx_unlock (mtx_t *@var{mutex})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Unlocks the mutex pointed to by @var{mutex}. The behavior is undefined if the
+mutex is not locked by the calling thread.  This function synchronizes-with
+subsequent @code{mtx_lock}, @code{mtx_trylock}, or @code{mtx_timedlock} on
+the same mutex.  All lock/unlock operations on any given mutex form a single
+total order (similar to the modification order of an atomic).
+@end deftypefun
+
+@deftypefun void mtx_destroy (mtx_t *@var{mutex})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Destroys the mutex pointed to by @var{mutex}.  If there are threads waiting
+on mutex, the behavior is undefined.
+@end deftypefun
+
+The ISO C11 standard also defines several types of mutex that are also
+supported.  They are represented with symbolic constants (enumeration type
+values) and are the following:
+
+@vtable @code
+
+@item mtx_plain
+Mutex type that does not support timeout or test and return.
+
+@item mtx_recursive
+Mutex type that supports recursive locking, what means that owner thread can
+lock it twice or more without causing deadlock.
+
+@item mtx_timed
+Mutex type that supports timeout.
+
+@end vtable
+
+@node Condition variable, Thread-local storage, Mutex, ISO Threads
+@section Condition Variable
+
+Mutexes are not the only synchronization mechanisms available.  For some more
+complex tasks, @theglibc{} also implements conditional variables, that allow
+the user to think in a higher level to solve complex synchronization problems.
+They are used to synchronize threads waiting on a certain condition to happen.
+
+@deftp {Data Type} {cnd_t}
+Condition variable object identifier.
+@end deftp
+
+@deftypefun int cnd_init (cnd_t *@var{cond})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Initializes new conditional variable.  The object pointed to by @var{cond}
+will be set to value that identifies the conditional variable.
+@end deftypefun
+
+@deftypefun int cnd_signal (cnd_t *@var{cond})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Unblocks one thread that currently waits on conditional variable pointed to
+by @var{cond}.  If no threads are blocked, does nothing and returns
+@code{thrd_success}.
+@end deftypefun
+
+@deftypefun int cnd_broadcast (cnd_t *@var{cond})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Unblocks all threads that currently wait on conditional variable pointed to
+by @var{cond}.  If no threads are blocked, does nothing and returns
+@code{thrd_success}.
+@end deftypefun
+
+@deftypefun int cnd_wait (cnd_t *@var{cond}, mtx_t *@var{mutex})
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Atomically unlocks the mutex pointed to by @var{mutex} and blocks on the
+conditional variable pointed to by @var{cond} until the thread is signalled
+by @code{cnd_signal} or @code{cnd_broadcast}.  The mutex is locked again
+before the function returns.
+@end deftypefun
+
+@deftypefun int cnd_timedwait (cnd_t *restrict @var{cond}, mtx_t *restrict @var{mutex}, const struct timespec *restrict @var{time_point})
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Atomically unlocks the mutex pointed to by @var{mutex} and blocks on the
+conditional variable pointed to by @var{cond} until the thread is signalled
+by @code{cnd_signal} or @code{cnd_broadcast}, or until the wall-clock time
+pointed to by @var{time_point} has been reached.  The mutex is locked again
+before the function returns.
+As for @code{mtx_timedlock}, this function also takes an absolute time
+rather than a duration.
+@end deftypefun
+
+@deftypefun void cnd_destroy (cnd_t *@var{cond})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Destroys the conditional variable pointed to by @var{cond}.  If there are
+threads waiting on @var{cond}, the behavior is undefined.
+@end deftypefun
+
+@node Thread-local storage, C11 error types, Condition variable, ISO Threads
+@section Thread-local Storage
+
+@Theglibc{} also implements different functions that adds funtionality for
+thread-local storage.  That means that each thread can have their own
+variables and are not visible by other threads.  The functions and types
+provided are:
+
+@deftp {Data Type} {tss_t}
+Thread-specific storage object.  Even if shared, every thread will have
+its own instance of that variable with different values.
+@end deftp
+
+@deftp {Data Type} {tss_dtor_t}
+Function pointer of type @code{void(*)(void*)}, used for TSS destructor.
+This function will be called when the current thread calls @code{thrd_exit},
+but never when calling @code{tss_delete} or @code{exit}
+@end deftp
+
+@deftypevr Macro {} thread_local
+Used to mark a variable with thread storage duration, that means created
+when the thread starts and cleaned up when the thread ends.
+@end deftypevr
+
+@deftypevr Macro {} TSS_DTOR_ITERATIONS
+Integer constant expression representing the maximum number of times that
+destructors will be called when a thread terminates.
+@end deftypevr
+
+@deftypefun int tss_create (tss_t *@var{tss_key}, tss_dtor_t @var{destructor})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Creates new thread-specific storage key and stores it in the object pointed
+to by @var{tss_key}.  Although the same key value may be used by different
+threads, the values bound to the key by @code{tss_set} are maintained on a
+per-thread basis and persist for the life of the calling thread.
+
+If @var{destructor} is different to NULL, a destructor function will be set,
+and called when the thread finishes its execution by calling @code{thrd_exit}.
+@end deftypefun
+
+@deftypefun void *tss_get (tss_t @var{tss_key})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Returns the value held in thread-specific storage for the current thread
+identified by @var{tss_key}.  Different threads may get different values
+identified by the same key.
+@end deftypefun
+
+@deftypefun int tss_set (tss_t @var{tss_id}, void *@var{val})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Sets the value of the thread-specific storage identified by @var{tss_id} for
+the current thread to @var{val}.  Different threads may set different values
+to the same key.  The destructor, if available, is not invoked.
+@end deftypefun
+
+@deftypefun void tss_delete (tss_t @var{tss_id})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Destroys the thread-specific storage identified by @var{tss_id}.  The
+destructor, if one was registered by @code{tss_create}, is not called.
+@end deftypefun
+
+@node C11 error types, , Thread-local storage, ISO Threads
+@section Error Types
+
+The ISO C11 specification also provides new error types that belong
+specifically to @code{threads.h}.  @Theglibc{} has also implemented this
+feature and every function in this API always returns one of the following
+error codes:
+
+@vtable @code
+
+@item thrd_timedout
+Value returned by a function to indicate that a specified time was reached
+without acquiring the requested resource, usually a mutex or conditional
+variable.
+
+@item thrd_sucess
+Value returned by a function to indicate that the requested operation
+succeded.
+
+@item thrd_busy
+Value returned by a function to indicate that the requested operation
+failed because a resource requested is already in use.
+
+@item thrd_error
+Value returned by a function to indicate that the requested operation
+failed.
+
+@item thrd_nomem
+Value returned by a function to indicate that the requested operation
+failed because it was unable to allocate enough memory.
+
+@end vtable
-- 
2.7.4



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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-02-02 17:04 ` [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions Adhemerval Zanella
@ 2018-02-08 13:49   ` Gabriel F. T. Gomes
  2018-02-09 10:56     ` Adhemerval Zanella
  2018-07-06 12:46   ` Florian Weimer
                     ` (4 subsequent siblings)
  5 siblings, 1 reply; 80+ messages in thread
From: Gabriel F. T. Gomes @ 2018-02-08 13:49 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

I have only a few, minor comments.

On Fri, 02 Feb 2018, Adhemerval Zanella wrote:

>-/* We do not support C11 <threads.h>.  */
>-#define __STDC_NO_THREADS__		1

I don't know if that actually matters, but should you wait until the other
patches in this series (at least patch 2) are in before removing this
definition?

>+int
>+thrd_sleep (const struct timespec* time_point, struct timespec* remaining)
>+{
>+  /* It calls the syscalls directly to avoid cancellable version.  */
>+  INTERNAL_SYSCALL_DECL (err);
>+  int ret = INTERNAL_SYSCALL_CALL (nanosleep, err, time_point, remaining);
>+  if (INTERNAL_SYSCALL_ERROR_P (ret, err))
>+    {
>+      /* C11 states thrd_sleep function returns -1 if it has been interrupted
>+         by a signal, or a negative value if it fails.  */
  ~~~~~~~~~
This hunk did not apply with git am, because there are more than 8 spaces.

>+/* Detach the thread identified by __THR from the current environment
>+   (tt does not allow join or wait for it).  */
      ~~
Did you mean "it"?  Or is "tt" something else that I did not understand.


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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-02-08 13:49   ` Gabriel F. T. Gomes
@ 2018-02-09 10:56     ` Adhemerval Zanella
  2018-02-26 12:28       ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-02-09 10:56 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 08/02/2018 11:49, Gabriel F. T. Gomes wrote:
> I have only a few, minor comments.
> 
> On Fri, 02 Feb 2018, Adhemerval Zanella wrote:
> 
>> -/* We do not support C11 <threads.h>.  */
>> -#define __STDC_NO_THREADS__		1
> 
> I don't know if that actually matters, but should you wait until the other
> patches in this series (at least patch 2) are in before removing this
> definition?
>

I do not have a strong opinion about when to remove __STDC_NO_THREADS__, since
my idea is first get all patches reviewed and acked before actually commit then.

 
>> +int
>> +thrd_sleep (const struct timespec* time_point, struct timespec* remaining)
>> +{
>> +  /* It calls the syscalls directly to avoid cancellable version.  */
>> +  INTERNAL_SYSCALL_DECL (err);
>> +  int ret = INTERNAL_SYSCALL_CALL (nanosleep, err, time_point, remaining);
>> +  if (INTERNAL_SYSCALL_ERROR_P (ret, err))
>> +    {
>> +      /* C11 states thrd_sleep function returns -1 if it has been interrupted
>> +         by a signal, or a negative value if it fails.  */
>   ~~~~~~~~~
> This hunk did not apply with git am, because there are more than 8 spaces.

Thanks, I fixed it locally (I also keep my user branch in sync [1]).

> 
>> +/* Detach the thread identified by __THR from the current environment
>> +   (tt does not allow join or wait for it).  */
>       ~~
> Did you mean "it"?  Or is "tt" something else that I did not understand.
> 

It should be 'it', fixed it locally.

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


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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-02-09 10:56     ` Adhemerval Zanella
@ 2018-02-26 12:28       ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 80+ messages in thread
From: Gabriel F. T. Gomes @ 2018-02-26 12:28 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, 09 Feb 2018, Adhemerval Zanella wrote:
>On 08/02/2018 11:49, Gabriel F. T. Gomes wrote:
>> On Fri, 02 Feb 2018, Adhemerval Zanella wrote:
>>   
>>> -/* We do not support C11 <threads.h>.  */
>>> -#define __STDC_NO_THREADS__		1  
>> 
>> I don't know if that actually matters, but should you wait until the other
>> patches in this series (at least patch 2) are in before removing this
>> definition?
>
>I do not have a strong opinion about when to remove __STDC_NO_THREADS__, since
>my idea is first get all patches reviewed and acked before actually commit then.

Fair enough.

I also reviewed the other patches in this set, and I don't have further
comments other than the cosmetic bit below.

(Since I'm definitely *not* an expert at threads, I only checked against
the standard and it looks good to me.  So, please read this review as one
from a novice)


On patch 4:

>+/* Destroy condition variable pointed by __cond and free all of its
>+   resources.  */
>+extern void cnd_destroy (cnd_t *__COND);  
                                  ~~~~~~
Only here, the parameter name is in uppercase (and the comment in
lowercase).  Any special reason to do so?


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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h
  2018-02-02 17:04 [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
                   ` (7 preceding siblings ...)
  2018-02-02 17:04 ` [PATCH v8 8/8] Add manual documentation for threads.h Adhemerval Zanella
@ 2018-06-27 13:39 ` Adhemerval Zanella
  2018-07-19 17:46   ` Adhemerval Zanella
  8 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-06-27 13:39 UTC (permalink / raw)
  To: libc-alpha

Ping, do we still want this for 2.28 release?

On 02/02/2018 15:04, Adhemerval Zanella wrote:
> This is a new update for C11 threads support based on my previous [1]
> version.  The main changes from previous version are:
>  
>   - Rebase against 2.28.
> 
>   - Add RISCV abilist symbols.
>  
>   - Adjusted copyright dates for 2018.
>  
>   - Remove some redundant comments.
>  
> I tested this without regression with a full make/check on
> x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
> powerpc-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabihf,
> sparc64-linux-gnu, and sparcv9-linux-gnu.
>  
> [1] https://sourceware.org/ml/libc-alpha/2017-09/msg00871.html
> 
> Adhemerval Zanella (7):
>   nptl: Add C11 threads thrd_* functions
>   nptl: Add C11 threads mtx_* functions
>   nptl: Add C11 threads call_once functions
>   nptl: Add C11 threads cnd_* functions
>   nptl: Add C11 threads tss_* functions
>   nptl: Add abilist symbols for C11 threads
>   nptl: Add test cases for ISO C11 threads
> 
> Juan Manuel Torres Palma (1):
>   Add manual documentation for threads.h
> 
>  ChangeLog                                          | 175 ++++++++++
>  conform/Makefile                                   |   7 +-
>  conform/data/threads.h-data                        |  57 ++++
>  include/stdc-predef.h                              |   3 -
>  manual/Makefile                                    |   2 +-
>  manual/isothreads.texi                             | 355 +++++++++++++++++++++
>  nptl/Makefile                                      |  15 +-
>  nptl/Versions                                      |   9 +
>  nptl/call_once.c                                   |  31 ++
>  nptl/cnd_broadcast.c                               |  26 ++
>  nptl/cnd_destroy.c                                 |  26 ++
>  nptl/cnd_init.c                                    |  32 ++
>  nptl/cnd_signal.c                                  |  26 ++
>  nptl/cnd_timedwait.c                               |  29 ++
>  nptl/cnd_wait.c                                    |  27 ++
>  nptl/descr.h                                       |   2 +
>  nptl/mtx_destroy.c                                 |  26 ++
>  nptl/mtx_init.c                                    |  52 +++
>  nptl/mtx_lock.c                                    |  26 ++
>  nptl/mtx_timedlock.c                               |  28 ++
>  nptl/mtx_trylock.c                                 |  26 ++
>  nptl/mtx_unlock.c                                  |  26 ++
>  nptl/pthreadP.h                                    |   3 +
>  nptl/pthread_create.c                              |  18 +-
>  nptl/thrd_create.c                                 |  29 ++
>  nptl/thrd_current.c                                |  25 ++
>  nptl/thrd_detach.c                                 |  28 ++
>  nptl/thrd_equal.c                                  |  25 ++
>  nptl/thrd_exit.c                                   |  25 ++
>  nptl/thrd_join.c                                   |  30 ++
>  nptl/thrd_priv.h                                   |  45 +++
>  nptl/thrd_sleep.c                                  |  38 +++
>  nptl/thrd_yield.c                                  |  26 ++
>  nptl/tss_create.c                                  |  28 ++
>  nptl/tss_delete.c                                  |  25 ++
>  nptl/tss_get.c                                     |  25 ++
>  nptl/tss_set.c                                     |  26 ++
>  nptl/tst-call-once.c                               |  66 ++++
>  nptl/tst-cnd-basic.c                               |  68 ++++
>  nptl/tst-cnd-broadcast.c                           |  83 +++++
>  nptl/tst-cnd-timedwait.c                           |  70 ++++
>  nptl/tst-mtx-basic.c                               |  73 +++++
>  nptl/tst-mtx-recursive.c                           |  45 +++
>  nptl/tst-mtx-timedlock.c                           |  98 ++++++
>  nptl/tst-mtx-trylock.c                             |  90 ++++++
>  nptl/tst-thrd-detach.c                             |  52 +++
>  nptl/tst-thrd-sleep.c                              |  51 +++
>  nptl/tst-tss-basic.c                               |  75 +++++
>  sysdeps/nptl/threads.h                             | 200 ++++++++++++
>  sysdeps/unix/sysv/linux/aarch64/libpthread.abilist |  26 ++
>  sysdeps/unix/sysv/linux/alpha/libpthread.abilist   |  26 ++
>  sysdeps/unix/sysv/linux/arm/libpthread.abilist     |  26 ++
>  sysdeps/unix/sysv/linux/hppa/libpthread.abilist    |  26 ++
>  sysdeps/unix/sysv/linux/i386/libpthread.abilist    |  26 ++
>  sysdeps/unix/sysv/linux/ia64/libpthread.abilist    |  26 ++
>  .../sysv/linux/m68k/coldfire/libpthread.abilist    |  26 ++
>  .../unix/sysv/linux/m68k/m680x0/libpthread.abilist |  26 ++
>  .../unix/sysv/linux/microblaze/libpthread.abilist  |  26 ++
>  .../unix/sysv/linux/mips/mips32/libpthread.abilist |  26 ++
>  .../unix/sysv/linux/mips/mips64/libpthread.abilist |  26 ++
>  sysdeps/unix/sysv/linux/nios2/libpthread.abilist   |  26 ++
>  .../linux/powerpc/powerpc32/libpthread.abilist     |  26 ++
>  .../linux/powerpc/powerpc64/libpthread-le.abilist  |  26 ++
>  .../linux/powerpc/powerpc64/libpthread.abilist     |  26 ++
>  .../unix/sysv/linux/riscv/rv64/libpthread.abilist  |  26 ++
>  .../sysv/linux/s390/s390-32/libpthread.abilist     |  26 ++
>  .../sysv/linux/s390/s390-64/libpthread.abilist     |  26 ++
>  sysdeps/unix/sysv/linux/sh/libpthread.abilist      |  26 ++
>  .../sysv/linux/sparc/sparc32/libpthread.abilist    |  26 ++
>  .../sysv/linux/sparc/sparc64/libpthread.abilist    |  26 ++
>  .../sysv/linux/tile/tilegx32/libpthread.abilist    |  26 ++
>  .../sysv/linux/tile/tilegx64/libpthread.abilist    |  26 ++
>  .../unix/sysv/linux/x86_64/64/libpthread.abilist   |  26 ++
>  .../unix/sysv/linux/x86_64/x32/libpthread.abilist  |  26 ++
>  74 files changed, 3011 insertions(+), 12 deletions(-)
>  create mode 100644 conform/data/threads.h-data
>  create mode 100644 manual/isothreads.texi
>  create mode 100644 nptl/call_once.c
>  create mode 100644 nptl/cnd_broadcast.c
>  create mode 100644 nptl/cnd_destroy.c
>  create mode 100644 nptl/cnd_init.c
>  create mode 100644 nptl/cnd_signal.c
>  create mode 100644 nptl/cnd_timedwait.c
>  create mode 100644 nptl/cnd_wait.c
>  create mode 100644 nptl/mtx_destroy.c
>  create mode 100644 nptl/mtx_init.c
>  create mode 100644 nptl/mtx_lock.c
>  create mode 100644 nptl/mtx_timedlock.c
>  create mode 100644 nptl/mtx_trylock.c
>  create mode 100644 nptl/mtx_unlock.c
>  create mode 100644 nptl/thrd_create.c
>  create mode 100644 nptl/thrd_current.c
>  create mode 100644 nptl/thrd_detach.c
>  create mode 100644 nptl/thrd_equal.c
>  create mode 100644 nptl/thrd_exit.c
>  create mode 100644 nptl/thrd_join.c
>  create mode 100644 nptl/thrd_priv.h
>  create mode 100644 nptl/thrd_sleep.c
>  create mode 100644 nptl/thrd_yield.c
>  create mode 100644 nptl/tss_create.c
>  create mode 100644 nptl/tss_delete.c
>  create mode 100644 nptl/tss_get.c
>  create mode 100644 nptl/tss_set.c
>  create mode 100644 nptl/tst-call-once.c
>  create mode 100644 nptl/tst-cnd-basic.c
>  create mode 100644 nptl/tst-cnd-broadcast.c
>  create mode 100644 nptl/tst-cnd-timedwait.c
>  create mode 100644 nptl/tst-mtx-basic.c
>  create mode 100644 nptl/tst-mtx-recursive.c
>  create mode 100644 nptl/tst-mtx-timedlock.c
>  create mode 100644 nptl/tst-mtx-trylock.c
>  create mode 100644 nptl/tst-thrd-detach.c
>  create mode 100644 nptl/tst-thrd-sleep.c
>  create mode 100644 nptl/tst-tss-basic.c
>  create mode 100644 sysdeps/nptl/threads.h
> 

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-02-02 17:04 ` [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions Adhemerval Zanella
  2018-02-08 13:49   ` Gabriel F. T. Gomes
@ 2018-07-06 12:46   ` Florian Weimer
  2018-07-10 19:26     ` Adhemerval Zanella
  2018-07-12 16:46   ` Florian Weimer
                     ` (3 subsequent siblings)
  5 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-06 12:46 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
> @@ -139,7 +139,9 @@ libpthread-routines = nptl-init vars events version pt-interp \
>   		      pthread_mutex_getprioceiling \
>   		      pthread_mutex_setprioceiling \
>   		      pthread_setname pthread_getname \
> -		      pthread_setattr_default_np pthread_getattr_default_np
> +		      pthread_setattr_default_np pthread_getattr_default_np \
> +		      thrd_create thrd_current thrd_detach thrd_equal \

thrd_current should live in libc, not in libpthread.  Same for 
thrd_equal, I suppose.  You should just duplicate the comparison, seeing 
that we haven't done that particular cleanup for pthread_equal yet.

Not sure about thrd_sleep and thrd_yield, but I lean towards libc there 
as well.

Thanks,
Florian

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

* Re: [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions
  2018-02-02 17:04 ` [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions Adhemerval Zanella
@ 2018-07-06 12:51   ` Florian Weimer
  2018-07-10 12:35     ` Adhemerval Zanella
  2018-07-24 12:04   ` Adhemerval Zanella
  1 sibling, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-06 12:51 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
> This patch adds the mtx_* definitions from C11 threads (ISO/IEC 9899:2011),
> more specifically mtx_init, mtx_destroy, mtx_lock, mtx_timedlock, mtx_trylock,
> mtx_unlock, and required types.
> 
> Mostly of the definitions are composed based on POSIX conterparts, and mtx_t
> is also based on internal pthread fields, but with a distinct internal layout
> to avoid possible issues with code interchange (such as trying to pass POSIX
> structure on C11 functions and to avoid inclusion of pthread.h).  The idea
> is to make possible to share POSIX internal implementations for mostly of
> the code (and making adjustment only when required).

Should we check for the supported mutex types and error out if the type 
does not match?  The interface does not support the full range of error 
codes required by robust mutexes, for example—EOWNERDEAD is missing.

Thanks,
Florian


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

* Re: [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions
  2018-07-06 12:51   ` Florian Weimer
@ 2018-07-10 12:35     ` Adhemerval Zanella
  2018-07-12 18:39       ` Florian Weimer
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-10 12:35 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 06/07/2018 09:51, Florian Weimer wrote:
> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>> This patch adds the mtx_* definitions from C11 threads (ISO/IEC 9899:2011),
>> more specifically mtx_init, mtx_destroy, mtx_lock, mtx_timedlock, mtx_trylock,
>> mtx_unlock, and required types.
>>
>> Mostly of the definitions are composed based on POSIX conterparts, and mtx_t
>> is also based on internal pthread fields, but with a distinct internal layout
>> to avoid possible issues with code interchange (such as trying to pass POSIX
>> structure on C11 functions and to avoid inclusion of pthread.h).  The idea
>> is to make possible to share POSIX internal implementations for mostly of
>> the code (and making adjustment only when required).
> 
> Should we check for the supported mutex types and error out if the type does not match?  The interface does not support the full range of error codes required by robust mutexes, for example—EOWNERDEAD is missing.
> 

I am not sure if adding extra tests will yield any gain, specially on mutex
operations which users would expect optimized fast paths.  I really think
we should handle as undefined behaviour if uses try to use pthread_t objects
with c11 threads function (in similar manner it is undefined behaviour if
uses messes with internal pthread_mutex_t objects data directly).

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-06 12:46   ` Florian Weimer
@ 2018-07-10 19:26     ` Adhemerval Zanella
  2018-07-11 15:49       ` Szabolcs Nagy
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-10 19:26 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 06/07/2018 09:46, Florian Weimer wrote:
> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>> @@ -139,7 +139,9 @@ libpthread-routines = nptl-init vars events version pt-interp \
>>                 pthread_mutex_getprioceiling \
>>                 pthread_mutex_setprioceiling \
>>                 pthread_setname pthread_getname \
>> -              pthread_setattr_default_np pthread_getattr_default_np
>> +              pthread_setattr_default_np pthread_getattr_default_np \
>> +              thrd_create thrd_current thrd_detach thrd_equal \
> 
> thrd_current should live in libc, not in libpthread.  Same for thrd_equal, I suppose.  You should just duplicate the comparison, seeing that we haven't done that particular cleanup for pthread_equal yet.
> 
> Not sure about thrd_sleep and thrd_yield, but I lean towards libc there as well.

Right, I added all four symbols (thrd_current, thrd_equal, thrd_sleep, and
thrd_yield) to libc on my personal branch [1] (the change is just to move
the objects from libpthread-routines to routines rule in nptl/Makefile).
I also adjusted the abilist patch with the change.


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

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-10 19:26     ` Adhemerval Zanella
@ 2018-07-11 15:49       ` Szabolcs Nagy
  2018-07-11 16:24         ` Adhemerval Zanella
  0 siblings, 1 reply; 80+ messages in thread
From: Szabolcs Nagy @ 2018-07-11 15:49 UTC (permalink / raw)
  To: Adhemerval Zanella, Florian Weimer, libc-alpha; +Cc: nd

On 10/07/18 20:26, Adhemerval Zanella wrote:
> 
> 
> On 06/07/2018 09:46, Florian Weimer wrote:
>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>> @@ -139,7 +139,9 @@ libpthread-routines = nptl-init vars events version pt-interp \
>>>                  pthread_mutex_getprioceiling \
>>>                  pthread_mutex_setprioceiling \
>>>                  pthread_setname pthread_getname \
>>> -              pthread_setattr_default_np pthread_getattr_default_np
>>> +              pthread_setattr_default_np pthread_getattr_default_np \
>>> +              thrd_create thrd_current thrd_detach thrd_equal \
>>
>> thrd_current should live in libc, not in libpthread.  Same for thrd_equal, I suppose.  You should just duplicate the comparison, seeing that we haven't done that particular cleanup for pthread_equal yet.
>>
>> Not sure about thrd_sleep and thrd_yield, but I lean towards libc there as well.
> 
> Right, I added all four symbols (thrd_current, thrd_equal, thrd_sleep, and
> thrd_yield) to libc on my personal branch [1] (the change is just to move
> the objects from libpthread-routines to routines rule in nptl/Makefile).
> I also adjusted the abilist patch with the change.
> 

the abilist patch seems to add
sysdeps/unix/sysv/linux/tile/tilegx64/libpthread.abilist
i think you can drop that (and update the ChangeLog).

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


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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-11 15:49       ` Szabolcs Nagy
@ 2018-07-11 16:24         ` Adhemerval Zanella
  2018-07-12 12:18           ` Florian Weimer
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-11 16:24 UTC (permalink / raw)
  To: Szabolcs Nagy, Florian Weimer, libc-alpha; +Cc: nd



On 11/07/2018 12:49, Szabolcs Nagy wrote:
> On 10/07/18 20:26, Adhemerval Zanella wrote:
>>
>>
>> On 06/07/2018 09:46, Florian Weimer wrote:
>>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>>> @@ -139,7 +139,9 @@ libpthread-routines = nptl-init vars events version pt-interp \
>>>>                  pthread_mutex_getprioceiling \
>>>>                  pthread_mutex_setprioceiling \
>>>>                  pthread_setname pthread_getname \
>>>> -              pthread_setattr_default_np pthread_getattr_default_np
>>>> +              pthread_setattr_default_np pthread_getattr_default_np \
>>>> +              thrd_create thrd_current thrd_detach thrd_equal \
>>>
>>> thrd_current should live in libc, not in libpthread.  Same for thrd_equal, I suppose.  You should just duplicate the comparison, seeing that we haven't done that particular cleanup for pthread_equal yet.
>>>
>>> Not sure about thrd_sleep and thrd_yield, but I lean towards libc there as well.
>>
>> Right, I added all four symbols (thrd_current, thrd_equal, thrd_sleep, and
>> thrd_yield) to libc on my personal branch [1] (the change is just to move
>> the objects from libpthread-routines to routines rule in nptl/Makefile).
>> I also adjusted the abilist patch with the change.
>>
> 
> the abilist patch seems to add
> sysdeps/unix/sysv/linux/tile/tilegx64/libpthread.abilist
> i think you can drop that (and update the ChangeLog).

Thanks for catching this up, I fixed on my personal c11 thread branch.

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-11 16:24         ` Adhemerval Zanella
@ 2018-07-12 12:18           ` Florian Weimer
  2018-07-12 17:38             ` Adhemerval Zanella
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-12 12:18 UTC (permalink / raw)
  To: Adhemerval Zanella, Szabolcs Nagy, libc-alpha; +Cc: nd

[-- Attachment #1: Type: text/plain, Size: 1956 bytes --]

On 07/11/2018 06:24 PM, Adhemerval Zanella wrote:
> 
> 
> On 11/07/2018 12:49, Szabolcs Nagy wrote:
>> On 10/07/18 20:26, Adhemerval Zanella wrote:
>>>
>>>
>>> On 06/07/2018 09:46, Florian Weimer wrote:
>>>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>>>> @@ -139,7 +139,9 @@ libpthread-routines = nptl-init vars events version pt-interp \
>>>>>                   pthread_mutex_getprioceiling \
>>>>>                   pthread_mutex_setprioceiling \
>>>>>                   pthread_setname pthread_getname \
>>>>> -              pthread_setattr_default_np pthread_getattr_default_np
>>>>> +              pthread_setattr_default_np pthread_getattr_default_np \
>>>>> +              thrd_create thrd_current thrd_detach thrd_equal \
>>>>
>>>> thrd_current should live in libc, not in libpthread.  Same for thrd_equal, I suppose.  You should just duplicate the comparison, seeing that we haven't done that particular cleanup for pthread_equal yet.
>>>>
>>>> Not sure about thrd_sleep and thrd_yield, but I lean towards libc there as well.
>>>
>>> Right, I added all four symbols (thrd_current, thrd_equal, thrd_sleep, and
>>> thrd_yield) to libc on my personal branch [1] (the change is just to move
>>> the objects from libpthread-routines to routines rule in nptl/Makefile).
>>> I also adjusted the abilist patch with the change.
>>>
>>
>> the abilist patch seems to add
>> sysdeps/unix/sysv/linux/tile/tilegx64/libpthread.abilist
>> i think you can drop that (and update the ChangeLog).
> 
> Thanks for catching this up, I fixed on my personal c11 thread branch.

I still see the attached ABI diffs.

There is also a new linknamespace failure on hppa:

[initial] thrd_create -> [libpthread.a(thrd_create.o)] 
__pthread_create_2_1 -> [libpthread.a(pthread_create.o)] mprotect

That should be easy to fix.  I'll post a separate patch for that.

Thanks,
Florian

[-- Attachment #2: abi-diffs.txt --]
[-- Type: text/plain, Size: 8078 bytes --]

==> /home/bmg/build/glibcs/i686-gnu/glibc/hurd/check-abi-libhurduser.out <==
--- ../sysdeps/mach/hurd/libhurduser.abilist	2018-07-05 06:10:49.243248916 -0400
+++ /home/bmg/build/glibcs/i686-gnu/glibc/hurd/libhurduser.symlist	2018-07-12 07:38:17.405204797 -0400
@@ -0,0 +1,611 @@
+Base _S_msg_server F
+Base _S_msg_server_routines D 0x64
+Base __auth_getids F
+Base __auth_makeauth F
+Base __auth_server_authenticate F
+Base __auth_user_authenticate F
+Base __bss_start Base g ? D .bss 00000000
+Base __crash_dump_task F
+Base __dir_link F
+Base __dir_lookup F
+Base __dir_mkdir F
+Base __dir_mkfile F
+Base __dir_notice_changes F
+Base __dir_readdir F
+Base __dir_rename F
+Base __dir_rmdir F
+Base __dir_unlink F
+Base __exec_exec F
+Base __exec_exec_paths F
+Base __exec_init F
+Base __exec_setexecdata F
+Base __exec_startup_get_info F
+Base __file_chauthor F
+Base __file_check_access F
+Base __file_chflags F
+Base __file_chmod F
+Base __file_chown F
+Base __file_exec F
+Base __file_exec_paths F
+Base __file_get_fs_options F
+Base __file_get_storage_info F
+Base __file_get_translator F
+Base __file_get_translator_cntl F
+Base __file_getcontrol F
+Base __file_getfh F
+Base __file_getlinknode F
+Base __file_lock F
+Base __file_lock_stat F
+Base __file_notice_changes F
+Base __file_reparent F
+Base __file_set_size F
+Base __file_set_translator F
+Base __file_statfs F
+Base __file_sync F
+Base __file_syncfs F
+Base __file_utimens F
+Base __file_utimes F

==> /home/bmg/build/glibcs/i686-gnu/glibc/mach/check-abi-libmachuser.out <==
--- ../sysdeps/mach/libmachuser.abilist	2018-07-05 06:10:49.254249207 -0400
+++ /home/bmg/build/glibcs/i686-gnu/glibc/mach/libmachuser.symlist	2018-07-12 07:36:45.837658100 -0400
@@ -0,0 +1,319 @@
+Base _S_exc_server F
+Base _S_exc_server_routines D 0x4
+Base __bss_start Base g ? D .bss 00000000
+Base __default_pager_info F
+Base __default_pager_object_create F
+Base __default_pager_object_pages F
+Base __default_pager_objects F
+Base __default_pager_paging_file F
+Base __default_pager_register_fileserver F
+Base __device_close F
+Base __device_get_status F
+Base __device_map F
+Base __device_open F
+Base __device_open_request F
+Base __device_read F
+Base __device_read_inband F
+Base __device_read_request F
+Base __device_read_request_inband F
+Base __device_set_filter F
+Base __device_set_status F
+Base __device_write F
+Base __device_write_inband F
+Base __device_write_request F
+Base __device_write_request_inband F
+Base __exception_raise F
+Base __gsync_requeue F
+Base __gsync_wait F
+Base __gsync_wake F
+Base __host_adjust_time F
+Base __host_get_boot_info F
+Base __host_get_time F
+Base __host_info F
+Base __host_kernel_version F
+Base __host_processor_set_priv F
+Base __host_processor_sets F
+Base __host_processors F
+Base __host_reboot F
+Base __host_set_time F
+Base __i386_get_gdt F
+Base __i386_get_ldt F
+Base __i386_io_perm_create F
+Base __i386_io_perm_modify F
+Base __i386_set_gdt F
+Base __i386_set_ldt F
+Base __mach_notify_new_task F
+Base __mach_port_allocate_name_rpc F
+Base __mach_port_allocate_rpc F

==> /home/bmg/build/glibcs/m68k-linux-gnu-coldfire/glibc/elf/check-abi-libc.out <==
--- ../sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist	2018-07-10 08:15:53.535227613 -0400
+++ /home/bmg/build/glibcs/m68k-linux-gnu-coldfire/glibc/libc.symlist	2018-07-12 07:54:17.126989778 -0400
@@ -122,0 +123,4 @@ GLIBC_2.28 statx F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F

==> /home/bmg/build/glibcs/m68k-linux-gnu-coldfire/glibc/nptl/check-abi-libpthread.out <==
--- ../sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist	2018-07-12 07:14:24.376165898 -0400
+++ /home/bmg/build/glibcs/m68k-linux-gnu-coldfire/glibc/nptl/libpthread.symlist	2018-07-12 07:44:19.285683784 -0400
@@ -23 +22,0 @@ GLIBC_2.28 thrd_create F
-GLIBC_2.28 thrd_current F
@@ -25 +23,0 @@ GLIBC_2.28 thrd_detach F
-GLIBC_2.28 thrd_equal F
@@ -28,2 +25,0 @@ GLIBC_2.28 thrd_join F
-GLIBC_2.28 thrd_sleep F
-GLIBC_2.28 thrd_yield F

==> /home/bmg/build/glibcs/m68k-linux-gnu-coldfire-soft/glibc/elf/check-abi-libc.out <==
--- ../sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist	2018-07-10 08:15:53.535227613 -0400
+++ /home/bmg/build/glibcs/m68k-linux-gnu-coldfire-soft/glibc/libc.symlist	2018-07-12 07:59:42.365934960 -0400
@@ -122,0 +123,4 @@ GLIBC_2.28 statx F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F

==> /home/bmg/build/glibcs/m68k-linux-gnu-coldfire-soft/glibc/nptl/check-abi-libpthread.out <==
--- ../sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist	2018-07-12 07:14:24.376165898 -0400
+++ /home/bmg/build/glibcs/m68k-linux-gnu-coldfire-soft/glibc/nptl/libpthread.symlist	2018-07-12 07:45:38.102269392 -0400
@@ -23 +22,0 @@ GLIBC_2.28 thrd_create F
-GLIBC_2.28 thrd_current F
@@ -25 +23,0 @@ GLIBC_2.28 thrd_detach F
-GLIBC_2.28 thrd_equal F
@@ -28,2 +25,0 @@ GLIBC_2.28 thrd_join F
-GLIBC_2.28 thrd_sleep F
-GLIBC_2.28 thrd_yield F

==> /home/bmg/build/glibcs/mipsel-linux-gnu-nan2008-soft/glibc/elf/check-abi-libc.out <==
--- ../sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist	2018-07-10 08:15:53.536227638 -0400
+++ /home/bmg/build/glibcs/mipsel-linux-gnu-nan2008-soft/glibc/libc.symlist	2018-07-12 08:05:48.875315449 -0400
@@ -1963,0 +1964,4 @@ GLIBC_2.28 statx F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F

==> /home/bmg/build/glibcs/mipsel-linux-gnu-soft/glibc/elf/check-abi-libc.out <==
--- ../sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist	2018-07-10 08:15:53.536227638 -0400
+++ /home/bmg/build/glibcs/mipsel-linux-gnu-soft/glibc/libc.symlist	2018-07-12 08:07:26.234527478 -0400
@@ -1963,0 +1964,4 @@ GLIBC_2.28 statx F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F

==> /home/bmg/build/glibcs/mips-linux-gnu-nan2008-soft/glibc/elf/check-abi-libc.out <==
--- ../sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist	2018-07-10 08:15:53.536227638 -0400
+++ /home/bmg/build/glibcs/mips-linux-gnu-nan2008-soft/glibc/libc.symlist	2018-07-12 08:03:53.394265775 -0400
@@ -1963,0 +1964,4 @@ GLIBC_2.28 statx F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F

==> /home/bmg/build/glibcs/mips-linux-gnu-soft/glibc/elf/check-abi-libc.out <==
--- ../sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist	2018-07-10 08:15:53.536227638 -0400
+++ /home/bmg/build/glibcs/mips-linux-gnu-soft/glibc/libc.symlist	2018-07-12 08:04:43.725036830 -0400
@@ -1963,0 +1964,4 @@ GLIBC_2.28 statx F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F

==> /home/bmg/build/glibcs/powerpc-linux-gnu-soft/glibc/elf/check-abi-libc.out <==
--- ../sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist	2018-07-10 08:15:53.537227663 -0400
+++ /home/bmg/build/glibcs/powerpc-linux-gnu-soft/glibc/libc.symlist	2018-07-12 08:07:09.786984849 -0400
@@ -1995,0 +1996,4 @@ GLIBC_2.28 statx F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F

==> /home/bmg/build/glibcs/powerpc-linux-gnuspe-e500v1/glibc/elf/check-abi-libc.out <==
--- ../sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist	2018-07-10 08:15:53.537227663 -0400
+++ /home/bmg/build/glibcs/powerpc-linux-gnuspe-e500v1/glibc/libc.symlist	2018-07-12 08:07:11.875053737 -0400
@@ -1995,0 +1996,4 @@ GLIBC_2.28 statx F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F

==> /home/bmg/build/glibcs/powerpc-linux-gnuspe/glibc/elf/check-abi-libc.out <==
--- ../sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist	2018-07-10 08:15:53.537227663 -0400
+++ /home/bmg/build/glibcs/powerpc-linux-gnuspe/glibc/libc.symlist	2018-07-12 08:07:33.724774593 -0400
@@ -1995,0 +1996,4 @@ GLIBC_2.28 statx F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-02-02 17:04 ` [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions Adhemerval Zanella
  2018-02-08 13:49   ` Gabriel F. T. Gomes
  2018-07-06 12:46   ` Florian Weimer
@ 2018-07-12 16:46   ` Florian Weimer
  2018-07-12 17:52     ` Adhemerval Zanella
  2018-07-13  9:45   ` Florian Weimer
                     ` (2 subsequent siblings)
  5 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-12 16:46 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:

> diff --git a/include/stdc-predef.h b/include/stdc-predef.h
> index c569759..c2ab78a 100644
> --- a/include/stdc-predef.h
> +++ b/include/stdc-predef.h
> @@ -57,7 +57,4 @@
>      - 3 additional Zanabazar Square characters */
>   #define __STDC_ISO_10646__		201706L
>   
> -/* We do not support C11 <threads.h>.  */
> -#define __STDC_NO_THREADS__		1

Should we do this only if we know that the compiler has _Thread_local 
support (based on a GCC and __cplusplus version check)?

> diff --git a/nptl/descr.h b/nptl/descr.h
> index 64ba29e..f00e2c0 100644
> --- a/nptl/descr.h
> +++ b/nptl/descr.h
> @@ -371,6 +371,8 @@ struct pthread
>        to the function.  */
>     void *(*start_routine) (void *);
>     void *arg;
> +  /* Indicates whether is a C11 thread created by thrd_creat.  */
> +  bool c11;
>   
>     /* Debug state.  */
>     td_eventbuf_t eventbuf;

Can you move the new member towards the end of the struct?  I'm worried 
about the ABI implications.

> diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
> index caaf07c..74e773a 100644
> --- a/nptl/pthread_create.c
> +++ b/nptl/pthread_create.c
> @@ -460,7 +460,19 @@ START_THREAD_DEFN
>         LIBC_PROBE (pthread_start, 3, (pthread_t) pd, pd->start_routine, pd->arg);
>   
>         /* Run the code the user provided.  */
> -      THREAD_SETMEM (pd, result, pd->start_routine (pd->arg));
> +      void *ret;
> +      if (pd->c11)
> +	{
> +	  /* The function pointer of the c11 thread start is cast to an incorrect
> +	     type on __pthread_create_2_1 call, however it is casted back to correct
> +	     one so the call behavior is well-defined (it is assumed that pointers
> +	     to void are able to represent all values of int.  */
> +	  int (*start)(void*) = (int (*) (void*)) pd->start_routine;
> +	  ret = (void*) (intptr_t) start (pd->arg);

(I think this required on m68k, where void * and int are returned in 
different registers.)

> +int
> +thrd_join (thrd_t thr, int *res)
> +{
> +  void *pthread_res;
> +  int err_code = __pthread_join (thr, &pthread_res);
> +  if (res)
> +   *res = (int)((uintptr_t) pthread_res);
> +
> +  return thrd_err_map (err_code);
> +}

Slight inconsistency with intptr_t above.

> diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h
> new file mode 100644
> index 0000000..6adcac4
> --- /dev/null
> +++ b/sysdeps/nptl/threads.h

Should this be nptl/threads.h, not sysdeps/nptl/threads.h?

Thanks,
Florian

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

* Re: [PATCH v8 5/8] nptl: Add C11 threads tss_* functions
  2018-02-02 17:04 ` [PATCH v8 5/8] nptl: Add C11 threads tss_* functions Adhemerval Zanella
@ 2018-07-12 16:48   ` Florian Weimer
  2018-07-12 20:32     ` Adhemerval Zanella
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-12 16:48 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
> diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h
> index eb89b0a..6a807ee 100644
> --- a/sysdeps/nptl/threads.h
> +++ b/sysdeps/nptl/threads.h
> @@ -28,6 +28,10 @@ __BEGIN_DECLS
>   #include <bits/types/struct_timespec.h>
>   
>   #define ONCE_FLAG_INIT 0
> +#define thread_local _Thread_local

This needs a __cplusplus conditional.  _Thread_local does not exist in 
C++.  The macro has to be defined to thread_local starting with C++11.

Thanks,
Florian

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-12 12:18           ` Florian Weimer
@ 2018-07-12 17:38             ` Adhemerval Zanella
  2018-07-13  7:03               ` Florian Weimer
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-12 17:38 UTC (permalink / raw)
  To: Florian Weimer, Szabolcs Nagy, libc-alpha; +Cc: nd



On 12/07/2018 09:18, Florian Weimer wrote:
> On 07/11/2018 06:24 PM, Adhemerval Zanella wrote:
>>
>>
>> On 11/07/2018 12:49, Szabolcs Nagy wrote:
>>> On 10/07/18 20:26, Adhemerval Zanella wrote:
>>>>
>>>>
>>>> On 06/07/2018 09:46, Florian Weimer wrote:
>>>>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>>>>> @@ -139,7 +139,9 @@ libpthread-routines = nptl-init vars events version pt-interp \
>>>>>>                   pthread_mutex_getprioceiling \
>>>>>>                   pthread_mutex_setprioceiling \
>>>>>>                   pthread_setname pthread_getname \
>>>>>> -              pthread_setattr_default_np pthread_getattr_default_np
>>>>>> +              pthread_setattr_default_np pthread_getattr_default_np \
>>>>>> +              thrd_create thrd_current thrd_detach thrd_equal \
>>>>>
>>>>> thrd_current should live in libc, not in libpthread.  Same for thrd_equal, I suppose.  You should just duplicate the comparison, seeing that we haven't done that particular cleanup for pthread_equal yet.
>>>>>
>>>>> Not sure about thrd_sleep and thrd_yield, but I lean towards libc there as well.
>>>>
>>>> Right, I added all four symbols (thrd_current, thrd_equal, thrd_sleep, and
>>>> thrd_yield) to libc on my personal branch [1] (the change is just to move
>>>> the objects from libpthread-routines to routines rule in nptl/Makefile).
>>>> I also adjusted the abilist patch with the change.
>>>>
>>>
>>> the abilist patch seems to add
>>> sysdeps/unix/sysv/linux/tile/tilegx64/libpthread.abilist
>>> i think you can drop that (and update the ChangeLog).
>>
>> Thanks for catching this up, I fixed on my personal c11 thread branch.
> 
> I still see the attached ABI diffs.

Thanks, I have corrected them in my personal branch, along with the ChangeLog
entry and a lingering file from tile.

> 
> There is also a new linknamespace failure on hppa:
> 
> [initial] thrd_create -> [libpthread.a(thrd_create.o)] __pthread_create_2_1 -> [libpthread.a(pthread_create.o)] mprotect
> 
> That should be easy to fix.  I'll post a separate patch for that.

You seemed to already fix, thanks.

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-12 16:46   ` Florian Weimer
@ 2018-07-12 17:52     ` Adhemerval Zanella
  2018-07-12 18:24       ` Florian Weimer
  2018-07-12 19:32       ` Adhemerval Zanella
  0 siblings, 2 replies; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-12 17:52 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 12/07/2018 13:46, Florian Weimer wrote:
> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
> 
>> diff --git a/include/stdc-predef.h b/include/stdc-predef.h
>> index c569759..c2ab78a 100644
>> --- a/include/stdc-predef.h
>> +++ b/include/stdc-predef.h
>> @@ -57,7 +57,4 @@
>>      - 3 additional Zanabazar Square characters */
>>   #define __STDC_ISO_10646__        201706L
>>   -/* We do not support C11 <threads.h>.  */
>> -#define __STDC_NO_THREADS__        1
> 
> Should we do this only if we know that the compiler has _Thread_local support (based on a GCC and __cplusplus version check)?

It seems reasonable, since its a installed header.  Do we need to 
check for __cplusplus too? Shouldn't __GNUC_PREREQ (4.9) be suffice?

> 
>> diff --git a/nptl/descr.h b/nptl/descr.h
>> index 64ba29e..f00e2c0 100644
>> --- a/nptl/descr.h
>> +++ b/nptl/descr.h
>> @@ -371,6 +371,8 @@ struct pthread
>>        to the function.  */
>>     void *(*start_routine) (void *);
>>     void *arg;
>> +  /* Indicates whether is a C11 thread created by thrd_creat.  */
>> +  bool c11;
>>       /* Debug state.  */
>>     td_eventbuf_t eventbuf;
> 
> Can you move the new member towards the end of the struct?  I'm worried about the ABI implications.

Right, I will do it.

> 
>> diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
>> index caaf07c..74e773a 100644
>> --- a/nptl/pthread_create.c
>> +++ b/nptl/pthread_create.c
>> @@ -460,7 +460,19 @@ START_THREAD_DEFN
>>         LIBC_PROBE (pthread_start, 3, (pthread_t) pd, pd->start_routine, pd->arg);
>>           /* Run the code the user provided.  */
>> -      THREAD_SETMEM (pd, result, pd->start_routine (pd->arg));
>> +      void *ret;
>> +      if (pd->c11)
>> +    {
>> +      /* The function pointer of the c11 thread start is cast to an incorrect
>> +         type on __pthread_create_2_1 call, however it is casted back to correct
>> +         one so the call behavior is well-defined (it is assumed that pointers
>> +         to void are able to represent all values of int.  */
>> +      int (*start)(void*) = (int (*) (void*)) pd->start_routine;
>> +      ret = (void*) (intptr_t) start (pd->arg);
> 
> (I think this required on m68k, where void * and int are returned in different registers.)
> 
>> +int
>> +thrd_join (thrd_t thr, int *res)
>> +{
>> +  void *pthread_res;
>> +  int err_code = __pthread_join (thr, &pthread_res);
>> +  if (res)
>> +   *res = (int)((uintptr_t) pthread_res);
>> +
>> +  return thrd_err_map (err_code);
>> +}
> 
> Slight inconsistency with intptr_t above.

Indeed, it seems there is no need to cast.

> 
>> diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h
>> new file mode 100644
>> index 0000000..6adcac4
>> --- /dev/null
>> +++ b/sysdeps/nptl/threads.h
> 
> Should this be nptl/threads.h, not sysdeps/nptl/threads.h?

Right, I will move it.

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-12 17:52     ` Adhemerval Zanella
@ 2018-07-12 18:24       ` Florian Weimer
  2018-07-12 19:19         ` Adhemerval Zanella
  2018-07-12 19:32       ` Adhemerval Zanella
  1 sibling, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-12 18:24 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 07/12/2018 07:52 PM, Adhemerval Zanella wrote:
> 
> 
> On 12/07/2018 13:46, Florian Weimer wrote:
>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>
>>> diff --git a/include/stdc-predef.h b/include/stdc-predef.h
>>> index c569759..c2ab78a 100644
>>> --- a/include/stdc-predef.h
>>> +++ b/include/stdc-predef.h
>>> @@ -57,7 +57,4 @@
>>>       - 3 additional Zanabazar Square characters */
>>>    #define __STDC_ISO_10646__        201706L
>>>    -/* We do not support C11 <threads.h>.  */
>>> -#define __STDC_NO_THREADS__        1
>>
>> Should we do this only if we know that the compiler has _Thread_local support (based on a GCC and __cplusplus version check)?
> 
> It seems reasonable, since its a installed header.  Do we need to
> check for __cplusplus too? Shouldn't __GNUC_PREREQ (4.9) be suffice?

I think we can use __thread instead of _Thread_local with even older 
compilers, and also factor in __cplusplus if it is recent enough 
(essentially 2011 and later) for the !__GNUC__ case.

Maybe it's sufficient to say

#if !defined (__GNUC__) && !defined (__cpluscplus) \
   &&  __cplusplus < 201103L)
# define __STDC_NO_THREADS__        1
#endif

On the other hand, maybe your original change is right because in C11, 
_Thread_local support is not optional.  Implementations are required to 
recognize the keyword (and presumably ignore it) even if they define 
__STDC_NO_THREADS__.  And our <threads.h> will generally work fine even 
if the compiler does not actually support _Thread_local.  So I'd say go 
with your original change.

(But I do think you need to do something about thread_local in the C++ 
case, independently of this discussion.)

Thanks,
Florian

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

* Re: [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions
  2018-07-10 12:35     ` Adhemerval Zanella
@ 2018-07-12 18:39       ` Florian Weimer
  2018-07-12 20:30         ` Adhemerval Zanella
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-12 18:39 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 07/10/2018 02:35 PM, Adhemerval Zanella wrote:
> 
> 
> On 06/07/2018 09:51, Florian Weimer wrote:
>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>> This patch adds the mtx_* definitions from C11 threads (ISO/IEC 9899:2011),
>>> more specifically mtx_init, mtx_destroy, mtx_lock, mtx_timedlock, mtx_trylock,
>>> mtx_unlock, and required types.
>>>
>>> Mostly of the definitions are composed based on POSIX conterparts, and mtx_t
>>> is also based on internal pthread fields, but with a distinct internal layout
>>> to avoid possible issues with code interchange (such as trying to pass POSIX
>>> structure on C11 functions and to avoid inclusion of pthread.h).  The idea
>>> is to make possible to share POSIX internal implementations for mostly of
>>> the code (and making adjustment only when required).
>>
>> Should we check for the supported mutex types and error out if the type does not match?  The interface does not support the full range of error codes required by robust mutexes, for example—EOWNERDEAD is missing.
>>
> 
> I am not sure if adding extra tests will yield any gain, specially on mutex
> operations which users would expect optimized fast paths.  I really think
> we should handle as undefined behaviour if uses try to use pthread_t objects
> with c11 threads function (in similar manner it is undefined behaviour if
> uses messes with internal pthread_mutex_t objects data directly).

Some people might be tempted to use the C11 interfaces to avoid the 
(formal) namespace violations of the POSIX functions, but still stick to 
the underlying POSIX objects for type compatibility on other interfaces.

But I think we can clearly document that they shouldn't do this.

I'm concerned about this because in the future, we might compile the 
implementations to remove checks that are not needed for the C11 
implementations.

Thanks,
Florian

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-12 18:24       ` Florian Weimer
@ 2018-07-12 19:19         ` Adhemerval Zanella
  2018-07-12 19:26           ` Florian Weimer
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-12 19:19 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 12/07/2018 15:24, Florian Weimer wrote:
> On 07/12/2018 07:52 PM, Adhemerval Zanella wrote:
>>
>>
>> On 12/07/2018 13:46, Florian Weimer wrote:
>>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>>
>>>> diff --git a/include/stdc-predef.h b/include/stdc-predef.h
>>>> index c569759..c2ab78a 100644
>>>> --- a/include/stdc-predef.h
>>>> +++ b/include/stdc-predef.h
>>>> @@ -57,7 +57,4 @@
>>>>       - 3 additional Zanabazar Square characters */
>>>>    #define __STDC_ISO_10646__        201706L
>>>>    -/* We do not support C11 <threads.h>.  */
>>>> -#define __STDC_NO_THREADS__        1
>>>
>>> Should we do this only if we know that the compiler has _Thread_local support (based on a GCC and __cplusplus version check)?
>>
>> It seems reasonable, since its a installed header.  Do we need to
>> check for __cplusplus too? Shouldn't __GNUC_PREREQ (4.9) be suffice?
> 
> I think we can use __thread instead of _Thread_local with even older compilers, and also factor in __cplusplus if it is recent enough (essentially 2011 and later) for the !__GNUC__ case.
> 
> Maybe it's sufficient to say
> 
> #if !defined (__GNUC__) && !defined (__cpluscplus) \
>   &&  __cplusplus < 201103L)
> # define __STDC_NO_THREADS__        1
> #endif
> 
> On the other hand, maybe your original change is right because in C11, _Thread_local support is not optional.  Implementations are required to recognize the keyword (and presumably ignore it) even if they define __STDC_NO_THREADS__.  And our <threads.h> will generally work fine even if the compiler does not actually support _Thread_local.  So I'd say go with your original change.
> 
> (But I do think you need to do something about thread_local in the C++ case, independently of this discussion.)

Also on GCC BZ#53769 [1] Joseph wrote that check for __STDC_VERSION__
and/or __STDC_NO_THREADS__ is not meaningful to documented incomplete
compiler support for language standard.  This is at least for GCC 
standpoint, not sure about other compilers.

We could add a check like:

#if (defined (__GNUC__) && !__GNUC_PREREQ (4.9))
    || (!defined (__cpluscplus) &&  __cplusplus < 201103L)
#  define __STDC_NO_THREADS__   1
#endif

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53769

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-12 19:19         ` Adhemerval Zanella
@ 2018-07-12 19:26           ` Florian Weimer
  2018-07-12 19:41             ` Adhemerval Zanella
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-12 19:26 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 07/12/2018 09:19 PM, Adhemerval Zanella wrote:
> Also on GCC BZ#53769 [1] Joseph wrote that check for __STDC_VERSION__
> and/or __STDC_NO_THREADS__ is not meaningful to documented incomplete
> compiler support for language standard.  This is at least for GCC
> standpoint, not sure about other compilers.
> 
> We could add a check like:
> 
> #if (defined (__GNUC__) && !__GNUC_PREREQ (4.9))
>      || (!defined (__cpluscplus) &&  __cplusplus < 201103L)
> #  define __STDC_NO_THREADS__   1
> #endif
> 
> [1]https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53769

I think your first patch was fine.  The <threads.h> header exists after 
your change.

We could polish the definition of thread_local in the header file with 
some conditionals, though, so that we fall back to __thread for GCC 
prior to 4.9.  The definition of the thread_local macro will be 
non-confirming, but that's what you get for using a non-conforming 
implementation.

(If the C compiler is not known to be C, we need to use _Thread_local, 
even though __thread probably covers more old implementations out there.)

Thanks,
Florian

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-12 17:52     ` Adhemerval Zanella
  2018-07-12 18:24       ` Florian Weimer
@ 2018-07-12 19:32       ` Adhemerval Zanella
  2018-07-12 19:35         ` Florian Weimer
  1 sibling, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-12 19:32 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 12/07/2018 14:52, Adhemerval Zanella wrote:
> 
> 
> On 12/07/2018 13:46, Florian Weimer wrote:
>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>> +int
>>> +thrd_join (thrd_t thr, int *res)
>>> +{
>>> +  void *pthread_res;
>>> +  int err_code = __pthread_join (thr, &pthread_res);
>>> +  if (res)
>>> +   *res = (int)((uintptr_t) pthread_res);
>>> +
>>> +  return thrd_err_map (err_code);
>>> +}
>>
>> Slight inconsistency with intptr_t above.
> 
> Indeed, it seems there is no need to cast.

In fact the cast this construction is still required, since the pthread_join
returned value might have a different size of the expected c11 thrd_join.

As a slight optimization I changed to 

  int err_code = __pthread_timedjoin_ex (thr, &pthread_res, NULL, true);

(it should avoid calling pthread_join which will in turn call
pthread_timedjoin_ex).

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-12 19:32       ` Adhemerval Zanella
@ 2018-07-12 19:35         ` Florian Weimer
  2018-07-12 19:43           ` Adhemerval Zanella
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-12 19:35 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 07/12/2018 09:32 PM, Adhemerval Zanella wrote:
> 
> 
> On 12/07/2018 14:52, Adhemerval Zanella wrote:
>>
>>
>> On 12/07/2018 13:46, Florian Weimer wrote:
>>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>>> +int
>>>> +thrd_join (thrd_t thr, int *res)
>>>> +{
>>>> +  void *pthread_res;
>>>> +  int err_code = __pthread_join (thr, &pthread_res);
>>>> +  if (res)
>>>> +   *res = (int)((uintptr_t) pthread_res);
>>>> +
>>>> +  return thrd_err_map (err_code);
>>>> +}
>>>
>>> Slight inconsistency with intptr_t above.
>>
>> Indeed, it seems there is no need to cast.
> 
> In fact the cast this construction is still required, since the pthread_join
> returned value might have a different size of the expected c11 thrd_join.

I meant the inconsistency between intptr_t and uintptr_t.

Florian

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-12 19:26           ` Florian Weimer
@ 2018-07-12 19:41             ` Adhemerval Zanella
  0 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-12 19:41 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 12/07/2018 16:26, Florian Weimer wrote:
> On 07/12/2018 09:19 PM, Adhemerval Zanella wrote:
>> Also on GCC BZ#53769 [1] Joseph wrote that check for __STDC_VERSION__
>> and/or __STDC_NO_THREADS__ is not meaningful to documented incomplete
>> compiler support for language standard.  This is at least for GCC
>> standpoint, not sure about other compilers.
>>
>> We could add a check like:
>>
>> #if (defined (__GNUC__) && !__GNUC_PREREQ (4.9))
>>      || (!defined (__cpluscplus) &&  __cplusplus < 201103L)
>> #  define __STDC_NO_THREADS__   1
>> #endif
>>
>> [1]https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53769
> 
> I think your first patch was fine.  The <threads.h> header exists after your change.
> 
> We could polish the definition of thread_local in the header file with some conditionals, though, so that we fall back to __thread for GCC prior to 4.9.  The definition of the thread_local macro will be non-confirming, but that's what you get for using a non-conforming implementation.
> 
> (If the C compiler is not known to be C, we need to use _Thread_local, even though __thread probably covers more old implementations out there.)
> 
> Thanks,
> Florian

Right, I will keep the definition as is then.

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-12 19:35         ` Florian Weimer
@ 2018-07-12 19:43           ` Adhemerval Zanella
  0 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-12 19:43 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 12/07/2018 16:35, Florian Weimer wrote:
> On 07/12/2018 09:32 PM, Adhemerval Zanella wrote:
>>
>>
>> On 12/07/2018 14:52, Adhemerval Zanella wrote:
>>>
>>>
>>> On 12/07/2018 13:46, Florian Weimer wrote:
>>>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>>>> +int
>>>>> +thrd_join (thrd_t thr, int *res)
>>>>> +{
>>>>> +  void *pthread_res;
>>>>> +  int err_code = __pthread_join (thr, &pthread_res);
>>>>> +  if (res)
>>>>> +   *res = (int)((uintptr_t) pthread_res);
>>>>> +
>>>>> +  return thrd_err_map (err_code);
>>>>> +}
>>>>
>>>> Slight inconsistency with intptr_t above.
>>>
>>> Indeed, it seems there is no need to cast.
>>
>> In fact the cast this construction is still required, since the pthread_join
>> returned value might have a different size of the expected c11 thrd_join.
> 
> I meant the inconsistency between intptr_t and uintptr_t.

Ah right, there is no requirement to use a signed cast on pthread_create.
I will change it to uintptr_t.

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

* Re: [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions
  2018-07-12 18:39       ` Florian Weimer
@ 2018-07-12 20:30         ` Adhemerval Zanella
  2018-07-12 20:38           ` Florian Weimer
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-12 20:30 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 12/07/2018 15:39, Florian Weimer wrote:
> On 07/10/2018 02:35 PM, Adhemerval Zanella wrote:
>>
>>
>> On 06/07/2018 09:51, Florian Weimer wrote:
>>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>>> This patch adds the mtx_* definitions from C11 threads (ISO/IEC 9899:2011),
>>>> more specifically mtx_init, mtx_destroy, mtx_lock, mtx_timedlock, mtx_trylock,
>>>> mtx_unlock, and required types.
>>>>
>>>> Mostly of the definitions are composed based on POSIX conterparts, and mtx_t
>>>> is also based on internal pthread fields, but with a distinct internal layout
>>>> to avoid possible issues with code interchange (such as trying to pass POSIX
>>>> structure on C11 functions and to avoid inclusion of pthread.h).  The idea
>>>> is to make possible to share POSIX internal implementations for mostly of
>>>> the code (and making adjustment only when required).
>>>
>>> Should we check for the supported mutex types and error out if the type does not match?  The interface does not support the full range of error codes required by robust mutexes, for example—EOWNERDEAD is missing.
>>>
>>
>> I am not sure if adding extra tests will yield any gain, specially on mutex
>> operations which users would expect optimized fast paths.  I really think
>> we should handle as undefined behaviour if uses try to use pthread_t objects
>> with c11 threads function (in similar manner it is undefined behaviour if
>> uses messes with internal pthread_mutex_t objects data directly).
> 
> Some people might be tempted to use the C11 interfaces to avoid the (formal) namespace violations of the POSIX functions, but still stick to the underlying POSIX objects for type compatibility on other interfaces.
> 
> But I think we can clearly document that they shouldn't do this.

Even if developers try to do this, it will be implementation specific
(in a sense an implementation may provide different underlying types
for POSIX and C11 thread objects). I really think we should explicit
this is a non-supported scenario.

> 
> I'm concerned about this because in the future, we might compile the implementations to remove checks that are not needed for the C11 implementations.

Why kind of scenario do you have in mind? Maybe use a more streamlined
internal implementation for C11 threads?
 

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

* Re: [PATCH v8 5/8] nptl: Add C11 threads tss_* functions
  2018-07-12 16:48   ` Florian Weimer
@ 2018-07-12 20:32     ` Adhemerval Zanella
  2018-07-12 20:37       ` Florian Weimer
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-12 20:32 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 12/07/2018 13:48, Florian Weimer wrote:
> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>> diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h
>> index eb89b0a..6a807ee 100644
>> --- a/sysdeps/nptl/threads.h
>> +++ b/sysdeps/nptl/threads.h
>> @@ -28,6 +28,10 @@ __BEGIN_DECLS
>>   #include <bits/types/struct_timespec.h>
>>     #define ONCE_FLAG_INIT 0
>> +#define thread_local _Thread_local
> 
> This needs a __cplusplus conditional.  _Thread_local does not exist in C++.  The macro has to be defined to thread_local starting with C++11.

I think we can just not define it for C++, not really checking which
version is being used.

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

* Re: [PATCH v8 5/8] nptl: Add C11 threads tss_* functions
  2018-07-12 20:32     ` Adhemerval Zanella
@ 2018-07-12 20:37       ` Florian Weimer
  0 siblings, 0 replies; 80+ messages in thread
From: Florian Weimer @ 2018-07-12 20:37 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 07/12/2018 10:32 PM, Adhemerval Zanella wrote:
>> This needs a __cplusplus conditional.  _Thread_local does not exist in C++.  The macro has to be defined to thread_local starting with C++11.

> I think we can just not define it for C++, not really checking which
> version is being used.

Sounds fine to me.

Thanks,
Florian

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

* Re: [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions
  2018-07-12 20:30         ` Adhemerval Zanella
@ 2018-07-12 20:38           ` Florian Weimer
  2018-07-13 13:08             ` Adhemerval Zanella
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-12 20:38 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 07/12/2018 10:30 PM, Adhemerval Zanella wrote:

>> I'm concerned about this because in the future, we might compile the implementations to remove checks that are not needed for the C11 implementations.
> 
> Why kind of scenario do you have in mind? Maybe use a more streamlined
> internal implementation for C11 threads?

Yes, the polymorphic mutex types must have *some* overhead (think of 
speculatively executing the wrong atomics), and less polymorphism should 
improve performance.

Thanks,
Florian

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-12 17:38             ` Adhemerval Zanella
@ 2018-07-13  7:03               ` Florian Weimer
  0 siblings, 0 replies; 80+ messages in thread
From: Florian Weimer @ 2018-07-13  7:03 UTC (permalink / raw)
  To: Adhemerval Zanella, Szabolcs Nagy, libc-alpha; +Cc: nd

On 07/12/2018 07:38 PM, Adhemerval Zanella wrote:
> 
> 
> On 12/07/2018 09:18, Florian Weimer wrote:
>> On 07/11/2018 06:24 PM, Adhemerval Zanella wrote:
>>>
>>>
>>> On 11/07/2018 12:49, Szabolcs Nagy wrote:
>>>> On 10/07/18 20:26, Adhemerval Zanella wrote:
>>>>>
>>>>>
>>>>> On 06/07/2018 09:46, Florian Weimer wrote:
>>>>>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>>>>>> @@ -139,7 +139,9 @@ libpthread-routines = nptl-init vars events version pt-interp \
>>>>>>>                    pthread_mutex_getprioceiling \
>>>>>>>                    pthread_mutex_setprioceiling \
>>>>>>>                    pthread_setname pthread_getname \
>>>>>>> -              pthread_setattr_default_np pthread_getattr_default_np
>>>>>>> +              pthread_setattr_default_np pthread_getattr_default_np \
>>>>>>> +              thrd_create thrd_current thrd_detach thrd_equal \
>>>>>>
>>>>>> thrd_current should live in libc, not in libpthread.  Same for thrd_equal, I suppose.  You should just duplicate the comparison, seeing that we haven't done that particular cleanup for pthread_equal yet.
>>>>>>
>>>>>> Not sure about thrd_sleep and thrd_yield, but I lean towards libc there as well.
>>>>>
>>>>> Right, I added all four symbols (thrd_current, thrd_equal, thrd_sleep, and
>>>>> thrd_yield) to libc on my personal branch [1] (the change is just to move
>>>>> the objects from libpthread-routines to routines rule in nptl/Makefile).
>>>>> I also adjusted the abilist patch with the change.
>>>>>
>>>>
>>>> the abilist patch seems to add
>>>> sysdeps/unix/sysv/linux/tile/tilegx64/libpthread.abilist
>>>> i think you can drop that (and update the ChangeLog).
>>>
>>> Thanks for catching this up, I fixed on my personal c11 thread branch.
>>
>> I still see the attached ABI diffs.
> 
> Thanks, I have corrected them in my personal branch, along with the ChangeLog
> entry and a lingering file from tile.

As of commit 2b9d7c41ade511d99cd917bb8d28eb0fe91971ed, I still see:

==> 
/home/bmg/build/glibcs/mipsel-linux-gnu-nan2008-soft/glibc/elf/check-abi-libc.out 
<==
--- ../sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist 
2018-07-10 08:15:53.536227638 -0400
+++ 
/home/bmg/build/glibcs/mipsel-linux-gnu-nan2008-soft/glibc/libc.symlist 
    2018-07-13 03:00:06.345221784 -0400
@@ -1963,0 +1964,4 @@ GLIBC_2.28 statx F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F

==> 
/home/bmg/build/glibcs/mipsel-linux-gnu-soft/glibc/elf/check-abi-libc.out 
<==
--- ../sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist 
2018-07-10 08:15:53.536227638 -0400
+++ /home/bmg/build/glibcs/mipsel-linux-gnu-soft/glibc/libc.symlist 
2018-07-13 02:58:41.692589329 -0400
@@ -1963,0 +1964,4 @@ GLIBC_2.28 statx F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F

==> 
/home/bmg/build/glibcs/mips-linux-gnu-nan2008-soft/glibc/elf/check-abi-libc.out 
<==
--- ../sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist 
2018-07-10 08:15:53.536227638 -0400
+++ 
/home/bmg/build/glibcs/mips-linux-gnu-nan2008-soft/glibc/libc.symlist 
    2018-07-13 03:00:43.831389053 -0400
@@ -1963,0 +1964,4 @@ GLIBC_2.28 statx F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F

==> 
/home/bmg/build/glibcs/mips-linux-gnu-soft/glibc/elf/check-abi-libc.out <==
--- ../sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist 
2018-07-10 08:15:53.536227638 -0400
+++ /home/bmg/build/glibcs/mips-linux-gnu-soft/glibc/libc.symlist 
2018-07-13 03:00:32.210027180 -0400
@@ -1963,0 +1964,4 @@ GLIBC_2.28 statx F
+GLIBC_2.28 thrd_current F
+GLIBC_2.28 thrd_equal F
+GLIBC_2.28 thrd_sleep F
+GLIBC_2.28 thrd_yield F

Florian

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

* Re: [PATCH v8 7/8] nptl: Add test cases for ISO C11 threads
  2018-02-02 17:04 ` [PATCH v8 7/8] nptl: Add test cases for ISO " Adhemerval Zanella
@ 2018-07-13  9:31   ` Florian Weimer
  2018-07-13 13:10     ` Adhemerval Zanella
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-13  9:31 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
> This patch adds to testsuite new test cases to test all new introduced
> C11 threads functions, types and macros are tested.

Somewhere, there should be a test that the types (thrd_t, once_flag, 
mtx_t, cnd_t) have identicial size and alignment as the POSIX types, and 
that TSS_DTOR_ITERATIONS equals PTHREAD_DESTRUCTOR_ITERATIONS.

It should probably be a separate test, to avoid including <pthread.h> in 
the <threads.h> tests.

Thanks,
Florian

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

* Re: [PATCH v8 3/8] nptl: Add C11 threads call_once functions
  2018-02-02 17:04 ` [PATCH v8 3/8] nptl: Add C11 threads call_once functions Adhemerval Zanella
@ 2018-07-13  9:32   ` Florian Weimer
  0 siblings, 0 replies; 80+ messages in thread
From: Florian Weimer @ 2018-07-13  9:32 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
> +#define ONCE_FLAG_INIT 0
> +
>   typedef unsigned long int thrd_t;
>   typedef int (*thrd_start_t) (void*);
> +typedef int __ONCE_ALIGNMENT once_flag;

__ONCE_ALIGNMENT is not expressible in C11, so I think you should turn 
once_flag into a struct with a suitably aligned member, and change 
ONCE_FLAG_INIT as well (into a compound literal).

Thanks,
Florian

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-02-02 17:04 ` [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions Adhemerval Zanella
                     ` (2 preceding siblings ...)
  2018-07-12 16:46   ` Florian Weimer
@ 2018-07-13  9:45   ` Florian Weimer
  2018-07-13 12:59     ` Adhemerval Zanella
  2018-07-13  9:48   ` Florian Weimer
  2018-07-25  7:20   ` Andreas Schwab
  5 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-13  9:45 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>    2. thrd_sleep uses nanosleep internal direct syscall to avoid clobbering
>       errno, to handle expected standard return codes, and to avoid making
>       the call a POSIX cancellation entrypoint.

Isn't this inconsistent with the conditional variable wait and thread 
join functions, which are still cancellation points?

On the other hand, a sleep function which is not a cancellation point 
may be useful.

Thanks,
Florian

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-02-02 17:04 ` [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions Adhemerval Zanella
                     ` (3 preceding siblings ...)
  2018-07-13  9:45   ` Florian Weimer
@ 2018-07-13  9:48   ` Florian Weimer
  2018-07-25  7:20   ` Andreas Schwab
  5 siblings, 0 replies; 80+ messages in thread
From: Florian Weimer @ 2018-07-13  9:48 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
> +/* Exit and error codes.  */
> +enum
> +{
> +  thrd_success  = 0,
> +  thrd_busy     = 1,
> +  thrd_error    = 2,
> +  thrd_nomem    = 3,
> +  thrd_timedout = 4
> +};

We could make the mapping more efficient if we used EBUSY, EINVAL, 
ENOMEM, ETIMEDOUT for the error codes, possibly with the help of a .sym 
file.  I expect that this would allow us to eliminate some of the 
wrappers and use symbol aliases instead, but it doesn't look like there 
would be many such cases.  Your call.

Thanks,
Florian

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

* Re: [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads
  2018-02-02 17:04 ` [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads Adhemerval Zanella
@ 2018-07-13  9:50   ` Florian Weimer
  2018-07-13 15:49     ` Adhemerval Zanella
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-13  9:50 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
> This patch adds the required abilist symbols for C11 thread support.

I manually compared the definitions in the <threads.h> header with the 
C11 standard.  The ABI looks good, with the exception of the once_flag 
definition and the possible change of the error encoding.

Thanks,
Florian

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-13  9:45   ` Florian Weimer
@ 2018-07-13 12:59     ` Adhemerval Zanella
  2018-07-13 13:04       ` Florian Weimer
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-13 12:59 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 13/07/2018 06:45, Florian Weimer wrote:
> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>    2. thrd_sleep uses nanosleep internal direct syscall to avoid clobbering
>>       errno, to handle expected standard return codes, and to avoid making
>>       the call a POSIX cancellation entrypoint.
> 
> Isn't this inconsistent with the conditional variable wait and thread join functions, which are still cancellation points?
> 
> On the other hand, a sleep function which is not a cancellation point may be useful.

I am not sure which would be the best option to handle POSIX cancellation
with C11 threads with nptl implementation. Most straightforward option is
just use cancellation entrypoints as default, even though using thread
cancellation in C11 is UB (there is no defined way the use can get the
POSIX thread id from a C11 thread). This don't require much internal
code change

Another option is just disable cancellation by using non-cancellable
entry-points and/or explicit disable cancellation.  For thrd_join is
just a matter to set on '__pthread_timedjoin_ex', but for 
cnd_wait/cnd_timedwait we either need to explicit enable/disable or 
add an option to __pthread_cond_wait_common to select whether to use
cancellable syscalls.

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-13 12:59     ` Adhemerval Zanella
@ 2018-07-13 13:04       ` Florian Weimer
  2018-07-13 13:18         ` Adhemerval Zanella
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-13 13:04 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 07/13/2018 02:59 PM, Adhemerval Zanella wrote:
> 
> 
> On 13/07/2018 06:45, Florian Weimer wrote:
>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>>     2. thrd_sleep uses nanosleep internal direct syscall to avoid clobbering
>>>        errno, to handle expected standard return codes, and to avoid making
>>>        the call a POSIX cancellation entrypoint.
>>
>> Isn't this inconsistent with the conditional variable wait and thread join functions, which are still cancellation points?
>>
>> On the other hand, a sleep function which is not a cancellation point may be useful.
> 
> I am not sure which would be the best option to handle POSIX cancellation
> with C11 threads with nptl implementation. Most straightforward option is
> just use cancellation entrypoints as default, even though using thread
> cancellation in C11 is UB (there is no defined way the use can get the
> POSIX thread id from a C11 thread).

That's not true.  The POSIX thread ID is available using pthread_self on 
the thread itself, and that can be passed to another thread.

> Another option is just disable cancellation by using non-cancellable
> entry-points and/or explicit disable cancellation.  For thrd_join is
> just a matter to set on '__pthread_timedjoin_ex', but for
> cnd_wait/cnd_timedwait we either need to explicit enable/disable or
> add an option to __pthread_cond_wait_common to select whether to use
> cancellable syscalls.

 From my point of view, the least surprising approach would be to make 
thrd_sleep a cancellation point to match nanosleep.

Thanks,
Florian

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

* Re: [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions
  2018-07-12 20:38           ` Florian Weimer
@ 2018-07-13 13:08             ` Adhemerval Zanella
  2018-07-13 13:10               ` Florian Weimer
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-13 13:08 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 12/07/2018 17:38, Florian Weimer wrote:
> On 07/12/2018 10:30 PM, Adhemerval Zanella wrote:
> 
>>> I'm concerned about this because in the future, we might compile the implementations to remove checks that are not needed for the C11 implementations.
>>
>> Why kind of scenario do you have in mind? Maybe use a more streamlined
>> internal implementation for C11 threads?
> 
> Yes, the polymorphic mutex types must have *some* overhead (think of speculatively executing the wrong atomics), and less polymorphism should improve performance.

I think it would quite feasible in next releases to refactor the mutex 
code into C11 required operation and POSIX one and optimize C11 
implementation with a simpler internal one. The bulk of the work is
disentangle the mutex code (I started to check on this sometime ago,
but got sidetracked).

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

* Re: [PATCH v8 7/8] nptl: Add test cases for ISO C11 threads
  2018-07-13  9:31   ` Florian Weimer
@ 2018-07-13 13:10     ` Adhemerval Zanella
  2018-07-13 13:11       ` Florian Weimer
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-13 13:10 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 13/07/2018 06:31, Florian Weimer wrote:
> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>> This patch adds to testsuite new test cases to test all new introduced
>> C11 threads functions, types and macros are tested.
> 
> Somewhere, there should be a test that the types (thrd_t, once_flag, mtx_t, cnd_t) have identicial size and alignment as the POSIX types, and that TSS_DTOR_ITERATIONS equals PTHREAD_DESTRUCTOR_ITERATIONS.
> 
> It should probably be a separate test, to avoid including <pthread.h> in the <threads.h> tests.

Right, I will work on a extra test for this.

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

* Re: [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions
  2018-07-13 13:08             ` Adhemerval Zanella
@ 2018-07-13 13:10               ` Florian Weimer
  0 siblings, 0 replies; 80+ messages in thread
From: Florian Weimer @ 2018-07-13 13:10 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 07/13/2018 03:08 PM, Adhemerval Zanella wrote:
> 
> 
> On 12/07/2018 17:38, Florian Weimer wrote:
>> On 07/12/2018 10:30 PM, Adhemerval Zanella wrote:
>>
>>>> I'm concerned about this because in the future, we might compile the implementations to remove checks that are not needed for the C11 implementations.
>>>
>>> Why kind of scenario do you have in mind? Maybe use a more streamlined
>>> internal implementation for C11 threads?
>>
>> Yes, the polymorphic mutex types must have *some* overhead (think of speculatively executing the wrong atomics), and less polymorphism should improve performance.
> 
> I think it would quite feasible in next releases to refactor the mutex
> code into C11 required operation and POSIX one and optimize C11
> implementation with a simpler internal one. The bulk of the work is
> disentangle the mutex code (I started to check on this sometime ago,
> but got sidetracked).

Sure, we can delay this work somewhat, but I'd like to backport the 
optimization into 2.28 once we have it, to discourage such invalid uses.

Thanks,
Florian

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

* Re: [PATCH v8 7/8] nptl: Add test cases for ISO C11 threads
  2018-07-13 13:10     ` Adhemerval Zanella
@ 2018-07-13 13:11       ` Florian Weimer
  2018-07-13 13:29         ` Adhemerval Zanella
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-13 13:11 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 07/13/2018 03:10 PM, Adhemerval Zanella wrote:
> 
> 
> On 13/07/2018 06:31, Florian Weimer wrote:
>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>> This patch adds to testsuite new test cases to test all new introduced
>>> C11 threads functions, types and macros are tested.
>>
>> Somewhere, there should be a test that the types (thrd_t, once_flag, mtx_t, cnd_t) have identicial size and alignment as the POSIX types, and that TSS_DTOR_ITERATIONS equals PTHREAD_DESTRUCTOR_ITERATIONS.
>>
>> It should probably be a separate test, to avoid including <pthread.h> in the <threads.h> tests.
> 
> Right, I will work on a extra test for this.

I've since realized that these asserts are in the implementation, which 
is a bit questionable, but better than nothing.  I guess you can add the 
assert for TSS_DTOR_ITERATIONS into the implementation itself.

Thanks,
Florian

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-13 13:04       ` Florian Weimer
@ 2018-07-13 13:18         ` Adhemerval Zanella
  2018-07-13 13:21           ` Florian Weimer
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-13 13:18 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 13/07/2018 10:04, Florian Weimer wrote:
> On 07/13/2018 02:59 PM, Adhemerval Zanella wrote:
>>
>>
>> On 13/07/2018 06:45, Florian Weimer wrote:
>>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>>>     2. thrd_sleep uses nanosleep internal direct syscall to avoid clobbering
>>>>        errno, to handle expected standard return codes, and to avoid making
>>>>        the call a POSIX cancellation entrypoint.
>>>
>>> Isn't this inconsistent with the conditional variable wait and thread join functions, which are still cancellation points?
>>>
>>> On the other hand, a sleep function which is not a cancellation point may be useful.
>>
>> I am not sure which would be the best option to handle POSIX cancellation
>> with C11 threads with nptl implementation. Most straightforward option is
>> just use cancellation entrypoints as default, even though using thread
>> cancellation in C11 is UB (there is no defined way the use can get the
>> POSIX thread id from a C11 thread).
> 
> That's not true.  The POSIX thread ID is available using pthread_self on the thread itself, and that can be passed to another thread.

That is what I am not sure, if mixing POSIX semantic with C11 is really
defined by any standard (for instance, calling pthread_cancel with an
POSIX thread ID which was not created by pthread_create).

> 
>> Another option is just disable cancellation by using non-cancellable
>> entry-points and/or explicit disable cancellation.  For thrd_join is
>> just a matter to set on '__pthread_timedjoin_ex', but for
>> cnd_wait/cnd_timedwait we either need to explicit enable/disable or
>> add an option to __pthread_cond_wait_common to select whether to use
>> cancellable syscalls.
> 
> From my point of view, the least surprising approach would be to make thrd_sleep a cancellation point to match nanosleep.

Right, I will change thrd_sleep to use a cancellation entrypoint. We
can evaluate the POSIX cancellation interaction with C11 threads in
next releases.

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-13 13:18         ` Adhemerval Zanella
@ 2018-07-13 13:21           ` Florian Weimer
  0 siblings, 0 replies; 80+ messages in thread
From: Florian Weimer @ 2018-07-13 13:21 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 07/13/2018 03:18 PM, Adhemerval Zanella wrote:
> Right, I will change thrd_sleep to use a cancellation entrypoint. We
> can evaluate the POSIX cancellation interaction with C11 threads in
> next releases.

Agreed.  We've discussed internally a POSIX thread attribute which 
inhibits cancellation for thread in case it is created by a higher-level 
run-time which does not support cancellation.  I'm not sure if this 
should apply to C11 threads, but we should consider it as an enhancement 
for POSIX threads at least.

Thanks,
Florian

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

* Re: [PATCH v8 7/8] nptl: Add test cases for ISO C11 threads
  2018-07-13 13:11       ` Florian Weimer
@ 2018-07-13 13:29         ` Adhemerval Zanella
  2018-07-17 13:53           ` Adhemerval Zanella
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-13 13:29 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 13/07/2018 10:11, Florian Weimer wrote:
> On 07/13/2018 03:10 PM, Adhemerval Zanella wrote:
>>
>>
>> On 13/07/2018 06:31, Florian Weimer wrote:
>>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>>> This patch adds to testsuite new test cases to test all new introduced
>>>> C11 threads functions, types and macros are tested.
>>>
>>> Somewhere, there should be a test that the types (thrd_t, once_flag, mtx_t, cnd_t) have identicial size and alignment as the POSIX types, and that TSS_DTOR_ITERATIONS equals PTHREAD_DESTRUCTOR_ITERATIONS.
>>>
>>> It should probably be a separate test, to avoid including <pthread.h> in the <threads.h> tests.
>>
>> Right, I will work on a extra test for this.
> 
> I've since realized that these asserts are in the implementation, which is a bit questionable, but better than nothing.  I guess you can add the assert for TSS_DTOR_ITERATIONS into the implementation itself.

The asserts are more for implementation consistency, if we eventually
change internal implementation so POSIX and C11 either shared a common
or distinct implementation we can change the test to check for ABI
expected values instead.

Ok, I also think an assert TSS_DTOR_ITERATIONS should simplify things.

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

* Re: [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads
  2018-07-13  9:50   ` Florian Weimer
@ 2018-07-13 15:49     ` Adhemerval Zanella
  2018-07-13 17:49       ` Florian Weimer
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-13 15:49 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 13/07/2018 06:50, Florian Weimer wrote:
> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>> This patch adds the required abilist symbols for C11 thread support.
> 
> I manually compared the definitions in the <threads.h> header with the C11 standard.  The ABI looks good, with the exception of the once_flag definition and the possible change of the error encoding.
> 
> Thanks,
> Florian

Thanks for all the reviews, I have updated my personal branch [1] with
all you required changes:

  - ABI fixes for mips-gnu-linux-soft.
  - pthread_create / pthread_join cast inconsistency.
  - sysdeps/nptl/threads.h moved to nptl/threads.h.
  - thrd_sleep is now a cancellable entrypoint.
  - once_flag and ONCE_FLAG_INIT and __ONCE_ALIGNMENT definition.
  - thread_local guards for C++.
  - TSS_DTOR_ITERATIONS assert check.

I am not sure about the thread error code mapping to errno, it will
required tying POSIX error code to C11 use some internal mechanism
It will most like require generate a platform-specific file 
auto-generated from errno definitions (more build complexity), and
I am not sure if this micro-optimization will really yields any
measurable gain.

If you prefer I can resend the patches on maillist with a different
version tag (I did not sent to avoid clobber the mailist).

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

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

* Re: [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads
  2018-07-13 15:49     ` Adhemerval Zanella
@ 2018-07-13 17:49       ` Florian Weimer
  2018-07-13 18:47         ` Adhemerval Zanella
  2018-07-18 17:40         ` Joseph Myers
  0 siblings, 2 replies; 80+ messages in thread
From: Florian Weimer @ 2018-07-13 17:49 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 07/13/2018 05:49 PM, Adhemerval Zanella wrote:

> Thanks for all the reviews, I have updated my personal branch [1] with
> all you required changes:

Thank you for your patience.  This is looking really good now.

>    - ABI fixes for mips-gnu-linux-soft.

I can confirm that these are fixed.

>    - pthread_create / pthread_join cast inconsistency.
>    - sysdeps/nptl/threads.h moved to nptl/threads.h.
>    - thrd_sleep is now a cancellable entrypoint.
>    - once_flag and ONCE_FLAG_INIT and __ONCE_ALIGNMENT definition.

Should the type be a struct?

I think ONCE_FLAG_INIT needs to be a compound literal, not an 
initializer, at least that's how I read the standard (“which expands to 
a value that can be used to initialize an object”).

>    - thread_local guards for C++.

Missing indentation of the #define.  The manual could mention that for 
C++, C++11 or later needs to be used to get the thread_local keyword 
(not the macro).

>    - TSS_DTOR_ITERATIONS assert check.
> 
> I am not sure about the thread error code mapping to errno, it will
> required tying POSIX error code to C11 use some internal mechanism
> It will most like require generate a platform-specific file
> auto-generated from errno definitions (more build complexity), and
> I am not sure if this micro-optimization will really yields any
> measurable gain.

I'm fine with leaving it as is.

Thanks,
Florian

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

* Re: [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads
  2018-07-13 17:49       ` Florian Weimer
@ 2018-07-13 18:47         ` Adhemerval Zanella
  2018-07-13 19:56           ` Florian Weimer
  2018-07-18 17:40         ` Joseph Myers
  1 sibling, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-13 18:47 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 13/07/2018 14:49, Florian Weimer wrote:
> On 07/13/2018 05:49 PM, Adhemerval Zanella wrote:
> 
>> Thanks for all the reviews, I have updated my personal branch [1] with
>> all you required changes:
> 
> Thank you for your patience.  This is looking really good now.
> 
>>    - ABI fixes for mips-gnu-linux-soft.
> 
> I can confirm that these are fixed.
> 
>>    - pthread_create / pthread_join cast inconsistency.
>>    - sysdeps/nptl/threads.h moved to nptl/threads.h.
>>    - thrd_sleep is now a cancellable entrypoint.
>>    - once_flag and ONCE_FLAG_INIT and __ONCE_ALIGNMENT definition.
> 
> Should the type be a struct?
> 
> I think ONCE_FLAG_INIT needs to be a compound literal, not an initializer, at least that's how I read the standard (“which expands to a value that can be used to initialize an object”).

Right, you are correct, this will prevent ONCE_FLAG_INIT to be wrongly 
used to initialize other objects than once_flag.  I adjust to be a 
struct as well.

> 
>>    - thread_local guards for C++.
> 
> Missing indentation of the #define.  The manual could mention that for C++, C++11 or later needs to be used to get the thread_local keyword (not the macro).

Ack and I added a note on manual about C++11 requirement.

> 
>>    - TSS_DTOR_ITERATIONS assert check.
>>
>> I am not sure about the thread error code mapping to errno, it will
>> required tying POSIX error code to C11 use some internal mechanism
>> It will most like require generate a platform-specific file
>> auto-generated from errno definitions (more build complexity), and
>> I am not sure if this micro-optimization will really yields any
>> measurable gain.
> 
> I'm fine with leaving it as is.

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

* Re: [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads
  2018-07-13 18:47         ` Adhemerval Zanella
@ 2018-07-13 19:56           ` Florian Weimer
  2018-07-13 21:09             ` Adhemerval Zanella
  0 siblings, 1 reply; 80+ messages in thread
From: Florian Weimer @ 2018-07-13 19:56 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Florian Weimer, libc-alpha

* Adhemerval Zanella:

>> I think ONCE_FLAG_INIT needs to be a compound literal, not an
>> initializer, at least that's how I read the standard (“which expands
>> to a value that can be used to initialize an object”).
>
> Right, you are correct, this will prevent ONCE_FLAG_INIT to be wrongly 
> used to initialize other objects than once_flag.  I adjust to be a 
> struct as well.

Sorry, I forgot that this needs another __cplusplus conditional.

Something like this:

#ifdef __cplusplus
# define ONCE_FLAG_INIT (once_flag {})
#else
# define ONCE_FLAG_INIT (once_flag) { 0 }
#endif

Compound literals in C++ are a GCC extension.

>>>    - thread_local guards for C++.
>> 
>> Missing indentation of the #define.  The manual could mention that
>> for C++, C++11 or later needs to be used to get the thread_local
>> keyword (not the macro).
>
> Ack and I added a note on manual about C++11 requirement.

Thanks.

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

* Re: [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads
  2018-07-13 19:56           ` Florian Weimer
@ 2018-07-13 21:09             ` Adhemerval Zanella
  2018-07-14 13:50               ` Florian Weimer
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-13 21:09 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Florian Weimer, libc-alpha



On 13/07/2018 16:56, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>>> I think ONCE_FLAG_INIT needs to be a compound literal, not an
>>> initializer, at least that's how I read the standard (“which expands
>>> to a value that can be used to initialize an object”).
>>
>> Right, you are correct, this will prevent ONCE_FLAG_INIT to be wrongly 
>> used to initialize other objects than once_flag.  I adjust to be a 
>> struct as well.
> 
> Sorry, I forgot that this needs another __cplusplus conditional.
> 
> Something like this:
> 
> #ifdef __cplusplus
> # define ONCE_FLAG_INIT (once_flag {})
> #else
> # define ONCE_FLAG_INIT (once_flag) { 0 }
> #endif
> 
> Compound literals in C++ are a GCC extension.

Fixed.

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

* Re: [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads
  2018-07-13 21:09             ` Adhemerval Zanella
@ 2018-07-14 13:50               ` Florian Weimer
  0 siblings, 0 replies; 80+ messages in thread
From: Florian Weimer @ 2018-07-14 13:50 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> On 13/07/2018 16:56, Florian Weimer wrote:
>> * Adhemerval Zanella:
>> 
>>>> I think ONCE_FLAG_INIT needs to be a compound literal, not an
>>>> initializer, at least that's how I read the standard (“which expands
>>>> to a value that can be used to initialize an object”).
>>>
>>> Right, you are correct, this will prevent ONCE_FLAG_INIT to be wrongly 
>>> used to initialize other objects than once_flag.  I adjust to be a 
>>> struct as well.
>> 
>> Sorry, I forgot that this needs another __cplusplus conditional.
>> 
>> Something like this:
>> 
>> #ifdef __cplusplus
>> # define ONCE_FLAG_INIT (once_flag {})
>> #else
>> # define ONCE_FLAG_INIT (once_flag) { 0 }
>> #endif
>> 
>> Compound literals in C++ are a GCC extension.
>
> Fixed.

This looks fine to me now.

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

* Re: [PATCH v8 7/8] nptl: Add test cases for ISO C11 threads
  2018-07-13 13:29         ` Adhemerval Zanella
@ 2018-07-17 13:53           ` Adhemerval Zanella
  0 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-17 13:53 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 13/07/2018 10:29, Adhemerval Zanella wrote:
> 
> 
> On 13/07/2018 10:11, Florian Weimer wrote:
>> On 07/13/2018 03:10 PM, Adhemerval Zanella wrote:
>>>
>>>
>>> On 13/07/2018 06:31, Florian Weimer wrote:
>>>> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
>>>>> This patch adds to testsuite new test cases to test all new introduced
>>>>> C11 threads functions, types and macros are tested.
>>>>
>>>> Somewhere, there should be a test that the types (thrd_t, once_flag, mtx_t, cnd_t) have identicial size and alignment as the POSIX types, and that TSS_DTOR_ITERATIONS equals PTHREAD_DESTRUCTOR_ITERATIONS.
>>>>
>>>> It should probably be a separate test, to avoid including <pthread.h> in the <threads.h> tests.
>>>
>>> Right, I will work on a extra test for this.
>>
>> I've since realized that these asserts are in the implementation, which is a bit questionable, but better than nothing.  I guess you can add the assert for TSS_DTOR_ITERATIONS into the implementation itself.
> 
> The asserts are more for implementation consistency, if we eventually
> change internal implementation so POSIX and C11 either shared a common
> or distinct implementation we can change the test to check for ABI
> expected values instead.
> 
> Ok, I also think an assert TSS_DTOR_ITERATIONS should simplify things.
> 

I added a static assert to check TSS_DTOR_ITERATIONS is equal to 
PTHREAD_DESTRUCTOR_ITERATIONS.

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

* Re: [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads
  2018-07-13 17:49       ` Florian Weimer
  2018-07-13 18:47         ` Adhemerval Zanella
@ 2018-07-18 17:40         ` Joseph Myers
  2018-07-18 20:02           ` Adhemerval Zanella
  2018-07-18 21:19           ` Florian Weimer
  1 sibling, 2 replies; 80+ messages in thread
From: Joseph Myers @ 2018-07-18 17:40 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Adhemerval Zanella, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 533 bytes --]

On Fri, 13 Jul 2018, Florian Weimer wrote:

> I think ONCE_FLAG_INIT needs to be a compound literal, not an initializer, at
> least that's how I read the standard (“which expands to a value that can be
> used to initialize an object”).

I think it has to be valid as a static initializer.  Which means it can't 
be a compound literal, because standard C doesn't allow those in static 
initializers.  (I read "value" as meaning "expansion of the macro" not 
"value of an object type".)

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads
  2018-07-18 17:40         ` Joseph Myers
@ 2018-07-18 20:02           ` Adhemerval Zanella
  2018-07-18 21:19           ` Florian Weimer
  1 sibling, 0 replies; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-18 20:02 UTC (permalink / raw)
  To: Joseph Myers, Florian Weimer; +Cc: libc-alpha



On 18/07/2018 14:40, Joseph Myers wrote:
> On Fri, 13 Jul 2018, Florian Weimer wrote:
> 
>> I think ONCE_FLAG_INIT needs to be a compound literal, not an initializer, at
>> least that's how I read the standard (“which expands to a value that can be
>> used to initialize an object”).
> 
> I think it has to be valid as a static initializer.  Which means it can't 
> be a compound literal, because standard C doesn't allow those in static 
> initializers.  (I read "value" as meaning "expansion of the macro" not 
> "value of an object type".)
> 

Right, we should not enforce the compiler to support compound literal
as a static initializer as GCC does as an extension.  I will change 
back to static initializer.

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

* Re: [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads
  2018-07-18 17:40         ` Joseph Myers
  2018-07-18 20:02           ` Adhemerval Zanella
@ 2018-07-18 21:19           ` Florian Weimer
  1 sibling, 0 replies; 80+ messages in thread
From: Florian Weimer @ 2018-07-18 21:19 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Adhemerval Zanella, libc-alpha

* Joseph Myers:

> On Fri, 13 Jul 2018, Florian Weimer wrote:
>
>> I think ONCE_FLAG_INIT needs to be a compound literal, not an initializer, at
>> least that's how I read the standard (“which expands to a value that can be
>> used to initialize an object”).
>
> I think it has to be valid as a static initializer.  Which means it can't 
> be a compound literal, because standard C doesn't allow those in static 
> initializers.  (I read "value" as meaning "expansion of the macro" not 
> "value of an object type".)

Indeed, the standard uses “value” for macro expansion results in other
contexts.  Sorry for the misdirection.

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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h
  2018-06-27 13:39 ` [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
@ 2018-07-19 17:46   ` Adhemerval Zanella
  2018-07-19 18:43     ` Carlos O'Donell
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-19 17:46 UTC (permalink / raw)
  To: libc-alpha; +Cc: Carlos O'Donell, Florian Weimer

Florian, 

First thanks for the thoroughly review for c11 threads so far. I think it
has covered most the upcoming rough pieces.

Carlos, do you think we can squeeze this for 2.28? As you put private, I
also don't think we will get a 'pristine' implementation with optimal
object sizes without a refactor of internal nptl implementation.

On 27/06/2018 10:39, Adhemerval Zanella wrote:
> Ping, do we still want this for 2.28 release?
> 
> On 02/02/2018 15:04, Adhemerval Zanella wrote:
>> This is a new update for C11 threads support based on my previous [1]
>> version.  The main changes from previous version are:
>>  
>>   - Rebase against 2.28.
>>
>>   - Add RISCV abilist symbols.
>>  
>>   - Adjusted copyright dates for 2018.
>>  
>>   - Remove some redundant comments.
>>  
>> I tested this without regression with a full make/check on
>> x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
>> powerpc-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabihf,
>> sparc64-linux-gnu, and sparcv9-linux-gnu.
>>  
>> [1] https://sourceware.org/ml/libc-alpha/2017-09/msg00871.html
>>
>> Adhemerval Zanella (7):
>>   nptl: Add C11 threads thrd_* functions
>>   nptl: Add C11 threads mtx_* functions
>>   nptl: Add C11 threads call_once functions
>>   nptl: Add C11 threads cnd_* functions
>>   nptl: Add C11 threads tss_* functions
>>   nptl: Add abilist symbols for C11 threads
>>   nptl: Add test cases for ISO C11 threads
>>
>> Juan Manuel Torres Palma (1):
>>   Add manual documentation for threads.h
>>
>>  ChangeLog                                          | 175 ++++++++++
>>  conform/Makefile                                   |   7 +-
>>  conform/data/threads.h-data                        |  57 ++++
>>  include/stdc-predef.h                              |   3 -
>>  manual/Makefile                                    |   2 +-
>>  manual/isothreads.texi                             | 355 +++++++++++++++++++++
>>  nptl/Makefile                                      |  15 +-
>>  nptl/Versions                                      |   9 +
>>  nptl/call_once.c                                   |  31 ++
>>  nptl/cnd_broadcast.c                               |  26 ++
>>  nptl/cnd_destroy.c                                 |  26 ++
>>  nptl/cnd_init.c                                    |  32 ++
>>  nptl/cnd_signal.c                                  |  26 ++
>>  nptl/cnd_timedwait.c                               |  29 ++
>>  nptl/cnd_wait.c                                    |  27 ++
>>  nptl/descr.h                                       |   2 +
>>  nptl/mtx_destroy.c                                 |  26 ++
>>  nptl/mtx_init.c                                    |  52 +++
>>  nptl/mtx_lock.c                                    |  26 ++
>>  nptl/mtx_timedlock.c                               |  28 ++
>>  nptl/mtx_trylock.c                                 |  26 ++
>>  nptl/mtx_unlock.c                                  |  26 ++
>>  nptl/pthreadP.h                                    |   3 +
>>  nptl/pthread_create.c                              |  18 +-
>>  nptl/thrd_create.c                                 |  29 ++
>>  nptl/thrd_current.c                                |  25 ++
>>  nptl/thrd_detach.c                                 |  28 ++
>>  nptl/thrd_equal.c                                  |  25 ++
>>  nptl/thrd_exit.c                                   |  25 ++
>>  nptl/thrd_join.c                                   |  30 ++
>>  nptl/thrd_priv.h                                   |  45 +++
>>  nptl/thrd_sleep.c                                  |  38 +++
>>  nptl/thrd_yield.c                                  |  26 ++
>>  nptl/tss_create.c                                  |  28 ++
>>  nptl/tss_delete.c                                  |  25 ++
>>  nptl/tss_get.c                                     |  25 ++
>>  nptl/tss_set.c                                     |  26 ++
>>  nptl/tst-call-once.c                               |  66 ++++
>>  nptl/tst-cnd-basic.c                               |  68 ++++
>>  nptl/tst-cnd-broadcast.c                           |  83 +++++
>>  nptl/tst-cnd-timedwait.c                           |  70 ++++
>>  nptl/tst-mtx-basic.c                               |  73 +++++
>>  nptl/tst-mtx-recursive.c                           |  45 +++
>>  nptl/tst-mtx-timedlock.c                           |  98 ++++++
>>  nptl/tst-mtx-trylock.c                             |  90 ++++++
>>  nptl/tst-thrd-detach.c                             |  52 +++
>>  nptl/tst-thrd-sleep.c                              |  51 +++
>>  nptl/tst-tss-basic.c                               |  75 +++++
>>  sysdeps/nptl/threads.h                             | 200 ++++++++++++
>>  sysdeps/unix/sysv/linux/aarch64/libpthread.abilist |  26 ++
>>  sysdeps/unix/sysv/linux/alpha/libpthread.abilist   |  26 ++
>>  sysdeps/unix/sysv/linux/arm/libpthread.abilist     |  26 ++
>>  sysdeps/unix/sysv/linux/hppa/libpthread.abilist    |  26 ++
>>  sysdeps/unix/sysv/linux/i386/libpthread.abilist    |  26 ++
>>  sysdeps/unix/sysv/linux/ia64/libpthread.abilist    |  26 ++
>>  .../sysv/linux/m68k/coldfire/libpthread.abilist    |  26 ++
>>  .../unix/sysv/linux/m68k/m680x0/libpthread.abilist |  26 ++
>>  .../unix/sysv/linux/microblaze/libpthread.abilist  |  26 ++
>>  .../unix/sysv/linux/mips/mips32/libpthread.abilist |  26 ++
>>  .../unix/sysv/linux/mips/mips64/libpthread.abilist |  26 ++
>>  sysdeps/unix/sysv/linux/nios2/libpthread.abilist   |  26 ++
>>  .../linux/powerpc/powerpc32/libpthread.abilist     |  26 ++
>>  .../linux/powerpc/powerpc64/libpthread-le.abilist  |  26 ++
>>  .../linux/powerpc/powerpc64/libpthread.abilist     |  26 ++
>>  .../unix/sysv/linux/riscv/rv64/libpthread.abilist  |  26 ++
>>  .../sysv/linux/s390/s390-32/libpthread.abilist     |  26 ++
>>  .../sysv/linux/s390/s390-64/libpthread.abilist     |  26 ++
>>  sysdeps/unix/sysv/linux/sh/libpthread.abilist      |  26 ++
>>  .../sysv/linux/sparc/sparc32/libpthread.abilist    |  26 ++
>>  .../sysv/linux/sparc/sparc64/libpthread.abilist    |  26 ++
>>  .../sysv/linux/tile/tilegx32/libpthread.abilist    |  26 ++
>>  .../sysv/linux/tile/tilegx64/libpthread.abilist    |  26 ++
>>  .../unix/sysv/linux/x86_64/64/libpthread.abilist   |  26 ++
>>  .../unix/sysv/linux/x86_64/x32/libpthread.abilist  |  26 ++
>>  74 files changed, 3011 insertions(+), 12 deletions(-)
>>  create mode 100644 conform/data/threads.h-data
>>  create mode 100644 manual/isothreads.texi
>>  create mode 100644 nptl/call_once.c
>>  create mode 100644 nptl/cnd_broadcast.c
>>  create mode 100644 nptl/cnd_destroy.c
>>  create mode 100644 nptl/cnd_init.c
>>  create mode 100644 nptl/cnd_signal.c
>>  create mode 100644 nptl/cnd_timedwait.c
>>  create mode 100644 nptl/cnd_wait.c
>>  create mode 100644 nptl/mtx_destroy.c
>>  create mode 100644 nptl/mtx_init.c
>>  create mode 100644 nptl/mtx_lock.c
>>  create mode 100644 nptl/mtx_timedlock.c
>>  create mode 100644 nptl/mtx_trylock.c
>>  create mode 100644 nptl/mtx_unlock.c
>>  create mode 100644 nptl/thrd_create.c
>>  create mode 100644 nptl/thrd_current.c
>>  create mode 100644 nptl/thrd_detach.c
>>  create mode 100644 nptl/thrd_equal.c
>>  create mode 100644 nptl/thrd_exit.c
>>  create mode 100644 nptl/thrd_join.c
>>  create mode 100644 nptl/thrd_priv.h
>>  create mode 100644 nptl/thrd_sleep.c
>>  create mode 100644 nptl/thrd_yield.c
>>  create mode 100644 nptl/tss_create.c
>>  create mode 100644 nptl/tss_delete.c
>>  create mode 100644 nptl/tss_get.c
>>  create mode 100644 nptl/tss_set.c
>>  create mode 100644 nptl/tst-call-once.c
>>  create mode 100644 nptl/tst-cnd-basic.c
>>  create mode 100644 nptl/tst-cnd-broadcast.c
>>  create mode 100644 nptl/tst-cnd-timedwait.c
>>  create mode 100644 nptl/tst-mtx-basic.c
>>  create mode 100644 nptl/tst-mtx-recursive.c
>>  create mode 100644 nptl/tst-mtx-timedlock.c
>>  create mode 100644 nptl/tst-mtx-trylock.c
>>  create mode 100644 nptl/tst-thrd-detach.c
>>  create mode 100644 nptl/tst-thrd-sleep.c
>>  create mode 100644 nptl/tst-tss-basic.c
>>  create mode 100644 sysdeps/nptl/threads.h
>>

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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h
  2018-07-19 17:46   ` Adhemerval Zanella
@ 2018-07-19 18:43     ` Carlos O'Donell
  2018-07-19 19:12       ` Rical Jasan
  2018-07-19 21:26       ` Joseph Myers
  0 siblings, 2 replies; 80+ messages in thread
From: Carlos O'Donell @ 2018-07-19 18:43 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha; +Cc: Florian Weimer

On 07/19/2018 01:46 PM, Adhemerval Zanella wrote:
> Florian, 
> 
> First thanks for the thoroughly review for c11 threads so far. I think it
> has covered most the upcoming rough pieces.
> 
> Carlos, do you think we can squeeze this for 2.28? As you put private, I
> also don't think we will get a 'pristine' implementation with optimal
> object sizes without a refactor of internal nptl implementation.

Yes, I'd like to see Intel CET, C11 threads, and malloc hook removal land
in this release.

It seems to me like ISO C threads.h is ready, were there any more objections?

Have we double checked with Joseph?

-- 
Cheers,
Carlos.

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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h
  2018-07-19 18:43     ` Carlos O'Donell
@ 2018-07-19 19:12       ` Rical Jasan
  2018-07-19 19:58         ` Adhemerval Zanella
  2018-07-19 21:26       ` Joseph Myers
  1 sibling, 1 reply; 80+ messages in thread
From: Rical Jasan @ 2018-07-19 19:12 UTC (permalink / raw)
  To: Carlos O'Donell, Adhemerval Zanella, libc-alpha; +Cc: Florian Weimer

On 07/19/2018 11:43 AM, Carlos O'Donell wrote:
> On 07/19/2018 01:46 PM, Adhemerval Zanella wrote:
>> Carlos, do you think we can squeeze this for 2.28? As you put private, I
>> also don't think we will get a 'pristine' implementation with optimal
>> object sizes without a refactor of internal nptl implementation.
> 
> Yes, I'd like to see Intel CET, C11 threads, and malloc hook removal land
> in this release.
> 
> It seems to me like ISO C threads.h is ready, were there any more objections?

I would like to see the manual content folded into the chapter we
already have for threads (threads.texi).  I can take care of the
mechanical bits for doing that, either as a revision of v8 8/8 or as a
follow-up commit, whichever would be preferred.

Rical

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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h
  2018-07-19 19:12       ` Rical Jasan
@ 2018-07-19 19:58         ` Adhemerval Zanella
  2018-07-21  0:26           ` Rical Jasan
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-19 19:58 UTC (permalink / raw)
  To: Rical Jasan, Carlos O'Donell, libc-alpha; +Cc: Florian Weimer



On 19/07/2018 16:12, Rical Jasan wrote:
> On 07/19/2018 11:43 AM, Carlos O'Donell wrote:
>> On 07/19/2018 01:46 PM, Adhemerval Zanella wrote:
>>> Carlos, do you think we can squeeze this for 2.28? As you put private, I
>>> also don't think we will get a 'pristine' implementation with optimal
>>> object sizes without a refactor of internal nptl implementation.
>>
>> Yes, I'd like to see Intel CET, C11 threads, and malloc hook removal land
>> in this release.
>>
>> It seems to me like ISO C threads.h is ready, were there any more objections?
> 
> I would like to see the manual content folded into the chapter we
> already have for threads (threads.texi).  I can take care of the
> mechanical bits for doing that, either as a revision of v8 8/8 or as a
> follow-up commit, whichever would be preferred.
> 
> Rical
> 

If you could send a patch based on my personal branch [1] and can merge
it.

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

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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h
  2018-07-19 18:43     ` Carlos O'Donell
  2018-07-19 19:12       ` Rical Jasan
@ 2018-07-19 21:26       ` Joseph Myers
  2018-07-20 12:32         ` Adhemerval Zanella
  1 sibling, 1 reply; 80+ messages in thread
From: Joseph Myers @ 2018-07-19 21:26 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: Adhemerval Zanella, libc-alpha, Florian Weimer

On Thu, 19 Jul 2018, Carlos O'Donell wrote:

> Yes, I'd like to see Intel CET, C11 threads, and malloc hook removal land
> in this release.
> 
> It seems to me like ISO C threads.h is ready, were there any more objections?
> 
> Have we double checked with Joseph?

I have not reviewed the details of the patches, but do not object to 
inclusion in 2.28 if the patches can be reviewed and committed within the 
next day, given that they were proposed well in advance of the freeze and 
have already gone through a few reviews.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h
  2018-07-19 21:26       ` Joseph Myers
@ 2018-07-20 12:32         ` Adhemerval Zanella
  2018-07-20 13:22           ` Rical Jasan
  0 siblings, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-20 12:32 UTC (permalink / raw)
  To: Joseph Myers, Carlos O'Donell; +Cc: libc-alpha, Florian Weimer



On 19/07/2018 18:26, Joseph Myers wrote:
> On Thu, 19 Jul 2018, Carlos O'Donell wrote:
> 
>> Yes, I'd like to see Intel CET, C11 threads, and malloc hook removal land
>> in this release.
>>
>> It seems to me like ISO C threads.h is ready, were there any more objections?
>>
>> Have we double checked with Joseph?
> 
> I have not reviewed the details of the patches, but do not object to 
> inclusion in 2.28 if the patches can be reviewed and committed within the 
> next day, given that they were proposed well in advance of the freeze and 
> have already gone through a few reviews.
> 

I think the patchset is in good shape overall, the only missing part without
revision is '[PATCH v8 4/8] nptl: Add C11 threads cnd_* functions' but it
should be simple since it is just wrappers around internal nptl calls.

The only missing piece is Racal has asked to fold the manual contents
chapter in threads.text. I will sort this out today.

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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h
  2018-07-20 12:32         ` Adhemerval Zanella
@ 2018-07-20 13:22           ` Rical Jasan
  2018-07-20 13:54             ` Rical Jasan
  2018-07-20 15:02             ` [PATCH v8 0/8] Add support for ISO C threads.h [thrd_exit] Rical Jasan
  0 siblings, 2 replies; 80+ messages in thread
From: Rical Jasan @ 2018-07-20 13:22 UTC (permalink / raw)
  To: Adhemerval Zanella
  Cc: Joseph Myers, Carlos O'Donell, libc-alpha, Florian Weimer

On 07/20/2018 05:32 AM, Adhemerval Zanella wrote:
> The only missing piece is Racal has asked to fold the manual contents
> chapter in threads.text. I will sort this out today.

I'm fixing this up as we speak; will have something soon.

Rical

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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h
  2018-07-20 13:22           ` Rical Jasan
@ 2018-07-20 13:54             ` Rical Jasan
  2018-07-20 14:04               ` Carlos O'Donell
  2018-07-20 15:02             ` [PATCH v8 0/8] Add support for ISO C threads.h [thrd_exit] Rical Jasan
  1 sibling, 1 reply; 80+ messages in thread
From: Rical Jasan @ 2018-07-20 13:54 UTC (permalink / raw)
  To: Adhemerval Zanella
  Cc: Joseph Myers, Carlos O'Donell, libc-alpha, Florian Weimer

Should we really be saying "ISO C11" threads everywhere?  Would it be
appropriate to just say "ISO C"?  (I'm thinking about future ISO CXX
standards also having specifications for threads.)

Rical

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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h
  2018-07-20 13:54             ` Rical Jasan
@ 2018-07-20 14:04               ` Carlos O'Donell
  0 siblings, 0 replies; 80+ messages in thread
From: Carlos O'Donell @ 2018-07-20 14:04 UTC (permalink / raw)
  To: Rical Jasan, Adhemerval Zanella; +Cc: Joseph Myers, libc-alpha, Florian Weimer

On 07/20/2018 09:54 AM, Rical Jasan wrote:
> Should we really be saying "ISO C11" threads everywhere?  Would it be
> appropriate to just say "ISO C"?  (I'm thinking about future ISO CXX
> standards also having specifications for threads.)

I'd prefer ISO C threads for more formal discussions, with C threads,
as opposed to POSIX threads, for less formal.

-- 
Cheers,
Carlos.

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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h [thrd_exit]
  2018-07-20 13:22           ` Rical Jasan
  2018-07-20 13:54             ` Rical Jasan
@ 2018-07-20 15:02             ` Rical Jasan
  1 sibling, 0 replies; 80+ messages in thread
From: Rical Jasan @ 2018-07-20 15:02 UTC (permalink / raw)
  To: Adhemerval Zanella
  Cc: Joseph Myers, Carlos O'Donell, libc-alpha, Florian Weimer

Regarding thrd_exit, the new documentation is saying:

If this function is called from a single thread process, the call to
this function is equivalent to @code{exit(0)}.  Returning from a
thread-start function is equivalent to calling @code{thrd_exit}.

The standard says:

The program shall terminate normally after the last thread has been
terminated. The behavior shall be as if the program called the exit
function with the status EXIT_SUCCESS at thread termination time.

I came up with:

If this function is called from a single-threaded process, the call is
equivalent to calling @code{exit} with @code{EXIT_SUCCESS}
(@pxref{Normal Termination}).  Also note that returning from a function
that started a thread is equivalent to calling @code{thrd_exit}.


but I don't feel like the first sentence of each of those quite lines
up.  I suppose "single-threaded" and "last thread" could be used
interchangeably, but I don't think it gives the same impression.  Also,
the standard doesn't mention the function case.  Seems like a good
point, but maybe I'm not reading "thread-start function" right.

Any suggestions?

Thanks,
Rical

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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h
  2018-07-19 19:58         ` Adhemerval Zanella
@ 2018-07-21  0:26           ` Rical Jasan
  2018-07-21  2:11             ` Carlos O'Donell
  0 siblings, 1 reply; 80+ messages in thread
From: Rical Jasan @ 2018-07-21  0:26 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Carlos O'Donell, libc-alpha, Florian Weimer

[-- Attachment #1: Type: text/plain, Size: 974 bytes --]

On 07/19/2018 12:58 PM, Adhemerval Zanella wrote:
> If you could send a patch based on my personal branch [1] and can merge
> it.

I've attached the refactored/rewritten version.  It isn't a very long
section, so shouldn't take long to review (IANAE, so somebody should).

Aside from the refactoring to make the Threads chapter generic, I
reviewed the grammar, converted all references to "ISO C11" to "ISO C",
added @standards to everything, made sure all the relevant functions
mentioned their return values, and added cross-references where I felt
they would be useful.  I also reviewed the output in PDF, Info, and HTML
form.

I didn't mean to take so long, but I had to build make due a minimum
version requirement before I could review the output, and it took a lot
longer than building a single package like that usually does...

I didn't bother with the ChangeLog since I wasn't sure how you wanted to
handle that, and it changes all the time anyway.

Thanks,
Rical

[-- Attachment #2: cthreads.patch --]
[-- Type: text/x-patch, Size: 23189 bytes --]

commit 52d5f975656c61903d6a2fbb47a9ea460dd8db28
Author: Rical Jasan <ricaljasan@pacific.net>
Date:   Fri Jul 20 17:04:02 2018 -0700

    manual: Add documentation for ISO C Threads.
    
    The POSIX Threads chapter is renamed to Threads, making POSIX Threads
    a section, and a new section is added on the topic of ISO C Threads.
    
            * manual/debug.texi: Update adjacent chapter name.
            * manual/probes.texi: Likewise.
            * manual/threads.texi (ISO C Threads): New section.
            (POSIX Threads): Convert to a section.

diff --git a/manual/debug.texi b/manual/debug.texi
index f4157e525e..712a42f75c 100644
--- a/manual/debug.texi
+++ b/manual/debug.texi
@@ -1,5 +1,5 @@
 @node Debugging Support
-@c @node Debugging Support, POSIX Threads, Cryptographic Functions, Top
+@c @node Debugging Support, Threads, Cryptographic Functions, Top
 @c %MENU% Functions to help debugging applications
 @chapter Debugging support
 
diff --git a/manual/probes.texi b/manual/probes.texi
index fa6e38f785..ab2a3102bb 100644
--- a/manual/probes.texi
+++ b/manual/probes.texi
@@ -1,5 +1,5 @@
 @node Internal Probes
-@c @node Internal Probes, Tunables, POSIX Threads, Top
+@c @node Internal Probes, Tunables, Threads, Top
 @c %MENU% Probes to monitor libc internal behavior
 @chapter Internal probes
 
diff --git a/manual/threads.texi b/manual/threads.texi
index 769d974d50..01217e1c85 100644
--- a/manual/threads.texi
+++ b/manual/threads.texi
@@ -1,10 +1,538 @@
+@node Threads
+@c @node Threads, Internal Probes, Debugging Support, Top
+@c %MENU% Functions, constants, and data types for working with threads
+@chapter Threads
+@cindex threads
+
+This chapter describes functions used for managing threads.
+@Theglibc{} provides two threading implementations: ISO C threads and
+POSIX threads.
+
+@menu
+* ISO C Threads::	Threads based on the ISO C specification.
+* POSIX Threads::	Threads based on the POSIX specification.
+@end menu
+
+
+@node ISO C Threads
+@section ISO C Threads
+@cindex ISO C threads
+@cindex C threads
+@pindex threads.h
+
+This section describes the @glibcadj{} ISO C threads implementation.
+To have a deeper understanding of this API, it is strongly recomended
+to read ISO/IEC 9899:2011, section 7.26, in which ISO C threads were
+originally specified.  All types and function prototypes are declared
+in the header file @file{threads.h}.
+
+@menu
+* ISO C Threads Return Values:: Symbolic constants that represent a
+				function's return value.
+* ISO C Thread Management::	Support for basic threading.
+* Call Once::			Single-call functions and macros.
+* ISO C Mutexes::		A low-level mechanism for mutual exclusion.
+* ISO C Condition Variables::	High-level objects for thread synchronization.
+* ISO C Thread-local Storage::	Functions to support thread-local storage.
+@end menu
+
+
+@node ISO C Threads Return Values
+@subsection Return Values
+
+The ISO C thread specification provides the following enumeration
+constants for return values from functions in the API:
+
+@vtable @code
+@item thrd_timedout
+@standards{C11, threads.h}
+A specified time was reached without acquiring the requested resource,
+usually a mutex or condition variable.
+
+@item thrd_success
+@standards{C11, threads.h}
+The requested operation succeeded.
+
+@item thrd_busy
+@standards{C11, threads.h}
+The requested operation failed because a requested resource is already
+in use.
+
+@item thrd_error
+@standards{C11, threads.h}
+The requested operation failed.
+
+@item thrd_nomem
+@standards{C11, threads.h}
+The requested operation failed because it was unable to allocate
+enough memory.
+@end vtable
+
+
+@node ISO C Thread Management
+@subsection Creation and Control
+@cindex thread creation
+@cindex thread control
+@cindex thread management
+
+@Theglibc{} implements a set of functions that allow the user to easily
+create and use threads.  Additional functionality is provided to control
+the behavior of threads.
+
+The following data types are defined for managing threads:
+
+@deftp {Data Type} thrd_t
+@standards{C11, threads.h}
+A unique object that identifies a thread unequivocally.
+@end deftp
+
+@deftp {Data Type} thrd_start_t
+@standards{C11, threads.h}
+This data type is an @code{int (*) (void *)} typedef that is passed to
+@code{thrd_create} when creating a new thread.  It should point to the
+first function that thread will run.
+@end deftp
+
+The following functions are used for working with threads:
+
+@deftypefun int thrd_create (thrd_t *@var{thr}, thrd_start_t @var{func}, void *@var{arg})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{thrd_create} creates a new thread that will execute the function
+@var{func}.  The object pointed to by @var{arg} will be used as the
+argument to @var{func}.  If successful, @var{thr} is set to the new
+thread identifier.
+
+This function may return @code{thrd_success}, @code{thrd_nomem}, or
+@code{thrd_error}.
+@end deftypefun
+
+@deftypefun thrd_t thrd_current (void)
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+This function returns the identifier of the calling thread.
+@end deftypefun
+
+@deftypefun int thrd_equal (thrd_t @var{lhs}, thrd_t @var{rhs})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{thrd_equal} checks whether @var{lhs} and @var{rhs} refer to the
+same thread.  If @var{lhs} and @var{rhs} are different threads, this
+function returns @math{0}; otherwise, the return value is non-zero.
+@end deftypefun
+
+@deftypefun int thrd_sleep (const struct timespec *@var{time_point}, struct timespec *@var{remaining})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{thrd_sleep} blocks the execution of the current thread for at
+least until the elapsed time pointed to by @var{time_point} has been
+reached.  This function does not take an absolute time, but a duration
+that the thread is required to be blocked.  @xref{Time Basics}, and
+@ref{Elapsed Time}.
+
+The thread may wake early if a signal that is not ignored is received.
+In such a case, if @code{remaining} is not NULL, the remaining time
+duration is stored in the object pointed to by
+@var{remaining}.
+
+@code{thrd_sleep} returns @math{0} if it blocked for at least the
+amount of time in @code{time_point}, @math{-1} if it was interrupted
+by a signal, or a negative number on failure.
+@end deftypefun
+
+@deftypefun void thrd_yield (void)
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{thrd_yield} provides a hint to the implementation to reschedule
+the execution of the current thread, allowing other threads to run.
+@end deftypefun
+
+@deftypefun {_Noreturn void} thrd_exit (int @var{res})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{thrd_exit} terminates execution of the calling thread and sets
+its result code to @var{res}.
+
+If this function is called from a single-threaded process, the call is
+equivalent to calling @code{exit} with @code{EXIT_SUCCESS}
+(@pxref{Normal Termination}).  Also note that returning from a
+function that started a thread is equivalent to calling
+@code{thrd_exit}.
+@end deftypefun
+
+@deftypefun int thrd_detach (thrd_t @var{thr})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{thrd_detach} detaches the thread identified by @code{thr} from
+the current control thread.  The resources held by the detached thread
+will be freed automatically once the thread exits.  The parent thread
+will never be notified by any @var{thr} signal.
+
+Calling @code{thrd_detach} on a thread that was previously detached or
+joined by another thread results in undefined behavior.
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+@deftypefun int thrd_join (thrd_t @var{thr}, int *@var{res})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{thrd_join} blocks the current thread until the thread identified
+by @code{thr} finishes execution.  If @code{res} is not NULL, the
+result code of the thread is put into the location pointed to by
+@var{res}.  The termination of the thread @dfn{synchronizes-with} the
+completion of this function, meaning both threads have arrived at a
+common point in their execution.
+
+Calling @code{thrd_join} on a thread that was previously detached or
+joined by another thread results in undefined behavior.
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+
+@node Call Once
+@subsection Call Once
+@cindex call once
+@cindex single-call functions
+
+In order to guarantee single access to a function, @theglibc{}
+implements a @dfn{call once function} to ensure a function is only
+called once in the presence of multiple, potentially calling threads.
+
+@deftp {Data Type} once_flag
+@standards{C11, threads.h}
+A complete object type capable of holding a flag used by @code{call_once}.
+@end deftp
+
+@defvr Macro ONCE_FLAG_INIT
+@standards{C11, threads.h}
+This value is used to initialize an object of type @code{once_flag}.
+@end defvr
+
+@deftypefun void call_once (once_flag *@var{flag}, void (*@var{func}) (void))
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{call_once} calls function @var{func} exactly once, even if
+invoked from several threads.  The completion of the function
+@var{func} synchronizes-with all previous or subsequent calls to
+@code{call_once} with the same @code{flag} variable.
+@end deftypefun
+
+
+@node ISO C Mutexes
+@subsection Mutexes
+@cindex mutex
+@cindex mutual exclusion
+
+To have better control of resources and how threads access them,
+@theglibc{} implements a @dfn{mutex} object, which can help avoid race
+conditions and other concurrency issues.  The term ``mutex'' refers to
+mutual exclusion.
+
+The fundamental data type for a mutex is the @code{mtx_t}:
+
+@deftp {Data Type} mtx_t
+@standards{C11, threads.h}
+The @code{mtx_t} data type uniquely identifies a mutex object.
+@end deftp
+
+The ISO C standard defines several types of mutexes.  They are
+represented by the following symbolic constants:
+
+@vtable @code
+@item mtx_plain
+@standards{C11, threads.h}
+A mutex that does not support timeout, or test and return.
+
+@item mtx_recursive
+@standards{C11, threads.h}
+A mutex that supports recursive locking, which means that the owner
+thread can lock it more than once without causing deadlock.
+
+@item mtx_timed
+@standards{C11, threads.h}
+A mutex that supports timeout.
+@end vtable
+
+The following functions are used for working with mutexes:
+
+@deftypefun int mtx_init (mtx_t *@var{mutex}, int @var{type})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{mtx_init} creates a new mutex object with type @var{type}.  The
+object pointed to by @var{mutex} is set to the identifier of the newly
+created mutex.
+
+The @code{type} argument may be either @code{mtx_plain} or
+@code{mtx_timed}, optionally combined with @code{mtx_recursive}.
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+@deftypefun int mtx_lock (mtx_t *@var{mutex})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+@code{mtx_lock} blocks the current thread until the mutex pointed to
+by @var{mutex} is locked.  The behavior is undefined if the current
+thread has already locked the mutex and the mutex is not recursive.
+
+Prior calls to @code{mtx_unlock} on the same mutex synchronize-with
+this operation (if this operation succeeds), and all lock/unlock
+operations on any given mutex form a single total order (similar to
+the modification order of an atomic).
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+@deftypefun int mtx_timedlock (mtx_t *restrict @var{mutex}, const struct timespec *restrict @var{time_point})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+@code{mtx_timedlock} blocks the current thread until the mutex pointed
+to by @var{mutex} is locked or until the calendar time pointed to by
+@var{time_point} has been reached.  Since this function takes an
+absolute time, if a duration is required, the calendar time must be
+calculated manually.  @xref{Time Basics}, and @ref{Calendar Time}.
+
+If the current thread has already locked the mutex and the mutex is
+not recursive, or if the mutex does not support timeout, the behavior
+of this function is undefined.
+
+Prior calls to @code{mtx_unlock} on the same mutex synchronize-with
+this operation (if this operation succeeds), and all lock/unlock
+operations on any given mutex form a single total order (similar to
+the modification order of an atomic).
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+@deftypefun int mtx_trylock (mtx_t *@var{mutex})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+@code{mtx_trylock} tries to lock the mutex pointed to by @var{mutex}
+without blocking.  It returns immediately if the mutex is already
+locked.
+
+Prior calls to @code{mtx_unlock} on the same mutex synchronize-with
+this operation (if this operation succeeds), and all lock/unlock
+operations on any given mutex form a single total order (similar to
+the modification order of an atomic).
+
+This function returns @code{thrd_success} if the lock was obtained,
+@code{thrd_busy} if the mutex is already locked, and @code{thrd_error}
+on failure.
+@end deftypefun
+
+@deftypefun int mtx_unlock (mtx_t *@var{mutex})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{mtx_unlock} unlocks the mutex pointed to by @var{mutex}.  The
+behavior is undefined if the mutex is not locked by the calling
+thread.
+
+This function synchronizes-with subsequent @code{mtx_lock},
+@code{mtx_trylock}, and @code{mtx_timedlock} calls on the same mutex.
+All lock/unlock operations on any given mutex form a single total
+order (similar to the modification order of an atomic).
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+@deftypefun void mtx_destroy (mtx_t *@var{mutex})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{mtx_destroy} destroys the mutex pointed to by @var{mutex}.  If
+there are any threads waiting on the mutex, the behavior is
+undefined.
+@end deftypefun
+
+
+@node ISO C Condition Variables
+@subsection Condition Variables
+@cindex condvar
+@cindex condition variables
+
+Mutexes are not the only synchronization mechanisms available.  For
+some more complex tasks, @theglibc{} also implements @dfn{condition
+variables}, which allow the programmer to think at a higher level when
+solving complex synchronization problems.  They are used to
+synchronize threads waiting on a certain condition to happen.
+
+The fundamental data type for condition variables is the @code{cnd_t}:
+
+@deftp {Data Type} cnd_t
+@standards{C11, threads.h}
+The @code{cnd_t} uniquely identifies a condition variable object.
+@end deftp
+
+The following functions are used for working with condition variables:
+
+@deftypefun int cnd_init (cnd_t *@var{cond})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{cnd_init} initializes a new condition variable, identified by
+@var{cond}.
+
+This function may return @code{thrd_success}, @code{thrd_nomem}, or
+@code{thrd_error}.
+@end deftypefun
+
+@deftypefun int cnd_signal (cnd_t *@var{cond})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{cnd_signal} unblocks one thread that is currently waiting on the
+condition variable pointed to by @var{cond}.  If a thread is
+successfully unblocked, this function returns @code{thrd_success}.  If
+no threads are blocked, this function does nothing and returns
+@code{thrd_success}.  Otherwise, this function returns
+@code{thrd_error}.
+@end deftypefun
+
+@deftypefun int cnd_broadcast (cnd_t *@var{cond})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{cnd_broadcast} unblocks all the threads that are currently
+waiting on the condition variable pointed to by @var{cond}.  This
+function returns @code{thrd_success} on success.  If no threads are
+blocked, this function does nothing and returns
+@code{thrd_success}. Otherwise, this function returns
+@code{thrd_error}.
+@end deftypefun
+
+@deftypefun int cnd_wait (cnd_t *@var{cond}, mtx_t *@var{mutex})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+@code{cnd_wait} atomically unlocks the mutex pointed to by @var{mutex}
+and blocks on the condition variable pointed to by @var{cond} until
+the thread is signalled by @code{cnd_signal} or @code{cnd_broadcast}.
+The mutex is locked again before the function returns.
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+@deftypefun int cnd_timedwait (cnd_t *restrict @var{cond}, mtx_t *restrict @var{mutex}, const struct timespec *restrict @var{time_point})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+@code{cnd_timedwait} atomically unlocks the mutex pointed to by
+@var{mutex} and blocks on the condition variable pointed to by
+@var{cond} until the thread is signalled by @code{cnd_signal} or
+@code{cnd_broadcast}, or until the calendar time pointed to by
+@var{time_point} has been reached.  The mutex is locked again before
+the function returns.
+
+As for @code{mtx_timedlock}, since this function takes an absolute
+time, if a duration is required, the calendar time must be calculated
+manually.  @xref{Time Basics}, and @ref{Calendar Time}.
+
+This function may return @code{thrd_success}, @code{thrd_nomem}, or
+@code{thrd_error}.
+@end deftypefun
+
+@deftypefun void cnd_destroy (cnd_t *@var{cond})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{cnd_destroy} destroys the condition variable pointed to by
+@var{cond}.  If there are threads waiting on @var{cond}, the behavior
+is undefined.
+@end deftypefun
+
+
+@node ISO C Thread-local Storage
+@subsection Thread-local Storage
+@cindex thread-local storage
+
+@Theglibc{} implements functions to provide @dfn{thread-local
+storage}, which means each thread can have their own variables that
+are not visible by other threads.
+
+Several data types and macros exist for working with thread-local
+storage:
+
+@deftp {Data Type} tss_t
+@standards{C11, threads.h}
+The @code{tss_t} data type identifies a thread-specific storage
+object.  Even if shared, every thread will have its own instance of
+the variable, with different values.
+@end deftp
+
+@deftp {Data Type} tss_dtor_t
+@standards{C11, threads.h}
+The @code{tss_dtor_t} is a function pointer of type @code{void (*)
+(void *)}, to be used as a thread-specific storage destructor.  The
+function will be called when the current thread calls @code{thrd_exit}
+(but never when calling @code{tss_delete} or @code{exit}).
+@end deftp
+
+@defvr Macro thread_local
+@standards{C11, threads.h}
+@code{thread_local} is used to mark a variable with thread storage
+duration, which means it is created when the thread starts and cleaned
+up when the thread ends.
+
+@emph{Note:} For C++, C++11 or later is required to get the
+@code{thread_local} keyword.
+@end defvr
+
+@defvr Macro TSS_DTOR_ITERATIONS
+@standards{C11, threads.h}
+@code{TSS_DTOR_ITERATIONS} is an integer constant expression
+representing the maximum number of times that destructors will be
+called when a thread terminates.
+@end defvr
+
+The following functions are used to manage thread-local storage:
+
+@deftypefun int tss_create (tss_t *@var{tss_key}, tss_dtor_t @var{destructor})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{tss_create} creates a new thread-specific storage key and stores
+it in the object pointed to by @var{tss_key}.  Although the same key
+value may be used by different threads, the values bound to the key by
+@code{tss_set} are maintained on a per-thread basis and persist for
+the life of the calling thread.
+
+If @code{destructor} is not NULL, a destructor function will be set,
+and called when the thread finishes its execution by calling
+@code{thrd_exit}.
+
+This function returns @code{thrd_success} if @code{tss_key} is
+successfully set to a unique value for the thread; otherwise,
+@code{thrd_error} is returned and the value of @code{tss_key} is
+undefined.
+@end deftypefun
+
+@deftypefun int tss_set (tss_t @var{tss_key}, void *@var{val})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{tss_set} sets the value of the thread-specific storage
+identified by @var{tss_key} for the current thread to @var{val}.
+Different threads may set different values to the same key.
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+@deftypefun {void *} tss_get (tss_t @var{tss_key})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{tss_get} returns the value identified by @var{tss_key} held in
+thread-specific storage for the current thread.  Different threads may
+get different values identified by the same key.  On failure,
+@code{tss_get} returns zero.
+@end deftypefun
+
+@deftypefun void tss_delete (tss_t @var{tss_key})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{tss_delete} destroys the thread-specific storage identified by
+@var{tss_key}.
+@end deftypefun
+
+
 @node POSIX Threads
-@c @node POSIX Threads, Internal Probes, Cryptographic Functions, Top
-@chapter POSIX Threads
-@c %MENU% POSIX Threads
+@section POSIX Threads
 @cindex pthreads
 
-This chapter describes the @glibcadj{} POSIX Threads implementation.
+This section describes the @glibcadj{} POSIX Threads implementation.
 
 @menu
 * Thread-specific Data::          Support for creating and
@@ -14,7 +542,7 @@ This chapter describes the @glibcadj{} POSIX Threads implementation.
 @end menu
 
 @node Thread-specific Data
-@section Thread-specific Data
+@subsection Thread-specific Data
 
 The @glibcadj{} implements functions to allow users to create and manage
 data specific to a thread.  Such data may be destroyed at thread exit,
@@ -71,7 +599,7 @@ Associate the thread-specific @var{value} with @var{key} in the calling thread.
 
 
 @node Non-POSIX Extensions
-@section Non-POSIX Extensions
+@subsection Non-POSIX Extensions
 
 In addition to implementing the POSIX API for threads, @theglibc{} provides
 additional functions and interfaces to provide functionality not specified in
@@ -83,7 +611,7 @@ the standard.
 @end menu
 
 @node Default Thread Attributes
-@subsection Setting Process-wide defaults for thread attributes
+@subsubsection Setting Process-wide defaults for thread attributes
 
 @Theglibc{} provides non-standard API functions to set and get the default
 attributes used in the creation of threads in a process.

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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h
  2018-07-21  0:26           ` Rical Jasan
@ 2018-07-21  2:11             ` Carlos O'Donell
  2018-07-21  6:22               ` Rical Jasan
  0 siblings, 1 reply; 80+ messages in thread
From: Carlos O'Donell @ 2018-07-21  2:11 UTC (permalink / raw)
  To: Rical Jasan, Adhemerval Zanella; +Cc: libc-alpha, Florian Weimer

On 07/20/2018 08:26 PM, Rical Jasan wrote:
> On 07/19/2018 12:58 PM, Adhemerval Zanella wrote:
>> If you could send a patch based on my personal branch [1] and can merge
>> it.
> I've attached the refactored/rewritten version.  It isn't a very long
> section, so shouldn't take long to review (IANAE, so somebody should).
> 
> Aside from the refactoring to make the Threads chapter generic, I
> reviewed the grammar, converted all references to "ISO C11" to "ISO C",
> added @standards to everything, made sure all the relevant functions
> mentioned their return values, and added cross-references where I felt
> they would be useful.  I also reviewed the output in PDF, Info, and HTML
> form.
> 
> I didn't mean to take so long, but I had to build make due a minimum
> version requirement before I could review the output, and it took a lot
> longer than building a single package like that usually does...
> 
> I didn't bother with the ChangeLog since I wasn't sure how you wanted to
> handle that, and it changes all the time anyway.

Great work here! Thank you for this help Rical!

OK for 2.28 with the follwing changes:

- Two spelling fixes.
- Consider suggestion for removing "unequivocally"
- Use "owning thread"
- Consider suggestion to expand thread type |'ing.
- Tighten up TLS language.
- You "use" a keyword.
- Broaden explanation of TSS_DTOR_ITERATIONS

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> commit 52d5f975656c61903d6a2fbb47a9ea460dd8db28
> Author: Rical Jasan <ricaljasan@pacific.net>
> Date:   Fri Jul 20 17:04:02 2018 -0700
> 
>     manual: Add documentation for ISO C Threads.
>     
>     The POSIX Threads chapter is renamed to Threads, making POSIX Threads
>     a section, and a new section is added on the topic of ISO C Threads.
>     
>             * manual/debug.texi: Update adjacent chapter name.
>             * manual/probes.texi: Likewise.
>             * manual/threads.texi (ISO C Threads): New section.
>             (POSIX Threads): Convert to a section.
> 
> diff --git a/manual/debug.texi b/manual/debug.texi
> index f4157e525e..712a42f75c 100644
> --- a/manual/debug.texi
> +++ b/manual/debug.texi
> @@ -1,5 +1,5 @@
>  @node Debugging Support
> -@c @node Debugging Support, POSIX Threads, Cryptographic Functions, Top
> +@c @node Debugging Support, Threads, Cryptographic Functions, Top

OK.

>  @c %MENU% Functions to help debugging applications
>  @chapter Debugging support
>  
> diff --git a/manual/probes.texi b/manual/probes.texi
> index fa6e38f785..ab2a3102bb 100644
> --- a/manual/probes.texi
> +++ b/manual/probes.texi
> @@ -1,5 +1,5 @@
>  @node Internal Probes
> -@c @node Internal Probes, Tunables, POSIX Threads, Top
> +@c @node Internal Probes, Tunables, Threads, Top

OK.

>  @c %MENU% Probes to monitor libc internal behavior
>  @chapter Internal probes
>  
> diff --git a/manual/threads.texi b/manual/threads.texi
> index 769d974d50..01217e1c85 100644
> --- a/manual/threads.texi
> +++ b/manual/threads.texi
> @@ -1,10 +1,538 @@
> +@node Threads
> +@c @node Threads, Internal Probes, Debugging Support, Top
> +@c %MENU% Functions, constants, and data types for working with threads

OK.

> +@chapter Threads
> +@cindex threads
> +
> +This chapter describes functions used for managing threads.
> +@Theglibc{} provides two threading implementations: ISO C threads and
> +POSIX threads.

OK.

> +
> +@menu
> +* ISO C Threads::	Threads based on the ISO C specification.
> +* POSIX Threads::	Threads based on the POSIX specification.

OK. Yay!

> +@end menu
> +
> +
> +@node ISO C Threads
> +@section ISO C Threads
> +@cindex ISO C threads
> +@cindex C threads
> +@pindex threads.h
> +
> +This section describes the @glibcadj{} ISO C threads implementation.
> +To have a deeper understanding of this API, it is strongly recomended

s/recomended/recommended/g

> +to read ISO/IEC 9899:2011, section 7.26, in which ISO C threads were
> +originally specified.  All types and function prototypes are declared
> +in the header file @file{threads.h}.
> +
> +@menu
> +* ISO C Threads Return Values:: Symbolic constants that represent a
> +				function's return value.
> +* ISO C Thread Management::	Support for basic threading.
> +* Call Once::			Single-call functions and macros.
> +* ISO C Mutexes::		A low-level mechanism for mutual exclusion.
> +* ISO C Condition Variables::	High-level objects for thread synchronization.
> +* ISO C Thread-local Storage::	Functions to support thread-local storage.
> +@end menu

OK.

> +
> +
> +@node ISO C Threads Return Values
> +@subsection Return Values
> +
> +The ISO C thread specification provides the following enumeration
> +constants for return values from functions in the API:
> +
> +@vtable @code
> +@item thrd_timedout
> +@standards{C11, threads.h}
> +A specified time was reached without acquiring the requested resource,
> +usually a mutex or condition variable.
> +
> +@item thrd_success
> +@standards{C11, threads.h}
> +The requested operation succeeded.
> +
> +@item thrd_busy
> +@standards{C11, threads.h}
> +The requested operation failed because a requested resource is already
> +in use.
> +
> +@item thrd_error
> +@standards{C11, threads.h}
> +The requested operation failed.
> +
> +@item thrd_nomem
> +@standards{C11, threads.h}
> +The requested operation failed because it was unable to allocate
> +enough memory.
> +@end vtable

OK.

> +
> +
> +@node ISO C Thread Management
> +@subsection Creation and Control
> +@cindex thread creation
> +@cindex thread control
> +@cindex thread management
> +
> +@Theglibc{} implements a set of functions that allow the user to easily
> +create and use threads.  Additional functionality is provided to control
> +the behavior of threads.
> +
> +The following data types are defined for managing threads:
> +
> +@deftp {Data Type} thrd_t
> +@standards{C11, threads.h}
> +A unique object that identifies a thread unequivocally.

Suggest:
A unique object that identifies one thread.

Do more with less.

> +@end deftp
> +
> +@deftp {Data Type} thrd_start_t
> +@standards{C11, threads.h}
> +This data type is an @code{int (*) (void *)} typedef that is passed to
> +@code{thrd_create} when creating a new thread.  It should point to the
> +first function that thread will run.
> +@end deftp
> +
> +The following functions are used for working with threads:
> +
> +@deftypefun int thrd_create (thrd_t *@var{thr}, thrd_start_t @var{func}, void *@var{arg})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{thrd_create} creates a new thread that will execute the function
> +@var{func}.  The object pointed to by @var{arg} will be used as the
> +argument to @var{func}.  If successful, @var{thr} is set to the new
> +thread identifier.

OK.

> +
> +This function may return @code{thrd_success}, @code{thrd_nomem}, or
> +@code{thrd_error}.

OK.

> +@end deftypefun
> +
> +@deftypefun thrd_t thrd_current (void)
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +This function returns the identifier of the calling thread.
> +@end deftypefun
> +
> +@deftypefun int thrd_equal (thrd_t @var{lhs}, thrd_t @var{rhs})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{thrd_equal} checks whether @var{lhs} and @var{rhs} refer to the
> +same thread.  If @var{lhs} and @var{rhs} are different threads, this
> +function returns @math{0}; otherwise, the return value is non-zero.
> +@end deftypefun

OK.

> +
> +@deftypefun int thrd_sleep (const struct timespec *@var{time_point}, struct timespec *@var{remaining})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{thrd_sleep} blocks the execution of the current thread for at
> +least until the elapsed time pointed to by @var{time_point} has been
> +reached.  This function does not take an absolute time, but a duration
> +that the thread is required to be blocked.  @xref{Time Basics}, and
> +@ref{Elapsed Time}.
> +

OK.

> +The thread may wake early if a signal that is not ignored is received.
> +In such a case, if @code{remaining} is not NULL, the remaining time
> +duration is stored in the object pointed to by
> +@var{remaining}.

OK.

> +
> +@code{thrd_sleep} returns @math{0} if it blocked for at least the
> +amount of time in @code{time_point}, @math{-1} if it was interrupted
> +by a signal, or a negative number on failure.
> +@end deftypefun

OK.

> +
> +@deftypefun void thrd_yield (void)
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{thrd_yield} provides a hint to the implementation to reschedule
> +the execution of the current thread, allowing other threads to run.
> +@end deftypefun

OK.

> +
> +@deftypefun {_Noreturn void} thrd_exit (int @var{res})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{thrd_exit} terminates execution of the calling thread and sets
> +its result code to @var{res}.
> +
> +If this function is called from a single-threaded process, the call is
> +equivalent to calling @code{exit} with @code{EXIT_SUCCESS}
> +(@pxref{Normal Termination}).  Also note that returning from a
> +function that started a thread is equivalent to calling
> +@code{thrd_exit}.

This is the text you worried about.

On the one hand the standard says "last thread," but what does that mean?
It implies a total ordering of exiting threads, when that might not be true,
but both texts appear to assume it. Therefore it's fine for a first kick at
the can to describe what is happening.

In essence you had a multi-threaded program, and the threads start exiting,
and eventually you are left with just one thread whose thrd_exit is equivalent
to exit. It's a fine cognitive model, but assumes the implementation imposes
that total exit ordering in order for there to be a "last" thread, rather than
all threads exiting simultaneously and all of them being the "last" thread.

This looks good to me.

> +@end deftypefun
> +
> +@deftypefun int thrd_detach (thrd_t @var{thr})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{thrd_detach} detaches the thread identified by @code{thr} from
> +the current control thread.  The resources held by the detached thread
> +will be freed automatically once the thread exits.  The parent thread
> +will never be notified by any @var{thr} signal.
> +
> +Calling @code{thrd_detach} on a thread that was previously detached or
> +joined by another thread results in undefined behavior.
> +
> +This function returns either @code{thrd_success} or @code{thrd_error}.
> +@end deftypefun
> +
> +@deftypefun int thrd_join (thrd_t @var{thr}, int *@var{res})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{thrd_join} blocks the current thread until the thread identified
> +by @code{thr} finishes execution.  If @code{res} is not NULL, the
> +result code of the thread is put into the location pointed to by
> +@var{res}.  The termination of the thread @dfn{synchronizes-with} the
> +completion of this function, meaning both threads have arrived at a
> +common point in their execution.
> +
> +Calling @code{thrd_join} on a thread that was previously detached or
> +joined by another thread results in undefined behavior.
> +
> +This function returns either @code{thrd_success} or @code{thrd_error}.
> +@end deftypefun
> +
> +
> +@node Call Once
> +@subsection Call Once
> +@cindex call once
> +@cindex single-call functions
> +
> +In order to guarantee single access to a function, @theglibc{}
> +implements a @dfn{call once function} to ensure a function is only
> +called once in the presence of multiple, potentially calling threads.
> +
> +@deftp {Data Type} once_flag
> +@standards{C11, threads.h}
> +A complete object type capable of holding a flag used by @code{call_once}.
> +@end deftp
> +
> +@defvr Macro ONCE_FLAG_INIT
> +@standards{C11, threads.h}
> +This value is used to initialize an object of type @code{once_flag}.
> +@end defvr
> +
> +@deftypefun void call_once (once_flag *@var{flag}, void (*@var{func}) (void))
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{call_once} calls function @var{func} exactly once, even if
> +invoked from several threads.  The completion of the function
> +@var{func} synchronizes-with all previous or subsequent calls to
> +@code{call_once} with the same @code{flag} variable.
> +@end deftypefun

OK.

> +
> +
> +@node ISO C Mutexes
> +@subsection Mutexes
> +@cindex mutex
> +@cindex mutual exclusion
> +
> +To have better control of resources and how threads access them,
> +@theglibc{} implements a @dfn{mutex} object, which can help avoid race
> +conditions and other concurrency issues.  The term ``mutex'' refers to

OK.

> +mutual exclusion.
> +

OK.

> +The fundamental data type for a mutex is the @code{mtx_t}:
> +
> +@deftp {Data Type} mtx_t
> +@standards{C11, threads.h}
> +The @code{mtx_t} data type uniquely identifies a mutex object.
> +@end deftp
> +
> +The ISO C standard defines several types of mutexes.  They are
> +represented by the following symbolic constants:
> +
> +@vtable @code
> +@item mtx_plain
> +@standards{C11, threads.h}
> +A mutex that does not support timeout, or test and return.
> +
> +@item mtx_recursive
> +@standards{C11, threads.h}
> +A mutex that supports recursive locking, which means that the owner
> +thread can lock it more than once without causing deadlock.

Traditional technical language is "owning thread"

s/owner thread/owning thread/g

> +
> +@item mtx_timed
> +@standards{C11, threads.h}
> +A mutex that supports timeout.
> +@end vtable
> +
> +The following functions are used for working with mutexes:
> +
> +@deftypefun int mtx_init (mtx_t *@var{mutex}, int @var{type})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{mtx_init} creates a new mutex object with type @var{type}.  The
> +object pointed to by @var{mutex} is set to the identifier of the newly
> +created mutex.
> +
> +The @code{type} argument may be either @code{mtx_plain} or
> +@code{mtx_timed}, optionally combined with @code{mtx_recursive}.

This should be expanded to ensure clarity.

Suggest:
~~~
The @code{type} argument may be either @code{mtx_plain},
@code{mtx_timed}, @code{mtx_plain | mtx_recursive}, or 
@code{mtx_timed | mtx_recursive}.
~~~

> +
> +This function returns either @code{thrd_success} or @code{thrd_error}.
> +@end deftypefun
> +
> +@deftypefun int mtx_lock (mtx_t *@var{mutex})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
> +@code{mtx_lock} blocks the current thread until the mutex pointed to
> +by @var{mutex} is locked.  The behavior is undefined if the current
> +thread has already locked the mutex and the mutex is not recursive.
> +
> +Prior calls to @code{mtx_unlock} on the same mutex synchronize-with
> +this operation (if this operation succeeds), and all lock/unlock
> +operations on any given mutex form a single total order (similar to
> +the modification order of an atomic).
> +
> +This function returns either @code{thrd_success} or @code{thrd_error}.
> +@end deftypefun
> +
> +@deftypefun int mtx_timedlock (mtx_t *restrict @var{mutex}, const struct timespec *restrict @var{time_point})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
> +@code{mtx_timedlock} blocks the current thread until the mutex pointed
> +to by @var{mutex} is locked or until the calendar time pointed to by
> +@var{time_point} has been reached.  Since this function takes an
> +absolute time, if a duration is required, the calendar time must be
> +calculated manually.  @xref{Time Basics}, and @ref{Calendar Time}.

OK.

> +
> +If the current thread has already locked the mutex and the mutex is
> +not recursive, or if the mutex does not support timeout, the behavior
> +of this function is undefined.
> +
> +Prior calls to @code{mtx_unlock} on the same mutex synchronize-with
> +this operation (if this operation succeeds), and all lock/unlock
> +operations on any given mutex form a single total order (similar to
> +the modification order of an atomic).
> +
> +This function returns either @code{thrd_success} or @code{thrd_error}.
> +@end deftypefun

OK.

> +
> +@deftypefun int mtx_trylock (mtx_t *@var{mutex})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
> +@code{mtx_trylock} tries to lock the mutex pointed to by @var{mutex}
> +without blocking.  It returns immediately if the mutex is already
> +locked.
> +
> +Prior calls to @code{mtx_unlock} on the same mutex synchronize-with
> +this operation (if this operation succeeds), and all lock/unlock
> +operations on any given mutex form a single total order (similar to
> +the modification order of an atomic).
> +
> +This function returns @code{thrd_success} if the lock was obtained,
> +@code{thrd_busy} if the mutex is already locked, and @code{thrd_error}
> +on failure.
> +@end deftypefun
> +
> +@deftypefun int mtx_unlock (mtx_t *@var{mutex})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{mtx_unlock} unlocks the mutex pointed to by @var{mutex}.  The
> +behavior is undefined if the mutex is not locked by the calling
> +thread.

OK. What about unlocking a lock you already unlocked?

> +
> +This function synchronizes-with subsequent @code{mtx_lock},
> +@code{mtx_trylock}, and @code{mtx_timedlock} calls on the same mutex.
> +All lock/unlock operations on any given mutex form a single total
> +order (similar to the modification order of an atomic).
> +
> +This function returns either @code{thrd_success} or @code{thrd_error}.
> +@end deftypefun
> +
> +@deftypefun void mtx_destroy (mtx_t *@var{mutex})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{mtx_destroy} destroys the mutex pointed to by @var{mutex}.  If
> +there are any threads waiting on the mutex, the behavior is
> +undefined.

OK.

> +@end deftypefun
> +
> +
> +@node ISO C Condition Variables
> +@subsection Condition Variables
> +@cindex condvar
> +@cindex condition variables
> +
> +Mutexes are not the only synchronization mechanisms available.  For
> +some more complex tasks, @theglibc{} also implements @dfn{condition
> +variables}, which allow the programmer to think at a higher level when
> +solving complex synchronization problems.  They are used to
> +synchronize threads waiting on a certain condition to happen.

OK.
> +
> +The fundamental data type for condition variables is the @code{cnd_t}:
> +
> +@deftp {Data Type} cnd_t
> +@standards{C11, threads.h}
> +The @code{cnd_t} uniquely identifies a condition variable object.
> +@end deftp
> +
> +The following functions are used for working with condition variables:
> +
> +@deftypefun int cnd_init (cnd_t *@var{cond})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{cnd_init} initializes a new condition variable, identified by
> +@var{cond}.
> +
> +This function may return @code{thrd_success}, @code{thrd_nomem}, or
> +@code{thrd_error}.
> +@end deftypefun
> +
> +@deftypefun int cnd_signal (cnd_t *@var{cond})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{cnd_signal} unblocks one thread that is currently waiting on the
> +condition variable pointed to by @var{cond}.  If a thread is
> +successfully unblocked, this function returns @code{thrd_success}.  If
> +no threads are blocked, this function does nothing and returns
> +@code{thrd_success}.  Otherwise, this function returns
> +@code{thrd_error}.
> +@end deftypefun

OK.

> +
> +@deftypefun int cnd_broadcast (cnd_t *@var{cond})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{cnd_broadcast} unblocks all the threads that are currently
> +waiting on the condition variable pointed to by @var{cond}.  This
> +function returns @code{thrd_success} on success.  If no threads are
> +blocked, this function does nothing and returns
> +@code{thrd_success}. Otherwise, this function returns
> +@code{thrd_error}.
> +@end deftypefun

OK.

> +
> +@deftypefun int cnd_wait (cnd_t *@var{cond}, mtx_t *@var{mutex})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
> +@code{cnd_wait} atomically unlocks the mutex pointed to by @var{mutex}
> +and blocks on the condition variable pointed to by @var{cond} until
> +the thread is signalled by @code{cnd_signal} or @code{cnd_broadcast}.

s/signalled/signaled/g

> +The mutex is locked again before the function returns.
> +
> +This function returns either @code{thrd_success} or @code{thrd_error}.
> +@end deftypefun
> +
> +@deftypefun int cnd_timedwait (cnd_t *restrict @var{cond}, mtx_t *restrict @var{mutex}, const struct timespec *restrict @var{time_point})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
> +@code{cnd_timedwait} atomically unlocks the mutex pointed to by
> +@var{mutex} and blocks on the condition variable pointed to by
> +@var{cond} until the thread is signalled by @code{cnd_signal} or

s/signalled/signaled/g

> +@code{cnd_broadcast}, or until the calendar time pointed to by
> +@var{time_point} has been reached.  The mutex is locked again before
> +the function returns.
> +
> +As for @code{mtx_timedlock}, since this function takes an absolute
> +time, if a duration is required, the calendar time must be calculated
> +manually.  @xref{Time Basics}, and @ref{Calendar Time}.
> +

OK.

> +This function may return @code{thrd_success}, @code{thrd_nomem}, or
> +@code{thrd_error}.
> +@end deftypefun
> +
> +@deftypefun void cnd_destroy (cnd_t *@var{cond})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{cnd_destroy} destroys the condition variable pointed to by
> +@var{cond}.  If there are threads waiting on @var{cond}, the behavior
> +is undefined.
> +@end deftypefun

OK.

> +
> +
> +@node ISO C Thread-local Storage
> +@subsection Thread-local Storage
> +@cindex thread-local storage
> +
> +@Theglibc{} implements functions to provide @dfn{thread-local
> +storage}, which means each thread can have their own variables that
> +are not visible by other threads.

I would tighten this up a bit like this, since it's less about
visibility and more about storage:
~~~
@Theglibc{} implements functions to provide @dfn{thread-local
storage}. Variables can be defined to have unique storage per-thread,
lifetimes that match the thread lifetime, and destructors that cleanup
the unique per-thread storage.
~~~

> +
> +Several data types and macros exist for working with thread-local
> +storage:
> +
> +@deftp {Data Type} tss_t
> +@standards{C11, threads.h}
> +The @code{tss_t} data type identifies a thread-specific storage
> +object.  Even if shared, every thread will have its own instance of
> +the variable, with different values.
> +@end deftp

OK.

> +
> +@deftp {Data Type} tss_dtor_t
> +@standards{C11, threads.h}
> +The @code{tss_dtor_t} is a function pointer of type @code{void (*)
> +(void *)}, to be used as a thread-specific storage destructor.  The
> +function will be called when the current thread calls @code{thrd_exit}
> +(but never when calling @code{tss_delete} or @code{exit}).
> +@end deftp

OK.

> +
> +@defvr Macro thread_local
> +@standards{C11, threads.h}
> +@code{thread_local} is used to mark a variable with thread storage
> +duration, which means it is created when the thread starts and cleaned
> +up when the thread ends.

OK.

> +
> +@emph{Note:} For C++, C++11 or later is required to get the

s/get/use/g

You "use" a keyword.

> +@code{thread_local} keyword.
> +@end defvr
> +
> +@defvr Macro TSS_DTOR_ITERATIONS
> +@standards{C11, threads.h}
> +@code{TSS_DTOR_ITERATIONS} is an integer constant expression
> +representing the maximum number of times that destructors will be
> +called when a thread terminates.

Suggest a broader explanation:

@code{TSS_DTOR_ITERATIONS} is an integer constant expression
representing the maximum number of iterations over all thread-local
destructors at the time of thread termination. This value provides
a bounded limit to the destruction of thread-local storage e.g.
consider a destructor that creates more thread-local storage.

> +@end defvr
> +
> +The following functions are used to manage thread-local storage:
> +
> +@deftypefun int tss_create (tss_t *@var{tss_key}, tss_dtor_t @var{destructor})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{tss_create} creates a new thread-specific storage key and stores
> +it in the object pointed to by @var{tss_key}.  Although the same key
> +value may be used by different threads, the values bound to the key by
> +@code{tss_set} are maintained on a per-thread basis and persist for
> +the life of the calling thread.
> +
> +If @code{destructor} is not NULL, a destructor function will be set,
> +and called when the thread finishes its execution by calling
> +@code{thrd_exit}.
> +
> +This function returns @code{thrd_success} if @code{tss_key} is
> +successfully set to a unique value for the thread; otherwise,
> +@code{thrd_error} is returned and the value of @code{tss_key} is
> +undefined.
> +@end deftypefun

OK.

> +
> +@deftypefun int tss_set (tss_t @var{tss_key}, void *@var{val})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{tss_set} sets the value of the thread-specific storage
> +identified by @var{tss_key} for the current thread to @var{val}.
> +Different threads may set different values to the same key.

OK.

> +
> +This function returns either @code{thrd_success} or @code{thrd_error}.
> +@end deftypefun
> +
> +@deftypefun {void *} tss_get (tss_t @var{tss_key})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{tss_get} returns the value identified by @var{tss_key} held in
> +thread-specific storage for the current thread.  Different threads may
> +get different values identified by the same key.  On failure,
> +@code{tss_get} returns zero.
> +@end deftypefun

OK.

> +
> +@deftypefun void tss_delete (tss_t @var{tss_key})
> +@standards{C11, threads.h}
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +@code{tss_delete} destroys the thread-specific storage identified by
> +@var{tss_key}.
> +@end deftypefun

OK.

> +
> +
>  @node POSIX Threads
> -@c @node POSIX Threads, Internal Probes, Cryptographic Functions, Top
> -@chapter POSIX Threads
> -@c %MENU% POSIX Threads
> +@section POSIX Threads

OK.

>  @cindex pthreads
>  
> -This chapter describes the @glibcadj{} POSIX Threads implementation.
> +This section describes the @glibcadj{} POSIX Threads implementation.
>  
>  @menu
>  * Thread-specific Data::          Support for creating and
> @@ -14,7 +542,7 @@ This chapter describes the @glibcadj{} POSIX Threads implementation.
>  @end menu
>  
>  @node Thread-specific Data
> -@section Thread-specific Data
> +@subsection Thread-specific Data
>  
>  The @glibcadj{} implements functions to allow users to create and manage
>  data specific to a thread.  Such data may be destroyed at thread exit,
> @@ -71,7 +599,7 @@ Associate the thread-specific @var{value} with @var{key} in the calling thread.
>  
>  
>  @node Non-POSIX Extensions
> -@section Non-POSIX Extensions
> +@subsection Non-POSIX Extensions
>  
>  In addition to implementing the POSIX API for threads, @theglibc{} provides
>  additional functions and interfaces to provide functionality not specified in
> @@ -83,7 +611,7 @@ the standard.
>  @end menu
>  
>  @node Default Thread Attributes
> -@subsection Setting Process-wide defaults for thread attributes
> +@subsubsection Setting Process-wide defaults for thread attributes
>  

OK.

>  @Theglibc{} provides non-standard API functions to set and get the default
>  attributes used in the creation of threads in a process.


-- 
Cheers,
Carlos.

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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h
  2018-07-21  2:11             ` Carlos O'Donell
@ 2018-07-21  6:22               ` Rical Jasan
  2018-07-21 13:40                 ` Adhemerval Zanella
  0 siblings, 1 reply; 80+ messages in thread
From: Rical Jasan @ 2018-07-21  6:22 UTC (permalink / raw)
  To: Carlos O'Donell, Adhemerval Zanella; +Cc: libc-alpha, Florian Weimer

[-- Attachment #1: Type: text/plain, Size: 4901 bytes --]

On 07/20/2018 07:11 PM, Carlos O'Donell wrote:
> On 07/20/2018 08:26 PM, Rical Jasan wrote:
...
>> +This section describes the @glibcadj{} ISO C threads implementation.
>> +To have a deeper understanding of this API, it is strongly recomended
> 
> s/recomended/recommended/g

Fixed.

>> +@deftp {Data Type} thrd_t
>> +@standards{C11, threads.h}
>> +A unique object that identifies a thread unequivocally.
> 
> Suggest:
> A unique object that identifies one thread.
> 
> Do more with less.

I call, and raise you to "a thread".

>> +@item mtx_recursive
>> +@standards{C11, threads.h}
>> +A mutex that supports recursive locking, which means that the owner
>> +thread can lock it more than once without causing deadlock.
> 
> Traditional technical language is "owning thread"
> 
> s/owner thread/owning thread/g

Fixed.

>> +@deftypefun int mtx_init (mtx_t *@var{mutex}, int @var{type})
>> +@standards{C11, threads.h}
>> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
>> +@code{mtx_init} creates a new mutex object with type @var{type}.  The
>> +object pointed to by @var{mutex} is set to the identifier of the newly
>> +created mutex.
>> +
>> +The @code{type} argument may be either @code{mtx_plain} or
>> +@code{mtx_timed}, optionally combined with @code{mtx_recursive}.
> 
> This should be expanded to ensure clarity.
> 
> Suggest:
> ~~~
> The @code{type} argument may be either @code{mtx_plain},
> @code{mtx_timed}, @code{mtx_plain | mtx_recursive}, or 
> @code{mtx_timed | mtx_recursive}.
> ~~~

I turned this into a table.

>> +@deftypefun int mtx_unlock (mtx_t *@var{mutex})
>> +@standards{C11, threads.h}
>> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
>> +@code{mtx_unlock} unlocks the mutex pointed to by @var{mutex}.  The
>> +behavior is undefined if the mutex is not locked by the calling
>> +thread.
> 
> OK. What about unlocking a lock you already unlocked?

I don't know.  The specification is quiet on that point, as well as the
text I was working with.  nptl/mtx_unlock.c in Adhemerval's branch calls
__pthread_mutex_unlock.  In nptl/pthread_mutex_unlock.c, going through
the various tests for the mutex type (most of which result in a call to
lll_unlock or some variant), there are three tests that are conditional
upon "! lll_islocked", and they all return EPERM.  I believe, however,
that is an implementation detail we wouldn't necessarily include in the
manual, so the best I could say here is that it's UB because the spec
doesn't say anything about it.  (I didn't in the new patch, but I can
add that in if you like.)

>> +@deftypefun int cnd_wait (cnd_t *@var{cond}, mtx_t *@var{mutex})
>> +@standards{C11, threads.h}
>> +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
>> +@code{cnd_wait} atomically unlocks the mutex pointed to by @var{mutex}
>> +and blocks on the condition variable pointed to by @var{cond} until
>> +the thread is signalled by @code{cnd_signal} or @code{cnd_broadcast}.
> 
> s/signalled/signaled/g

Fixed.

>> +@deftypefun int cnd_timedwait (cnd_t *restrict @var{cond}, mtx_t *restrict @var{mutex}, const struct timespec *restrict @var{time_point})
>> +@standards{C11, threads.h}
>> +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
>> +@code{cnd_timedwait} atomically unlocks the mutex pointed to by
>> +@var{mutex} and blocks on the condition variable pointed to by
>> +@var{cond} until the thread is signalled by @code{cnd_signal} or
> 
> s/signalled/signaled/g

Fixed.

>> +@Theglibc{} implements functions to provide @dfn{thread-local
>> +storage}, which means each thread can have their own variables that
>> +are not visible by other threads.
> 
> I would tighten this up a bit like this, since it's less about
> visibility and more about storage:
> ~~~
> @Theglibc{} implements functions to provide @dfn{thread-local
> storage}. Variables can be defined to have unique storage per-thread,
> lifetimes that match the thread lifetime, and destructors that cleanup
> the unique per-thread storage.
> ~~~

Fixed.  I joined it into one sentence to bind the explanation a little
more tightly to the @dfn.

>> +@emph{Note:} For C++, C++11 or later is required to get the
> 
> s/get/use/g
> 
> You "use" a keyword.

Fixed.

>> +@defvr Macro TSS_DTOR_ITERATIONS
>> +@standards{C11, threads.h}
>> +@code{TSS_DTOR_ITERATIONS} is an integer constant expression
>> +representing the maximum number of times that destructors will be
>> +called when a thread terminates.
> 
> Suggest a broader explanation:
> 
> @code{TSS_DTOR_ITERATIONS} is an integer constant expression
> representing the maximum number of iterations over all thread-local
> destructors at the time of thread termination. This value provides
> a bounded limit to the destruction of thread-local storage e.g.
> consider a destructor that creates more thread-local storage.

Thanks.  I had largely left that one alone.

Updated patch attached.

Rical

[-- Attachment #2: cthreads-docs-v8.2.patch --]
[-- Type: text/x-patch, Size: 23219 bytes --]

diff --git a/manual/debug.texi b/manual/debug.texi
index f4157e525e..712a42f75c 100644
--- a/manual/debug.texi
+++ b/manual/debug.texi
@@ -1,5 +1,5 @@
 @node Debugging Support
-@c @node Debugging Support, POSIX Threads, Cryptographic Functions, Top
+@c @node Debugging Support, Threads, Cryptographic Functions, Top
 @c %MENU% Functions to help debugging applications
 @chapter Debugging support
 
diff --git a/manual/probes.texi b/manual/probes.texi
index fa6e38f785..ab2a3102bb 100644
--- a/manual/probes.texi
+++ b/manual/probes.texi
@@ -1,5 +1,5 @@
 @node Internal Probes
-@c @node Internal Probes, Tunables, POSIX Threads, Top
+@c @node Internal Probes, Tunables, Threads, Top
 @c %MENU% Probes to monitor libc internal behavior
 @chapter Internal probes
 
diff --git a/manual/threads.texi b/manual/threads.texi
index 769d974d50..87fda7d8e7 100644
--- a/manual/threads.texi
+++ b/manual/threads.texi
@@ -1,10 +1,555 @@
+@node Threads
+@c @node Threads, Internal Probes, Debugging Support, Top
+@c %MENU% Functions, constants, and data types for working with threads
+@chapter Threads
+@cindex threads
+
+This chapter describes functions used for managing threads.
+@Theglibc{} provides two threading implementations: ISO C threads and
+POSIX threads.
+
+@menu
+* ISO C Threads::	Threads based on the ISO C specification.
+* POSIX Threads::	Threads based on the POSIX specification.
+@end menu
+
+
+@node ISO C Threads
+@section ISO C Threads
+@cindex ISO C threads
+@cindex C threads
+@pindex threads.h
+
+This section describes the @glibcadj{} ISO C threads implementation.
+To have a deeper understanding of this API, it is strongly recommended
+to read ISO/IEC 9899:2011, section 7.26, in which ISO C threads were
+originally specified.  All types and function prototypes are declared
+in the header file @file{threads.h}.
+
+@menu
+* ISO C Threads Return Values:: Symbolic constants that represent a
+				function's return value.
+* ISO C Thread Management::	Support for basic threading.
+* Call Once::			Single-call functions and macros.
+* ISO C Mutexes::		A low-level mechanism for mutual exclusion.
+* ISO C Condition Variables::	High-level objects for thread synchronization.
+* ISO C Thread-local Storage::	Functions to support thread-local storage.
+@end menu
+
+
+@node ISO C Threads Return Values
+@subsection Return Values
+
+The ISO C thread specification provides the following enumeration
+constants for return values from functions in the API:
+
+@vtable @code
+@item thrd_timedout
+@standards{C11, threads.h}
+A specified time was reached without acquiring the requested resource,
+usually a mutex or condition variable.
+
+@item thrd_success
+@standards{C11, threads.h}
+The requested operation succeeded.
+
+@item thrd_busy
+@standards{C11, threads.h}
+The requested operation failed because a requested resource is already
+in use.
+
+@item thrd_error
+@standards{C11, threads.h}
+The requested operation failed.
+
+@item thrd_nomem
+@standards{C11, threads.h}
+The requested operation failed because it was unable to allocate
+enough memory.
+@end vtable
+
+
+@node ISO C Thread Management
+@subsection Creation and Control
+@cindex thread creation
+@cindex thread control
+@cindex thread management
+
+@Theglibc{} implements a set of functions that allow the user to easily
+create and use threads.  Additional functionality is provided to control
+the behavior of threads.
+
+The following data types are defined for managing threads:
+
+@deftp {Data Type} thrd_t
+@standards{C11, threads.h}
+A unique object that identifies a thread.
+@end deftp
+
+@deftp {Data Type} thrd_start_t
+@standards{C11, threads.h}
+This data type is an @code{int (*) (void *)} typedef that is passed to
+@code{thrd_create} when creating a new thread.  It should point to the
+first function that thread will run.
+@end deftp
+
+The following functions are used for working with threads:
+
+@deftypefun int thrd_create (thrd_t *@var{thr}, thrd_start_t @var{func}, void *@var{arg})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{thrd_create} creates a new thread that will execute the function
+@var{func}.  The object pointed to by @var{arg} will be used as the
+argument to @var{func}.  If successful, @var{thr} is set to the new
+thread identifier.
+
+This function may return @code{thrd_success}, @code{thrd_nomem}, or
+@code{thrd_error}.
+@end deftypefun
+
+@deftypefun thrd_t thrd_current (void)
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+This function returns the identifier of the calling thread.
+@end deftypefun
+
+@deftypefun int thrd_equal (thrd_t @var{lhs}, thrd_t @var{rhs})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{thrd_equal} checks whether @var{lhs} and @var{rhs} refer to the
+same thread.  If @var{lhs} and @var{rhs} are different threads, this
+function returns @math{0}; otherwise, the return value is non-zero.
+@end deftypefun
+
+@deftypefun int thrd_sleep (const struct timespec *@var{time_point}, struct timespec *@var{remaining})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{thrd_sleep} blocks the execution of the current thread for at
+least until the elapsed time pointed to by @var{time_point} has been
+reached.  This function does not take an absolute time, but a duration
+that the thread is required to be blocked.  @xref{Time Basics}, and
+@ref{Elapsed Time}.
+
+The thread may wake early if a signal that is not ignored is received.
+In such a case, if @code{remaining} is not NULL, the remaining time
+duration is stored in the object pointed to by
+@var{remaining}.
+
+@code{thrd_sleep} returns @math{0} if it blocked for at least the
+amount of time in @code{time_point}, @math{-1} if it was interrupted
+by a signal, or a negative number on failure.
+@end deftypefun
+
+@deftypefun void thrd_yield (void)
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{thrd_yield} provides a hint to the implementation to reschedule
+the execution of the current thread, allowing other threads to run.
+@end deftypefun
+
+@deftypefun {_Noreturn void} thrd_exit (int @var{res})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{thrd_exit} terminates execution of the calling thread and sets
+its result code to @var{res}.
+
+If this function is called from a single-threaded process, the call is
+equivalent to calling @code{exit} with @code{EXIT_SUCCESS}
+(@pxref{Normal Termination}).  Also note that returning from a
+function that started a thread is equivalent to calling
+@code{thrd_exit}.
+@end deftypefun
+
+@deftypefun int thrd_detach (thrd_t @var{thr})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{thrd_detach} detaches the thread identified by @code{thr} from
+the current control thread.  The resources held by the detached thread
+will be freed automatically once the thread exits.  The parent thread
+will never be notified by any @var{thr} signal.
+
+Calling @code{thrd_detach} on a thread that was previously detached or
+joined by another thread results in undefined behavior.
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+@deftypefun int thrd_join (thrd_t @var{thr}, int *@var{res})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{thrd_join} blocks the current thread until the thread identified
+by @code{thr} finishes execution.  If @code{res} is not NULL, the
+result code of the thread is put into the location pointed to by
+@var{res}.  The termination of the thread @dfn{synchronizes-with} the
+completion of this function, meaning both threads have arrived at a
+common point in their execution.
+
+Calling @code{thrd_join} on a thread that was previously detached or
+joined by another thread results in undefined behavior.
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+
+@node Call Once
+@subsection Call Once
+@cindex call once
+@cindex single-call functions
+
+In order to guarantee single access to a function, @theglibc{}
+implements a @dfn{call once function} to ensure a function is only
+called once in the presence of multiple, potentially calling threads.
+
+@deftp {Data Type} once_flag
+@standards{C11, threads.h}
+A complete object type capable of holding a flag used by @code{call_once}.
+@end deftp
+
+@defvr Macro ONCE_FLAG_INIT
+@standards{C11, threads.h}
+This value is used to initialize an object of type @code{once_flag}.
+@end defvr
+
+@deftypefun void call_once (once_flag *@var{flag}, void (*@var{func}) (void))
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{call_once} calls function @var{func} exactly once, even if
+invoked from several threads.  The completion of the function
+@var{func} synchronizes-with all previous or subsequent calls to
+@code{call_once} with the same @code{flag} variable.
+@end deftypefun
+
+
+@node ISO C Mutexes
+@subsection Mutexes
+@cindex mutex
+@cindex mutual exclusion
+
+To have better control of resources and how threads access them,
+@theglibc{} implements a @dfn{mutex} object, which can help avoid race
+conditions and other concurrency issues.  The term ``mutex'' refers to
+mutual exclusion.
+
+The fundamental data type for a mutex is the @code{mtx_t}:
+
+@deftp {Data Type} mtx_t
+@standards{C11, threads.h}
+The @code{mtx_t} data type uniquely identifies a mutex object.
+@end deftp
+
+The ISO C standard defines several types of mutexes.  They are
+represented by the following symbolic constants:
+
+@vtable @code
+@item mtx_plain
+@standards{C11, threads.h}
+A mutex that does not support timeout, or test and return.
+
+@item mtx_recursive
+@standards{C11, threads.h}
+A mutex that supports recursive locking, which means that the owning
+thread can lock it more than once without causing deadlock.
+
+@item mtx_timed
+@standards{C11, threads.h}
+A mutex that supports timeout.
+@end vtable
+
+The following functions are used for working with mutexes:
+
+@deftypefun int mtx_init (mtx_t *@var{mutex}, int @var{type})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{mtx_init} creates a new mutex object with type @var{type}.  The
+object pointed to by @var{mutex} is set to the identifier of the newly
+created mutex.
+
+Not all combinations of mutex types are valid for the @code{type}
+argument.  Valid uses of mutex types for the @code{type} argument are:
+
+@table @code
+@item mtx_plain
+A non-recursive mutex that does not support timeout.
+
+@item mtx_timed
+A non-recursive mutex that does support timeout.
+
+@item mtx_plain | mtx_recursive
+A recursive mutex that does not support timeout.
+
+@item mtx_timed | mtx_recursive
+A recursive mutex that does support timeout.
+@end table
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+@deftypefun int mtx_lock (mtx_t *@var{mutex})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+@code{mtx_lock} blocks the current thread until the mutex pointed to
+by @var{mutex} is locked.  The behavior is undefined if the current
+thread has already locked the mutex and the mutex is not recursive.
+
+Prior calls to @code{mtx_unlock} on the same mutex synchronize-with
+this operation (if this operation succeeds), and all lock/unlock
+operations on any given mutex form a single total order (similar to
+the modification order of an atomic).
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+@deftypefun int mtx_timedlock (mtx_t *restrict @var{mutex}, const struct timespec *restrict @var{time_point})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+@code{mtx_timedlock} blocks the current thread until the mutex pointed
+to by @var{mutex} is locked or until the calendar time pointed to by
+@var{time_point} has been reached.  Since this function takes an
+absolute time, if a duration is required, the calendar time must be
+calculated manually.  @xref{Time Basics}, and @ref{Calendar Time}.
+
+If the current thread has already locked the mutex and the mutex is
+not recursive, or if the mutex does not support timeout, the behavior
+of this function is undefined.
+
+Prior calls to @code{mtx_unlock} on the same mutex synchronize-with
+this operation (if this operation succeeds), and all lock/unlock
+operations on any given mutex form a single total order (similar to
+the modification order of an atomic).
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+@deftypefun int mtx_trylock (mtx_t *@var{mutex})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+@code{mtx_trylock} tries to lock the mutex pointed to by @var{mutex}
+without blocking.  It returns immediately if the mutex is already
+locked.
+
+Prior calls to @code{mtx_unlock} on the same mutex synchronize-with
+this operation (if this operation succeeds), and all lock/unlock
+operations on any given mutex form a single total order (similar to
+the modification order of an atomic).
+
+This function returns @code{thrd_success} if the lock was obtained,
+@code{thrd_busy} if the mutex is already locked, and @code{thrd_error}
+on failure.
+@end deftypefun
+
+@deftypefun int mtx_unlock (mtx_t *@var{mutex})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{mtx_unlock} unlocks the mutex pointed to by @var{mutex}.  The
+behavior is undefined if the mutex is not locked by the calling
+thread.
+
+This function synchronizes-with subsequent @code{mtx_lock},
+@code{mtx_trylock}, and @code{mtx_timedlock} calls on the same mutex.
+All lock/unlock operations on any given mutex form a single total
+order (similar to the modification order of an atomic).
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+@deftypefun void mtx_destroy (mtx_t *@var{mutex})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{mtx_destroy} destroys the mutex pointed to by @var{mutex}.  If
+there are any threads waiting on the mutex, the behavior is
+undefined.
+@end deftypefun
+
+
+@node ISO C Condition Variables
+@subsection Condition Variables
+@cindex condvar
+@cindex condition variables
+
+Mutexes are not the only synchronization mechanisms available.  For
+some more complex tasks, @theglibc{} also implements @dfn{condition
+variables}, which allow the programmer to think at a higher level when
+solving complex synchronization problems.  They are used to
+synchronize threads waiting on a certain condition to happen.
+
+The fundamental data type for condition variables is the @code{cnd_t}:
+
+@deftp {Data Type} cnd_t
+@standards{C11, threads.h}
+The @code{cnd_t} uniquely identifies a condition variable object.
+@end deftp
+
+The following functions are used for working with condition variables:
+
+@deftypefun int cnd_init (cnd_t *@var{cond})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{cnd_init} initializes a new condition variable, identified by
+@var{cond}.
+
+This function may return @code{thrd_success}, @code{thrd_nomem}, or
+@code{thrd_error}.
+@end deftypefun
+
+@deftypefun int cnd_signal (cnd_t *@var{cond})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{cnd_signal} unblocks one thread that is currently waiting on the
+condition variable pointed to by @var{cond}.  If a thread is
+successfully unblocked, this function returns @code{thrd_success}.  If
+no threads are blocked, this function does nothing and returns
+@code{thrd_success}.  Otherwise, this function returns
+@code{thrd_error}.
+@end deftypefun
+
+@deftypefun int cnd_broadcast (cnd_t *@var{cond})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{cnd_broadcast} unblocks all the threads that are currently
+waiting on the condition variable pointed to by @var{cond}.  This
+function returns @code{thrd_success} on success.  If no threads are
+blocked, this function does nothing and returns
+@code{thrd_success}. Otherwise, this function returns
+@code{thrd_error}.
+@end deftypefun
+
+@deftypefun int cnd_wait (cnd_t *@var{cond}, mtx_t *@var{mutex})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+@code{cnd_wait} atomically unlocks the mutex pointed to by @var{mutex}
+and blocks on the condition variable pointed to by @var{cond} until
+the thread is signaled by @code{cnd_signal} or @code{cnd_broadcast}.
+The mutex is locked again before the function returns.
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+@deftypefun int cnd_timedwait (cnd_t *restrict @var{cond}, mtx_t *restrict @var{mutex}, const struct timespec *restrict @var{time_point})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+@code{cnd_timedwait} atomically unlocks the mutex pointed to by
+@var{mutex} and blocks on the condition variable pointed to by
+@var{cond} until the thread is signaled by @code{cnd_signal} or
+@code{cnd_broadcast}, or until the calendar time pointed to by
+@var{time_point} has been reached.  The mutex is locked again before
+the function returns.
+
+As for @code{mtx_timedlock}, since this function takes an absolute
+time, if a duration is required, the calendar time must be calculated
+manually.  @xref{Time Basics}, and @ref{Calendar Time}.
+
+This function may return @code{thrd_success}, @code{thrd_nomem}, or
+@code{thrd_error}.
+@end deftypefun
+
+@deftypefun void cnd_destroy (cnd_t *@var{cond})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{cnd_destroy} destroys the condition variable pointed to by
+@var{cond}.  If there are threads waiting on @var{cond}, the behavior
+is undefined.
+@end deftypefun
+
+
+@node ISO C Thread-local Storage
+@subsection Thread-local Storage
+@cindex thread-local storage
+
+@Theglibc{} implements functions to provide @dfn{thread-local
+storage}, a mechanism by which variables can be defined to have unique
+per-thread storage, lifetimes that match the thread lifetime, and
+destructors that cleanup the unique per-thread storage.
+
+Several data types and macros exist for working with thread-local
+storage:
+
+@deftp {Data Type} tss_t
+@standards{C11, threads.h}
+The @code{tss_t} data type identifies a thread-specific storage
+object.  Even if shared, every thread will have its own instance of
+the variable, with different values.
+@end deftp
+
+@deftp {Data Type} tss_dtor_t
+@standards{C11, threads.h}
+The @code{tss_dtor_t} is a function pointer of type @code{void (*)
+(void *)}, to be used as a thread-specific storage destructor.  The
+function will be called when the current thread calls @code{thrd_exit}
+(but never when calling @code{tss_delete} or @code{exit}).
+@end deftp
+
+@defvr Macro thread_local
+@standards{C11, threads.h}
+@code{thread_local} is used to mark a variable with thread storage
+duration, which means it is created when the thread starts and cleaned
+up when the thread ends.
+
+@emph{Note:} For C++, C++11 or later is required to use the
+@code{thread_local} keyword.
+@end defvr
+
+@defvr Macro TSS_DTOR_ITERATIONS
+@standards{C11, threads.h}
+@code{TSS_DTOR_ITERATIONS} is an integer constant expression
+representing the maximum number of iterations over all thread-local
+destructors at the time of thread termination.  This value provides a
+bounded limit to the destruction of thread-local storage; e.g.,
+consider a destructor that creates more thread-local storage.
+@end defvr
+
+The following functions are used to manage thread-local storage:
+
+@deftypefun int tss_create (tss_t *@var{tss_key}, tss_dtor_t @var{destructor})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{tss_create} creates a new thread-specific storage key and stores
+it in the object pointed to by @var{tss_key}.  Although the same key
+value may be used by different threads, the values bound to the key by
+@code{tss_set} are maintained on a per-thread basis and persist for
+the life of the calling thread.
+
+If @code{destructor} is not NULL, a destructor function will be set,
+and called when the thread finishes its execution by calling
+@code{thrd_exit}.
+
+This function returns @code{thrd_success} if @code{tss_key} is
+successfully set to a unique value for the thread; otherwise,
+@code{thrd_error} is returned and the value of @code{tss_key} is
+undefined.
+@end deftypefun
+
+@deftypefun int tss_set (tss_t @var{tss_key}, void *@var{val})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{tss_set} sets the value of the thread-specific storage
+identified by @var{tss_key} for the current thread to @var{val}.
+Different threads may set different values to the same key.
+
+This function returns either @code{thrd_success} or @code{thrd_error}.
+@end deftypefun
+
+@deftypefun {void *} tss_get (tss_t @var{tss_key})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{tss_get} returns the value identified by @var{tss_key} held in
+thread-specific storage for the current thread.  Different threads may
+get different values identified by the same key.  On failure,
+@code{tss_get} returns zero.
+@end deftypefun
+
+@deftypefun void tss_delete (tss_t @var{tss_key})
+@standards{C11, threads.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+@code{tss_delete} destroys the thread-specific storage identified by
+@var{tss_key}.
+@end deftypefun
+
+
 @node POSIX Threads
-@c @node POSIX Threads, Internal Probes, Cryptographic Functions, Top
-@chapter POSIX Threads
-@c %MENU% POSIX Threads
+@section POSIX Threads
 @cindex pthreads
 
-This chapter describes the @glibcadj{} POSIX Threads implementation.
+This section describes the @glibcadj{} POSIX Threads implementation.
 
 @menu
 * Thread-specific Data::          Support for creating and
@@ -14,7 +559,7 @@ This chapter describes the @glibcadj{} POSIX Threads implementation.
 @end menu
 
 @node Thread-specific Data
-@section Thread-specific Data
+@subsection Thread-specific Data
 
 The @glibcadj{} implements functions to allow users to create and manage
 data specific to a thread.  Such data may be destroyed at thread exit,
@@ -71,7 +616,7 @@ Associate the thread-specific @var{value} with @var{key} in the calling thread.
 
 
 @node Non-POSIX Extensions
-@section Non-POSIX Extensions
+@subsection Non-POSIX Extensions
 
 In addition to implementing the POSIX API for threads, @theglibc{} provides
 additional functions and interfaces to provide functionality not specified in
@@ -83,7 +628,7 @@ the standard.
 @end menu
 
 @node Default Thread Attributes
-@subsection Setting Process-wide defaults for thread attributes
+@subsubsection Setting Process-wide defaults for thread attributes
 
 @Theglibc{} provides non-standard API functions to set and get the default
 attributes used in the creation of threads in a process.

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

* Re: [PATCH v8 0/8] Add support for ISO C threads.h
  2018-07-21  6:22               ` Rical Jasan
@ 2018-07-21 13:40                 ` Adhemerval Zanella
  0 siblings, 0 replies; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-21 13:40 UTC (permalink / raw)
  To: Rical Jasan, Carlos O'Donell; +Cc: libc-alpha, Florian Weimer



On 21/07/2018 03:22, Rical Jasan wrote:
> On 07/20/2018 07:11 PM, Carlos O'Donell wrote:
>> On 07/20/2018 08:26 PM, Rical Jasan wrote:
> ...
>>> +This section describes the @glibcadj{} ISO C threads implementation.
>>> +To have a deeper understanding of this API, it is strongly recomended
>>
>> s/recomended/recommended/g
> 
> Fixed.
> 
>>> +@deftp {Data Type} thrd_t
>>> +@standards{C11, threads.h}
>>> +A unique object that identifies a thread unequivocally.
>>
>> Suggest:
>> A unique object that identifies one thread.
>>
>> Do more with less.
> 
> I call, and raise you to "a thread".
> 
>>> +@item mtx_recursive
>>> +@standards{C11, threads.h}
>>> +A mutex that supports recursive locking, which means that the owner
>>> +thread can lock it more than once without causing deadlock.
>>
>> Traditional technical language is "owning thread"
>>
>> s/owner thread/owning thread/g
> 
> Fixed.
> 
>>> +@deftypefun int mtx_init (mtx_t *@var{mutex}, int @var{type})
>>> +@standards{C11, threads.h}
>>> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
>>> +@code{mtx_init} creates a new mutex object with type @var{type}.  The
>>> +object pointed to by @var{mutex} is set to the identifier of the newly
>>> +created mutex.
>>> +
>>> +The @code{type} argument may be either @code{mtx_plain} or
>>> +@code{mtx_timed}, optionally combined with @code{mtx_recursive}.
>>
>> This should be expanded to ensure clarity.
>>
>> Suggest:
>> ~~~
>> The @code{type} argument may be either @code{mtx_plain},
>> @code{mtx_timed}, @code{mtx_plain | mtx_recursive}, or 
>> @code{mtx_timed | mtx_recursive}.
>> ~~~
> 
> I turned this into a table.
> 
>>> +@deftypefun int mtx_unlock (mtx_t *@var{mutex})
>>> +@standards{C11, threads.h}
>>> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
>>> +@code{mtx_unlock} unlocks the mutex pointed to by @var{mutex}.  The
>>> +behavior is undefined if the mutex is not locked by the calling
>>> +thread.
>>
>> OK. What about unlocking a lock you already unlocked?
> 
> I don't know.  The specification is quiet on that point, as well as the
> text I was working with.  nptl/mtx_unlock.c in Adhemerval's branch calls
> __pthread_mutex_unlock.  In nptl/pthread_mutex_unlock.c, going through
> the various tests for the mutex type (most of which result in a call to
> lll_unlock or some variant), there are three tests that are conditional
> upon "! lll_islocked", and they all return EPERM.  I believe, however,
> that is an implementation detail we wouldn't necessarily include in the
> manual, so the best I could say here is that it's UB because the spec
> doesn't say anything about it.  (I didn't in the new patch, but I can
> add that in if you like.)
> 
>>> +@deftypefun int cnd_wait (cnd_t *@var{cond}, mtx_t *@var{mutex})
>>> +@standards{C11, threads.h}
>>> +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
>>> +@code{cnd_wait} atomically unlocks the mutex pointed to by @var{mutex}
>>> +and blocks on the condition variable pointed to by @var{cond} until
>>> +the thread is signalled by @code{cnd_signal} or @code{cnd_broadcast}.
>>
>> s/signalled/signaled/g
> 
> Fixed.
> 
>>> +@deftypefun int cnd_timedwait (cnd_t *restrict @var{cond}, mtx_t *restrict @var{mutex}, const struct timespec *restrict @var{time_point})
>>> +@standards{C11, threads.h}
>>> +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
>>> +@code{cnd_timedwait} atomically unlocks the mutex pointed to by
>>> +@var{mutex} and blocks on the condition variable pointed to by
>>> +@var{cond} until the thread is signalled by @code{cnd_signal} or
>>
>> s/signalled/signaled/g
> 
> Fixed.
> 
>>> +@Theglibc{} implements functions to provide @dfn{thread-local
>>> +storage}, which means each thread can have their own variables that
>>> +are not visible by other threads.
>>
>> I would tighten this up a bit like this, since it's less about
>> visibility and more about storage:
>> ~~~
>> @Theglibc{} implements functions to provide @dfn{thread-local
>> storage}. Variables can be defined to have unique storage per-thread,
>> lifetimes that match the thread lifetime, and destructors that cleanup
>> the unique per-thread storage.
>> ~~~
> 
> Fixed.  I joined it into one sentence to bind the explanation a little
> more tightly to the @dfn.
> 
>>> +@emph{Note:} For C++, C++11 or later is required to get the
>>
>> s/get/use/g
>>
>> You "use" a keyword.
> 
> Fixed.
> 
>>> +@defvr Macro TSS_DTOR_ITERATIONS
>>> +@standards{C11, threads.h}
>>> +@code{TSS_DTOR_ITERATIONS} is an integer constant expression
>>> +representing the maximum number of times that destructors will be
>>> +called when a thread terminates.
>>
>> Suggest a broader explanation:
>>
>> @code{TSS_DTOR_ITERATIONS} is an integer constant expression
>> representing the maximum number of iterations over all thread-local
>> destructors at the time of thread termination. This value provides
>> a bounded limit to the destruction of thread-local storage e.g.
>> consider a destructor that creates more thread-local storage.
> 
> Thanks.  I had largely left that one alone.
> 
> Updated patch attached.
> 
> Rical
> 

Thanks, I pushed it on my personal branch [1] with you as author.

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

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

* Re: [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions
  2018-02-02 17:04 ` [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions Adhemerval Zanella
  2018-07-06 12:51   ` Florian Weimer
@ 2018-07-24 12:04   ` Adhemerval Zanella
  2018-07-24 16:04     ` Carlos O'Donell
  1 sibling, 1 reply; 80+ messages in thread
From: Adhemerval Zanella @ 2018-07-24 12:04 UTC (permalink / raw)
  To: libc-alpha

Updated patch from Carlos suggestion.  Changes from previous version:

  - Remove an extra mtx_destroy on nptl/Versions.
  - Adjusted the wording on cnd_init static asserts.
  - Add bugzilla entry and adjusted glibc version on CL.

---

This patch adds the cnd_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically cnd_broadcast, cnd_destroy, cnd_init, cnd_signal,
cnd_timedwait, cnd_wait, and required types.

Mostly of the definitions are composed based on POSIX conterparts, and
cnd_t is also based on internal pthreads fields, but with distinct internal
layout to avoid possible issues with code interchange (such as trying to pass
POSIX structure on C11 functions and to avoid inclusion of pthread.h).  The
idea is to make it possible to share POSIX internal implementation for mostly
of the code making adjust where only required.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* conform/data/threads.h-data (cnd_t): New type.
	(cnd_init): New function.
	(cnd_signal): Likewise.
	(cnd_broadcast): Likewise.
	(cnd_wait): Likewise.
	(cnd_timedwait): Likewise.
	(cnd_destroy): Likewise.
	* nptl/Makefile (libpthread-routines): Add cnd_broadcast,
	cnd_destroy, cnd_init, cnd_signal, cnd_timedwait, and cnd_wait
	object.
	* nptl/Versions (libpthread) [GLIBC_2.28]: Likewise.
	* nptl/cnd_broadcast.c: New file.
	* nptl/cnd_destroy.c: Likewise.
	* nptl/cnd_init.c: Likewise.
	* nptl/cnd_signal.c: Likewise.
	* nptl/cnd_timedwait.c: Likewise.
	* nptl/cnd_wait.c: Likewise.
	* sysdeps/nptl/threads.h (cnd_t): New type.
	(cnd_init): New prototype.
	(cnd_signa): Likewise.
	(cnd_broadcast): Likewise.
	(cnd_wait): Likewise.
	(cnd_timedwait): Likewise.
	(cnd_destroy): Likewise.
---
 ChangeLog                   | 26 ++++++++++++++++++++++++++
 conform/data/threads.h-data |  8 ++++++++
 nptl/Makefile               |  3 ++-
 nptl/Versions               |  3 ++-
 nptl/cnd_broadcast.c        | 26 ++++++++++++++++++++++++++
 nptl/cnd_destroy.c          | 26 ++++++++++++++++++++++++++
 nptl/cnd_init.c             | 33 +++++++++++++++++++++++++++++++++
 nptl/cnd_signal.c           | 26 ++++++++++++++++++++++++++
 nptl/cnd_timedwait.c        | 29 +++++++++++++++++++++++++++++
 nptl/cnd_wait.c             | 27 +++++++++++++++++++++++++++
 nptl/threads.h              | 34 ++++++++++++++++++++++++++++++++++
 11 files changed, 239 insertions(+), 2 deletions(-)
 create mode 100644 nptl/cnd_broadcast.c
 create mode 100644 nptl/cnd_destroy.c
 create mode 100644 nptl/cnd_init.c
 create mode 100644 nptl/cnd_signal.c
 create mode 100644 nptl/cnd_timedwait.c
 create mode 100644 nptl/cnd_wait.c

diff --git a/ChangeLog b/ChangeLog
index 1b1d79e..f92f25a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,32 @@
 2018-07-21  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
 	[BZ #14092]
+	* conform/data/threads.h-data (cnd_t): New type.
+	(cnd_init): New function.
+	(cnd_signal): Likewise.
+	(cnd_broadcast): Likewise.
+	(cnd_wait): Likewise.
+	(cnd_timedwait): Likewise.
+	(cnd_destroy): Likewise.
+	* nptl/Makefile (libpthread-routines): Add cnd_broadcast,
+	cnd_destroy, cnd_init, cnd_signal, cnd_timedwait, and cnd_wait
+	object.
+	* nptl/Versions (libpthread) [GLIBC_2.28]: Likewise.
+	* nptl/cnd_broadcast.c: New file.
+	* nptl/cnd_destroy.c: Likewise.
+	* nptl/cnd_init.c: Likewise.
+	* nptl/cnd_signal.c: Likewise.
+	* nptl/cnd_timedwait.c: Likewise.
+	* nptl/cnd_wait.c: Likewise.
+	* sysdeps/nptl/threads.h (cnd_t): New type.
+	(cnd_init): New prototype.
+	(cnd_signa): Likewise.
+	(cnd_broadcast): Likewise.
+	(cnd_wait): Likewise.
+	(cnd_timedwait): Likewise.
+	(cnd_destroy): Likewise.
+
+	[BZ #14092]
 	* conform/data/threads.h-data (ONCE_FLAG_INIT): New macro.
 	(once_flag): New type.
 	(call_once): New function.
diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data
index 70b2fe0..d7c562e 100644
--- a/conform/data/threads.h-data
+++ b/conform/data/threads.h-data
@@ -16,6 +16,7 @@ type thrd_t
 type thrd_start_t
 type mtx_t
 type once_flag
+type cnd_t
 
 function int thrd_create (thrd_t*, thrd_start_t, void*)
 function int thrd_equal (thrd_t, thrd_t)
@@ -35,6 +36,13 @@ function void mtx_destroy (mtx_t*)
 
 function void call_once (once_flag*, void (*)(void))
 
+function int cnd_init (cnd_t*)
+function int cnd_signal (cnd_t*)
+function int cnd_broadcast (cnd_t*)
+function int cnd_wait (cnd_t*, mtx_t*)
+function int cnd_timedwait (cnd_t*, mtx_t*, const struct timespec*)
+function void cnd_destroy (cnd_t*)
+
 #include "time.h-data"
 
 #endif
diff --git a/nptl/Makefile b/nptl/Makefile
index d55d24b..0864aee 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -143,7 +143,8 @@ libpthread-routines = nptl-init nptlfreeres vars events version pt-interp \
 		      pthread_setattr_default_np pthread_getattr_default_np \
 		      thrd_create thrd_detach thrd_exit thrd_join \
 		      mtx_destroy mtx_init mtx_lock mtx_timedlock \
-		      mtx_trylock mtx_unlock call_once
+		      mtx_trylock mtx_unlock call_once cnd_broadcast \
+		      cnd_destroy cnd_init cnd_signal cnd_timedwait cnd_wait
 #		      pthread_setuid pthread_seteuid pthread_setreuid \
 #		      pthread_setresuid \
 #		      pthread_setgid pthread_setegid pthread_setregid \
diff --git a/nptl/Versions b/nptl/Versions
index 0fdba18..9c38d67 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -273,7 +273,8 @@ libpthread {
   GLIBC_2.28 {
     thrd_create; thrd_detach; thrd_exit; thrd_join;
     mtx_init; mtx_lock; mtx_timedlock; mtx_trylock; mtx_unlock; mtx_destroy;
-    call_once;
+    call_once; cnd_broadcast; cnd_destroy; cnd_init; cnd_signal;
+    cnd_timedwait; cnd_wait;
   }
 
   GLIBC_PRIVATE {
diff --git a/nptl/cnd_broadcast.c b/nptl/cnd_broadcast.c
new file mode 100644
index 0000000..889f88e
--- /dev/null
+++ b/nptl/cnd_broadcast.c
@@ -0,0 +1,26 @@
+/* C11 thread conditional broadcast implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+cnd_broadcast (cnd_t *cond)
+{
+  int err_code = __pthread_cond_broadcast ((pthread_cond_t*) cond);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/cnd_destroy.c b/nptl/cnd_destroy.c
new file mode 100644
index 0000000..37df9e9
--- /dev/null
+++ b/nptl/cnd_destroy.c
@@ -0,0 +1,26 @@
+/* C11 threads conditional destroy implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+#include "pthreadP.h"
+
+void
+cnd_destroy (cnd_t *cond)
+{
+  __pthread_cond_destroy ((pthread_cond_t *) cond);
+}
diff --git a/nptl/cnd_init.c b/nptl/cnd_init.c
new file mode 100644
index 0000000..13f0f80
--- /dev/null
+++ b/nptl/cnd_init.c
@@ -0,0 +1,33 @@
+/* C11 thread conditional initialization implementation.
+   Copyright (C) 2018 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 <stdalign.h>
+
+#include "thrd_priv.h"
+
+int
+cnd_init (cnd_t *cond)
+{
+  _Static_assert (sizeof (cnd_t) == sizeof (pthread_cond_t),
+		  "(sizeof (cnd_t) != sizeof (pthread_cond_t)");
+  _Static_assert (alignof (cnd_t) == alignof (pthread_cond_t),
+		  "alignof (cnd_t) != alignof (pthread_cond_t)");
+
+  int err_code = __pthread_cond_init ((pthread_cond_t *)cond, NULL);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/cnd_signal.c b/nptl/cnd_signal.c
new file mode 100644
index 0000000..8ae650b
--- /dev/null
+++ b/nptl/cnd_signal.c
@@ -0,0 +1,26 @@
+/* C11 threads conditional signal implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+cnd_signal (cnd_t *cond)
+{
+  int err_code = __pthread_cond_signal ((pthread_cond_t *) cond);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/cnd_timedwait.c b/nptl/cnd_timedwait.c
new file mode 100644
index 0000000..75358fe
--- /dev/null
+++ b/nptl/cnd_timedwait.c
@@ -0,0 +1,29 @@
+/* C11 threads conditional timed wait implementation.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+cnd_timedwait (cnd_t *restrict cond, mtx_t *restrict mutex,
+	       const struct timespec* restrict time_point)
+{
+  int err_code = __pthread_cond_timedwait ((pthread_cond_t *) cond,
+					   (pthread_mutex_t *) mutex,
+					   time_point);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/cnd_wait.c b/nptl/cnd_wait.c
new file mode 100644
index 0000000..727d9bb
--- /dev/null
+++ b/nptl/cnd_wait.c
@@ -0,0 +1,27 @@
+/* C11 threads conditional wait implementaiton.
+   Copyright (C) 2018 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 "thrd_priv.h"
+
+int
+cnd_wait (cnd_t *cond, mtx_t *mutex)
+{
+  int err_code = __pthread_cond_wait ((pthread_cond_t *) cond,
+				      (pthread_mutex_t *) mutex);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/threads.h b/nptl/threads.h
index 32f7cf8..e46b1b7 100644
--- a/nptl/threads.h
+++ b/nptl/threads.h
@@ -60,6 +60,12 @@ typedef union
   long int __align __LOCK_ALIGNMENT;
 } mtx_t;
 
+typedef union
+{
+  char __size[__SIZEOF_PTHREAD_COND_T];
+  __extension__ long long int __align __LOCK_ALIGNMENT;
+} cnd_t;
+
 /* Threads functions.  */
 
 /* Create a new thread executing the function __FUNC.  Arguments for __FUNC
@@ -140,6 +146,34 @@ extern void mtx_destroy (mtx_t *__mutex);
    All calls must be made with the same __FLAGS object.  */
 extern void call_once (once_flag *__flag, void (*__func)(void));
 
+
+/* Condition variable functions.  */
+
+/* Initialize new condition variable pointed by __COND.  */
+extern int cnd_init (cnd_t *__cond);
+
+/* Unblock one thread that currently waits on condition variable pointed
+   by __COND.  */
+extern int cnd_signal (cnd_t *__cond);
+
+/* Unblock all threads currently waiting on condition variable pointed by
+   __COND.  */
+extern int cnd_broadcast (cnd_t *__cond);
+
+/* Block current thread on the condition variable pointed by __COND.  */
+extern int cnd_wait (cnd_t *__cond, mtx_t *__mutex);
+
+/* Block current thread on the condition variable until condition variable
+   pointed by __COND is signaled or time pointed by __TIME_POINT is
+   reached.  */
+extern int cnd_timedwait (cnd_t *__restrict __cond,
+			  mtx_t *__restrict __mutex,
+			  const struct timespec *__restrict __time_point);
+
+/* Destroy condition variable pointed by __cond and free all of its
+   resources.  */
+extern void cnd_destroy (cnd_t *__COND);
+
 __END_DECLS
 
 #endif /* _THREADS_H */
-- 
2.7.4


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

* Re: [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions
  2018-07-24 12:04   ` Adhemerval Zanella
@ 2018-07-24 16:04     ` Carlos O'Donell
  0 siblings, 0 replies; 80+ messages in thread
From: Carlos O'Donell @ 2018-07-24 16:04 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 07/24/2018 08:04 AM, Adhemerval Zanella wrote:
> Updated patch from Carlos suggestion.  Changes from previous version:
> 
>   - Remove an extra mtx_destroy on nptl/Versions.
>   - Adjusted the wording on cnd_init static asserts.
>   - Add bugzilla entry and adjusted glibc version on CL.
> 
> ---
> 
> This patch adds the cnd_* definitions from C11 threads (ISO/IEC 9899:2011),
> more specifically cnd_broadcast, cnd_destroy, cnd_init, cnd_signal,
> cnd_timedwait, cnd_wait, and required types.
> 

OK.

I confirm going through the standard and I see:

cnd_t, cnd_broadcast, cnd_destroy, cnd_init, cnd_signal, cnd_timedwait,
and cnd_wait as the only condvar functions in use.

The rest of the usage requires the mutex support which has already
been reviewed.

> Mostly of the definitions are composed based on POSIX conterparts, and
> cnd_t is also based on internal pthreads fields, but with distinct internal
> layout to avoid possible issues with code interchange (such as trying to pass
> POSIX structure on C11 functions and to avoid inclusion of pthread.h).  The
> idea is to make it possible to share POSIX internal implementation for mostly
> of the code making adjust where only required.

OK.

> Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
> arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
> microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
> powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
> tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

OK.

> Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
> arm-linux-gnueabhf, and powerpc64le-linux-gnu.
> 
> 	[BZ #14092]
> 	* conform/data/threads.h-data (cnd_t): New type.
> 	(cnd_init): New function.
> 	(cnd_signal): Likewise.
> 	(cnd_broadcast): Likewise.
> 	(cnd_wait): Likewise.
> 	(cnd_timedwait): Likewise.
> 	(cnd_destroy): Likewise.
> 	* nptl/Makefile (libpthread-routines): Add cnd_broadcast,
> 	cnd_destroy, cnd_init, cnd_signal, cnd_timedwait, and cnd_wait
> 	object.
> 	* nptl/Versions (libpthread) [GLIBC_2.28]: Likewise.
> 	* nptl/cnd_broadcast.c: New file.
> 	* nptl/cnd_destroy.c: Likewise.
> 	* nptl/cnd_init.c: Likewise.
> 	* nptl/cnd_signal.c: Likewise.
> 	* nptl/cnd_timedwait.c: Likewise.
> 	* nptl/cnd_wait.c: Likewise.
> 	* sysdeps/nptl/threads.h (cnd_t): New type.
> 	(cnd_init): New prototype.
> 	(cnd_signa): Likewise.
> 	(cnd_broadcast): Likewise.
> 	(cnd_wait): Likewise.
> 	(cnd_timedwait): Likewise.
> 	(cnd_destroy): Likewise.

This looks good to me.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  ChangeLog                   | 26 ++++++++++++++++++++++++++
>  conform/data/threads.h-data |  8 ++++++++
>  nptl/Makefile               |  3 ++-
>  nptl/Versions               |  3 ++-
>  nptl/cnd_broadcast.c        | 26 ++++++++++++++++++++++++++
>  nptl/cnd_destroy.c          | 26 ++++++++++++++++++++++++++
>  nptl/cnd_init.c             | 33 +++++++++++++++++++++++++++++++++
>  nptl/cnd_signal.c           | 26 ++++++++++++++++++++++++++
>  nptl/cnd_timedwait.c        | 29 +++++++++++++++++++++++++++++
>  nptl/cnd_wait.c             | 27 +++++++++++++++++++++++++++
>  nptl/threads.h              | 34 ++++++++++++++++++++++++++++++++++
>  11 files changed, 239 insertions(+), 2 deletions(-)
>  create mode 100644 nptl/cnd_broadcast.c
>  create mode 100644 nptl/cnd_destroy.c
>  create mode 100644 nptl/cnd_init.c
>  create mode 100644 nptl/cnd_signal.c
>  create mode 100644 nptl/cnd_timedwait.c
>  create mode 100644 nptl/cnd_wait.c

This looks good to me. It looks good to me for 2.28.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
 
> diff --git a/ChangeLog b/ChangeLog
> index 1b1d79e..f92f25a 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,6 +1,32 @@
>  2018-07-21  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
>  
>  	[BZ #14092]
> +	* conform/data/threads.h-data (cnd_t): New type.
> +	(cnd_init): New function.
> +	(cnd_signal): Likewise.
> +	(cnd_broadcast): Likewise.
> +	(cnd_wait): Likewise.
> +	(cnd_timedwait): Likewise.
> +	(cnd_destroy): Likewise.
> +	* nptl/Makefile (libpthread-routines): Add cnd_broadcast,
> +	cnd_destroy, cnd_init, cnd_signal, cnd_timedwait, and cnd_wait
> +	object.
> +	* nptl/Versions (libpthread) [GLIBC_2.28]: Likewise.
> +	* nptl/cnd_broadcast.c: New file.
> +	* nptl/cnd_destroy.c: Likewise.
> +	* nptl/cnd_init.c: Likewise.
> +	* nptl/cnd_signal.c: Likewise.
> +	* nptl/cnd_timedwait.c: Likewise.
> +	* nptl/cnd_wait.c: Likewise.
> +	* sysdeps/nptl/threads.h (cnd_t): New type.
> +	(cnd_init): New prototype.
> +	(cnd_signa): Likewise.
> +	(cnd_broadcast): Likewise.
> +	(cnd_wait): Likewise.
> +	(cnd_timedwait): Likewise.
> +	(cnd_destroy): Likewise.
> +

OK.

> +	[BZ #14092]
>  	* conform/data/threads.h-data (ONCE_FLAG_INIT): New macro.
>  	(once_flag): New type.
>  	(call_once): New function.
> diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data
> index 70b2fe0..d7c562e 100644
> --- a/conform/data/threads.h-data
> +++ b/conform/data/threads.h-data
> @@ -16,6 +16,7 @@ type thrd_t
>  type thrd_start_t
>  type mtx_t
>  type once_flag
> +type cnd_t
>  
>  function int thrd_create (thrd_t*, thrd_start_t, void*)
>  function int thrd_equal (thrd_t, thrd_t)
> @@ -35,6 +36,13 @@ function void mtx_destroy (mtx_t*)
>  
>  function void call_once (once_flag*, void (*)(void))
>  
> +function int cnd_init (cnd_t*)
OK.

> +function int cnd_signal (cnd_t*)
OK.

> +function int cnd_broadcast (cnd_t*)
OK.

> +function int cnd_wait (cnd_t*, mtx_t*)
OK.

> +function int cnd_timedwait (cnd_t*, mtx_t*, const struct timespec*)
OK.

> +function void cnd_destroy (cnd_t*)
OK.

> +
>  #include "time.h-data"
>  
>  #endif
> diff --git a/nptl/Makefile b/nptl/Makefile
> index d55d24b..0864aee 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile
> @@ -143,7 +143,8 @@ libpthread-routines = nptl-init nptlfreeres vars events version pt-interp \
>  		      pthread_setattr_default_np pthread_getattr_default_np \
>  		      thrd_create thrd_detach thrd_exit thrd_join \
>  		      mtx_destroy mtx_init mtx_lock mtx_timedlock \
> -		      mtx_trylock mtx_unlock call_once
> +		      mtx_trylock mtx_unlock call_once cnd_broadcast \
> +		      cnd_destroy cnd_init cnd_signal cnd_timedwait cnd_wait

OK. 6 interfaces.

>  #		      pthread_setuid pthread_seteuid pthread_setreuid \
>  #		      pthread_setresuid \
>  #		      pthread_setgid pthread_setegid pthread_setregid \
> diff --git a/nptl/Versions b/nptl/Versions
> index 0fdba18..9c38d67 100644
> --- a/nptl/Versions
> +++ b/nptl/Versions
> @@ -273,7 +273,8 @@ libpthread {
>    GLIBC_2.28 {
>      thrd_create; thrd_detach; thrd_exit; thrd_join;
>      mtx_init; mtx_lock; mtx_timedlock; mtx_trylock; mtx_unlock; mtx_destroy;
> -    call_once;
> +    call_once; cnd_broadcast; cnd_destroy; cnd_init; cnd_signal;
> +    cnd_timedwait; cnd_wait;

OK. 6.

>    }
>  
>    GLIBC_PRIVATE {
> diff --git a/nptl/cnd_broadcast.c b/nptl/cnd_broadcast.c
> new file mode 100644
> index 0000000..889f88e
> --- /dev/null
> +++ b/nptl/cnd_broadcast.c
> @@ -0,0 +1,26 @@
> +/* C11 thread conditional broadcast implementation.
> +   Copyright (C) 2018 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 "thrd_priv.h"
> +
> +int
> +cnd_broadcast (cnd_t *cond)
> +{
> +  int err_code = __pthread_cond_broadcast ((pthread_cond_t*) cond);
> +  return thrd_err_map (err_code);
> +}

OK.

> diff --git a/nptl/cnd_destroy.c b/nptl/cnd_destroy.c
> new file mode 100644
> index 0000000..37df9e9
> --- /dev/null
> +++ b/nptl/cnd_destroy.c
> @@ -0,0 +1,26 @@
> +/* C11 threads conditional destroy implementation.
> +   Copyright (C) 2018 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 "thrd_priv.h"
> +#include "pthreadP.h"
> +
> +void
> +cnd_destroy (cnd_t *cond)
> +{
> +  __pthread_cond_destroy ((pthread_cond_t *) cond);
> +}

OK.

> diff --git a/nptl/cnd_init.c b/nptl/cnd_init.c
> new file mode 100644
> index 0000000..13f0f80
> --- /dev/null
> +++ b/nptl/cnd_init.c
> @@ -0,0 +1,33 @@
> +/* C11 thread conditional initialization implementation.
> +   Copyright (C) 2018 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 <stdalign.h>
> +
> +#include "thrd_priv.h"
> +
> +int
> +cnd_init (cnd_t *cond)
> +{
> +  _Static_assert (sizeof (cnd_t) == sizeof (pthread_cond_t),
> +		  "(sizeof (cnd_t) != sizeof (pthread_cond_t)");
> +  _Static_assert (alignof (cnd_t) == alignof (pthread_cond_t),
> +		  "alignof (cnd_t) != alignof (pthread_cond_t)");

OK.

> +
> +  int err_code = __pthread_cond_init ((pthread_cond_t *)cond, NULL);
> +  return thrd_err_map (err_code);

OK.

> +}
> diff --git a/nptl/cnd_signal.c b/nptl/cnd_signal.c
> new file mode 100644
> index 0000000..8ae650b
> --- /dev/null
> +++ b/nptl/cnd_signal.c
> @@ -0,0 +1,26 @@
> +/* C11 threads conditional signal implementation.
> +   Copyright (C) 2018 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 "thrd_priv.h"
> +
> +int
> +cnd_signal (cnd_t *cond)
> +{
> +  int err_code = __pthread_cond_signal ((pthread_cond_t *) cond);
> +  return thrd_err_map (err_code);
> +}

OK.

> diff --git a/nptl/cnd_timedwait.c b/nptl/cnd_timedwait.c
> new file mode 100644
> index 0000000..75358fe
> --- /dev/null
> +++ b/nptl/cnd_timedwait.c
> @@ -0,0 +1,29 @@
> +/* C11 threads conditional timed wait implementation.
> +   Copyright (C) 2018 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 "thrd_priv.h"
> +
> +int
> +cnd_timedwait (cnd_t *restrict cond, mtx_t *restrict mutex,
> +	       const struct timespec* restrict time_point)
> +{
> +  int err_code = __pthread_cond_timedwait ((pthread_cond_t *) cond,
> +					   (pthread_mutex_t *) mutex,
> +					   time_point);
> +  return thrd_err_map (err_code);

OK.

> +}
> diff --git a/nptl/cnd_wait.c b/nptl/cnd_wait.c
> new file mode 100644
> index 0000000..727d9bb
> --- /dev/null
> +++ b/nptl/cnd_wait.c
> @@ -0,0 +1,27 @@
> +/* C11 threads conditional wait implementaiton.
> +   Copyright (C) 2018 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 "thrd_priv.h"
> +
> +int
> +cnd_wait (cnd_t *cond, mtx_t *mutex)
> +{
> +  int err_code = __pthread_cond_wait ((pthread_cond_t *) cond,
> +				      (pthread_mutex_t *) mutex);
> +  return thrd_err_map (err_code);

OK.

> +}
> diff --git a/nptl/threads.h b/nptl/threads.h
> index 32f7cf8..e46b1b7 100644
> --- a/nptl/threads.h
> +++ b/nptl/threads.h
> @@ -60,6 +60,12 @@ typedef union
>    long int __align __LOCK_ALIGNMENT;
>  } mtx_t;
>  
> +typedef union
> +{
> +  char __size[__SIZEOF_PTHREAD_COND_T];
> +  __extension__ long long int __align __LOCK_ALIGNMENT;
> +} cnd_t;

OK.

> +
>  /* Threads functions.  */
>  
>  /* Create a new thread executing the function __FUNC.  Arguments for __FUNC
> @@ -140,6 +146,34 @@ extern void mtx_destroy (mtx_t *__mutex);
>     All calls must be made with the same __FLAGS object.  */
>  extern void call_once (once_flag *__flag, void (*__func)(void));
>  
> +
> +/* Condition variable functions.  */
> +
> +/* Initialize new condition variable pointed by __COND.  */
> +extern int cnd_init (cnd_t *__cond);
> +
> +/* Unblock one thread that currently waits on condition variable pointed
> +   by __COND.  */
> +extern int cnd_signal (cnd_t *__cond);
> +
> +/* Unblock all threads currently waiting on condition variable pointed by
> +   __COND.  */
> +extern int cnd_broadcast (cnd_t *__cond);
> +
> +/* Block current thread on the condition variable pointed by __COND.  */
> +extern int cnd_wait (cnd_t *__cond, mtx_t *__mutex);
> +
> +/* Block current thread on the condition variable until condition variable
> +   pointed by __COND is signaled or time pointed by __TIME_POINT is
> +   reached.  */
> +extern int cnd_timedwait (cnd_t *__restrict __cond,
> +			  mtx_t *__restrict __mutex,
> +			  const struct timespec *__restrict __time_point);
> +
> +/* Destroy condition variable pointed by __cond and free all of its
> +   resources.  */
> +extern void cnd_destroy (cnd_t *__COND);

OK.

> +
>  __END_DECLS
>  
>  #endif /* _THREADS_H */
> 

Cheers,
Carlos.

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-02-02 17:04 ` [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions Adhemerval Zanella
                     ` (4 preceding siblings ...)
  2018-07-13  9:48   ` Florian Weimer
@ 2018-07-25  7:20   ` Andreas Schwab
  2018-07-25  7:38     ` Florian Weimer
  2018-07-25 10:29     ` Joseph Myers
  5 siblings, 2 replies; 80+ messages in thread
From: Andreas Schwab @ 2018-07-25  7:20 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Feb 02 2018, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> @@ -197,7 +197,8 @@ linknamespace-libs-xsi = $(linknamespace-libs-posix) \
>  			 $(common-objpfx)crypt/libcrypt.a
>  linknamespace-libs-ISO = $(linknamespace-libs-isoc)
>  linknamespace-libs-ISO99 = $(linknamespace-libs-isoc)
> -linknamespace-libs-ISO11 = $(linknamespace-libs-isoc)
> +linknamespace-libs-ISO11 = $(linknamespace-libs-isoc) \
> +			   $(common-objpfx)nptl/libpthread.a
>  linknamespace-libs-XPG4 = $(linknamespace-libs-isoc) \
>  			  $(common-objpfx)crypt/libcrypt.a

You have reverted commit e69d994a63, which breaks --disable-crypt
builds.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-25  7:20   ` Andreas Schwab
@ 2018-07-25  7:38     ` Florian Weimer
  2018-07-25 10:29     ` Joseph Myers
  1 sibling, 0 replies; 80+ messages in thread
From: Florian Weimer @ 2018-07-25  7:38 UTC (permalink / raw)
  To: Andreas Schwab, Adhemerval Zanella; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]

On 07/25/2018 09:20 AM, Andreas Schwab wrote:
> On Feb 02 2018, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
> 
>> @@ -197,7 +197,8 @@ linknamespace-libs-xsi = $(linknamespace-libs-posix) \
>>   			 $(common-objpfx)crypt/libcrypt.a
>>   linknamespace-libs-ISO = $(linknamespace-libs-isoc)
>>   linknamespace-libs-ISO99 = $(linknamespace-libs-isoc)
>> -linknamespace-libs-ISO11 = $(linknamespace-libs-isoc)
>> +linknamespace-libs-ISO11 = $(linknamespace-libs-isoc) \
>> +			   $(common-objpfx)nptl/libpthread.a
>>   linknamespace-libs-XPG4 = $(linknamespace-libs-isoc) \
>>   			  $(common-objpfx)crypt/libcrypt.a
> 
> You have reverted commit e69d994a63, which breaks --disable-crypt
> builds.

Oh.  So we need this fix?

Thanks,
Florian

[-- Attachment #2: conform.patch --]
[-- Type: text/x-patch, Size: 901 bytes --]

Subject: [PATCH] conform: Do not add libcrypt twice in linknamespace tests
To: libc-alpha@sourceware.org

2018-07-25  Florian Weimer  <fweimer@redhat.com>

	* conform/Makefile (linknamespace-libs-XPG4): Do not add libcrypt
	twice.

diff --git a/conform/Makefile b/conform/Makefile
index a0ab70e302..98a9f8ea3e 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -198,8 +198,7 @@ linknamespace-libs-ISO = $(linknamespace-libs-isoc)
 linknamespace-libs-ISO99 = $(linknamespace-libs-isoc)
 linknamespace-libs-ISO11 = $(linknamespace-libs-isoc) \
 			   $(common-objpfx)nptl/libpthread.a
-linknamespace-libs-XPG4 = $(linknamespace-libs-isoc) \
-			  $(common-objpfx)crypt/libcrypt.a
+linknamespace-libs-XPG4 = $(linknamespace-libs-isoc)
 linknamespace-libs-XPG42 = $(linknamespace-libs-XPG4)
 linknamespace-libs-POSIX = $(linknamespace-libs-thr)
 linknamespace-libs-UNIX98 = $(linknamespace-libs-xsi)

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

* Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
  2018-07-25  7:20   ` Andreas Schwab
  2018-07-25  7:38     ` Florian Weimer
@ 2018-07-25 10:29     ` Joseph Myers
  1 sibling, 0 replies; 80+ messages in thread
From: Joseph Myers @ 2018-07-25 10:29 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Adhemerval Zanella, libc-alpha

On Wed, 25 Jul 2018, Andreas Schwab wrote:

> On Feb 02 2018, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
> 
> > @@ -197,7 +197,8 @@ linknamespace-libs-xsi = $(linknamespace-libs-posix) \
> >  			 $(common-objpfx)crypt/libcrypt.a
> >  linknamespace-libs-ISO = $(linknamespace-libs-isoc)
> >  linknamespace-libs-ISO99 = $(linknamespace-libs-isoc)
> > -linknamespace-libs-ISO11 = $(linknamespace-libs-isoc)
> > +linknamespace-libs-ISO11 = $(linknamespace-libs-isoc) \
> > +			   $(common-objpfx)nptl/libpthread.a
> >  linknamespace-libs-XPG4 = $(linknamespace-libs-isoc) \
> >  			  $(common-objpfx)crypt/libcrypt.a
> 
> You have reverted commit e69d994a63, which breaks --disable-crypt
> builds.

Also, the hardcoded reference to $(common-objpfx)nptl/libpthread.a should 
be $(static-thread-library).  As-is, the patch has broken the testsuite 
build for Hurd (not just introduced the expected failures from lack of 
support for C11 threads in HTL).

-- 
Joseph S. Myers
joseph@codesourcery.com

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

end of thread, other threads:[~2018-07-25 10:29 UTC | newest]

Thread overview: 80+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-02 17:04 [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
2018-02-02 17:04 ` [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions Adhemerval Zanella
2018-02-08 13:49   ` Gabriel F. T. Gomes
2018-02-09 10:56     ` Adhemerval Zanella
2018-02-26 12:28       ` Gabriel F. T. Gomes
2018-07-06 12:46   ` Florian Weimer
2018-07-10 19:26     ` Adhemerval Zanella
2018-07-11 15:49       ` Szabolcs Nagy
2018-07-11 16:24         ` Adhemerval Zanella
2018-07-12 12:18           ` Florian Weimer
2018-07-12 17:38             ` Adhemerval Zanella
2018-07-13  7:03               ` Florian Weimer
2018-07-12 16:46   ` Florian Weimer
2018-07-12 17:52     ` Adhemerval Zanella
2018-07-12 18:24       ` Florian Weimer
2018-07-12 19:19         ` Adhemerval Zanella
2018-07-12 19:26           ` Florian Weimer
2018-07-12 19:41             ` Adhemerval Zanella
2018-07-12 19:32       ` Adhemerval Zanella
2018-07-12 19:35         ` Florian Weimer
2018-07-12 19:43           ` Adhemerval Zanella
2018-07-13  9:45   ` Florian Weimer
2018-07-13 12:59     ` Adhemerval Zanella
2018-07-13 13:04       ` Florian Weimer
2018-07-13 13:18         ` Adhemerval Zanella
2018-07-13 13:21           ` Florian Weimer
2018-07-13  9:48   ` Florian Weimer
2018-07-25  7:20   ` Andreas Schwab
2018-07-25  7:38     ` Florian Weimer
2018-07-25 10:29     ` Joseph Myers
2018-02-02 17:04 ` [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions Adhemerval Zanella
2018-07-06 12:51   ` Florian Weimer
2018-07-10 12:35     ` Adhemerval Zanella
2018-07-12 18:39       ` Florian Weimer
2018-07-12 20:30         ` Adhemerval Zanella
2018-07-12 20:38           ` Florian Weimer
2018-07-13 13:08             ` Adhemerval Zanella
2018-07-13 13:10               ` Florian Weimer
2018-07-24 12:04   ` Adhemerval Zanella
2018-07-24 16:04     ` Carlos O'Donell
2018-02-02 17:04 ` [PATCH v8 3/8] nptl: Add C11 threads call_once functions Adhemerval Zanella
2018-07-13  9:32   ` Florian Weimer
2018-02-02 17:04 ` [PATCH v8 4/8] nptl: Add C11 threads cnd_* functions Adhemerval Zanella
2018-02-02 17:04 ` [PATCH v8 5/8] nptl: Add C11 threads tss_* functions Adhemerval Zanella
2018-07-12 16:48   ` Florian Weimer
2018-07-12 20:32     ` Adhemerval Zanella
2018-07-12 20:37       ` Florian Weimer
2018-02-02 17:04 ` [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads Adhemerval Zanella
2018-07-13  9:50   ` Florian Weimer
2018-07-13 15:49     ` Adhemerval Zanella
2018-07-13 17:49       ` Florian Weimer
2018-07-13 18:47         ` Adhemerval Zanella
2018-07-13 19:56           ` Florian Weimer
2018-07-13 21:09             ` Adhemerval Zanella
2018-07-14 13:50               ` Florian Weimer
2018-07-18 17:40         ` Joseph Myers
2018-07-18 20:02           ` Adhemerval Zanella
2018-07-18 21:19           ` Florian Weimer
2018-02-02 17:04 ` [PATCH v8 7/8] nptl: Add test cases for ISO " Adhemerval Zanella
2018-07-13  9:31   ` Florian Weimer
2018-07-13 13:10     ` Adhemerval Zanella
2018-07-13 13:11       ` Florian Weimer
2018-07-13 13:29         ` Adhemerval Zanella
2018-07-17 13:53           ` Adhemerval Zanella
2018-02-02 17:04 ` [PATCH v8 8/8] Add manual documentation for threads.h Adhemerval Zanella
2018-06-27 13:39 ` [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
2018-07-19 17:46   ` Adhemerval Zanella
2018-07-19 18:43     ` Carlos O'Donell
2018-07-19 19:12       ` Rical Jasan
2018-07-19 19:58         ` Adhemerval Zanella
2018-07-21  0:26           ` Rical Jasan
2018-07-21  2:11             ` Carlos O'Donell
2018-07-21  6:22               ` Rical Jasan
2018-07-21 13:40                 ` Adhemerval Zanella
2018-07-19 21:26       ` Joseph Myers
2018-07-20 12:32         ` Adhemerval Zanella
2018-07-20 13:22           ` Rical Jasan
2018-07-20 13:54             ` Rical Jasan
2018-07-20 14:04               ` Carlos O'Donell
2018-07-20 15:02             ` [PATCH v8 0/8] Add support for ISO C threads.h [thrd_exit] Rical Jasan

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