]> pd.if.org Git - pdclib.old/blobdiff - opt/pthreads/tss_get.c
pthread c11 threading backend: add support for thread specific data
[pdclib.old] / opt / pthreads / tss_get.c
diff --git a/opt/pthreads/tss_get.c b/opt/pthreads/tss_get.c
new file mode 100644 (file)
index 0000000..cff00ea
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef REGTEST
+#include <threads.h>
+#include <pthread.h>
+
+void *tss_get(tss_t key)
+{
+    return pthread_getspecific(key);
+}
+#endif
+
+#ifdef TEST
+#include <_PDCLIB_test.h>
+
+#ifndef REGTEST
+static tss_t key;
+static char v;
+#endif
+
+int main( void )
+{
+#ifndef REGTEST
+    TESTCASE(tss_create(&key, NULL) == thrd_success);
+    TESTCASE(tss_get(key) == NULL);
+    TESTCASE(tss_set(key, &v) == thrd_success);
+    TESTCASE(tss_get(key) == &v);
+    tss_delete(key);
+#endif
+    return TEST_RESULTS;
+}
+
+#endif