summaryrefslogtreecommitdiff
path: root/nptl/tss_create.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2017-06-27 11:00:05 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2018-07-24 14:07:12 -0300
commit78d401327f3bcbb06f5d6b388a967cae2ab42b43 (patch)
tree2241a9edf529879956e37a5bec9200225435d906 /nptl/tss_create.c
parent918311a3a3c7679f40e2e95fcaa120f8c74ef479 (diff)
downloadglibc-78d401327f3bcbb06f5d6b388a967cae2ab42b43.tar.gz
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/tss_create.c')
-rw-r--r--nptl/tss_create.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/nptl/tss_create.c b/nptl/tss_create.c
new file mode 100644
index 0000000000..c1b148c1f4
--- /dev/null
+++ b/nptl/tss_create.c
@@ -0,0 +1,31 @@
+/* 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),
+ "sizeof (tss_t) != sizeof (pthread_key_t)");
+ _Static_assert (TSS_DTOR_ITERATIONS == PTHREAD_DESTRUCTOR_ITERATIONS,
+ "TSS_DTOR_ITERATIONS != PTHREAD_DESTRUCTOR_ITERATIONS");
+
+ int err_code = __pthread_key_create (tss_id, destructor);
+ return thrd_err_map (err_code);
+}