glibc/sysdeps
Adhemerval Zanella ce7528f637 nptl: Add C11 threads thrd_* functions
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 and to handle expected standard return codes.  It is a
     cancellation entrypoint to be consistent with both thrd_join and
     cnd_{timed}wait.

  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,
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/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.28]): 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.
	* sysdeps/unix/sysdep.h (INTERNAL_SYSCALL_CANCEL): New macro.
	* 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.
	* include/threads.h: Likewise.
2018-07-24 14:06:45 -03:00
..
aarch64 aarch64,falkor: Use vector registers for memcpy 2018-06-29 22:45:59 +05:30
alpha Mark _init and _fini as hidden [BZ #23145] 2018-06-08 10:28:52 -07:00
arm Mark _init and _fini as hidden [BZ #23145] 2018-06-08 10:28:52 -07:00
generic x86: Support IBT and SHSTK in Intel CET [BZ #21598] 2018-07-16 14:08:27 -07:00
gnu hurd: Fix shmid_ds's shm_segsz field type 2018-06-02 21:52:43 +02:00
hppa Mark _init and _fini as hidden [BZ #23145] 2018-06-08 10:28:52 -07:00
htl hurd: Fix missing __pthread_get_cleanup_stack symbol 2018-06-16 10:52:04 +02:00
hurd hurd: Fix installed-headers tests 2018-07-20 03:28:08 +02:00
i386 i386: Use _CET_NOTRACK in memset-sse2-rep.S 2018-07-18 08:04:12 -07:00
ia64 Mark _init and _fini as hidden [BZ #23145] 2018-06-08 10:28:52 -07:00
ieee754 ldbl-128ibm-compat: Add printf_size 2018-07-02 10:51:01 -03:00
init_array sysdeps/init_array: Add PREINIT_FUNCTION to crti.S 2018-01-29 10:22:26 -08:00
m68k m68k: Reorganize log1p and significand implementations 2018-06-22 21:34:28 -03:00
mach check-execstack: Permit sysdeps to xfail some libs 2018-07-20 03:28:14 +02:00
microblaze Mark _init and _fini as hidden [BZ #23145] 2018-06-08 10:28:52 -07:00
mips Mark _init and _fini as hidden [BZ #23145] 2018-06-08 10:28:52 -07:00
nios2 Mark _init and _fini as hidden [BZ #23145] 2018-06-08 10:28:52 -07:00
nptl libc: Extend __libc_freeres framework (Bug 23329). 2018-06-29 22:39:06 -04:00
posix Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251) 2018-06-26 13:22:53 -03:00
powerpc powerpc64: Always restore TOC on longjmp [BZ #21895] 2018-07-16 16:08:41 -03:00
pthread hurd: fix sigevent's sigev_notify_attributes field type 2018-04-19 21:43:44 +02:00
riscv elf: Unify symbol address run-time calculation [BZ #19818] 2018-04-04 23:09:37 +01:00
s390 Mark _init and _fini as hidden [BZ #23145] 2018-06-08 10:28:52 -07:00
sh Mark _init and _fini as hidden [BZ #23145] 2018-06-08 10:28:52 -07:00
sparc Mark _init and _fini as hidden [BZ #23145] 2018-06-08 10:28:52 -07:00
unix nptl: Add C11 threads thrd_* functions 2018-07-24 14:06:45 -03:00
wordsize-32 Use libc_hidden_* for strtoumax (bug 15105). 2018-02-28 14:16:21 +00:00
wordsize-64 Use libc_hidden_* for strtoumax (bug 15105). 2018-02-28 14:16:21 +00:00
x86 Add <bits/indirect-return.h> 2018-07-24 07:55:47 -07:00
x86_64 x86-64: Add endbr64 to tst-quadmod[12].S 2018-07-24 05:12:14 -07:00