summaryrefslogtreecommitdiff
path: root/src/thread/tss_create.c
diff options
context:
space:
mode:
authorJens Gustedt <Jens.Gustedt@inria.fr>2014-09-06 21:32:53 -0400
committerRich Felker <dalias@aerifal.cx>2014-09-06 21:38:04 -0400
commite16f70f45210294321a88f23c85ac45046577adc (patch)
tree57372bee85877809503cd09dd9b79f0da6e3fc48 /src/thread/tss_create.c
parentb7cf71a190813590860af25b32532b6c360ac502 (diff)
downloadmusl-e16f70f45210294321a88f23c85ac45046577adc.tar.gz
add C11 thread functions operating on tss_t and once_flag
These all have POSIX equivalents, but aside from tss_get, they all have minor changes to the signature or return value and thus need to exist as separate functions.
Diffstat (limited to 'src/thread/tss_create.c')
-rw-r--r--src/thread/tss_create.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/thread/tss_create.c b/src/thread/tss_create.c
new file mode 100644
index 00000000..251d22b9
--- /dev/null
+++ b/src/thread/tss_create.c
@@ -0,0 +1,11 @@
+#include <threads.h>
+
+int __pthread_key_create(tss_t *, void (*)(void *));
+
+int tss_create(tss_t *tss, tss_dtor_t dtor)
+{
+ /* Different error returns are possible. C glues them together into
+ * just failure notification. Can't be optimized to a tail call,
+ * unless thrd_error equals EAGAIN. */
+ return __pthread_key_create(tss, dtor) ? thrd_error : thrd_success;
+}