diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2017-06-27 11:00:05 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2018-07-24 14:07:12 -0300 |
commit | 78d401327f3bcbb06f5d6b388a967cae2ab42b43 (patch) | |
tree | 2241a9edf529879956e37a5bec9200225435d906 /nptl/threads.h | |
parent | 918311a3a3c7679f40e2e95fcaa120f8c74ef479 (diff) | |
download | glibc-78d401327f3bcbb06f5d6b388a967cae2ab42b43.tar.gz glibc-78d401327f3bcbb06f5d6b388a967cae2ab42b43.tar.xz glibc-78d401327f3bcbb06f5d6b388a967cae2ab42b43.zip |
nptl: Add C11 threads tss_* functions
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, 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 (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.28]: 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.
Diffstat (limited to 'nptl/threads.h')
-rw-r--r-- | nptl/threads.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/nptl/threads.h b/nptl/threads.h index e46b1b7f32..9800f93aa7 100644 --- a/nptl/threads.h +++ b/nptl/threads.h @@ -27,6 +27,14 @@ __BEGIN_DECLS #include <bits/pthreadtypes-arch.h> #include <bits/types/struct_timespec.h> +#ifndef __cplusplus +# define thread_local _Thread_local +#endif + +#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*); @@ -174,6 +182,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 */ |