]> pd.if.org Git - pdclib/blobdiff - platform/win32/functions/threads/tss_get.c
win32: initial pass at thread support
[pdclib] / platform / win32 / functions / threads / tss_get.c
diff --git a/platform/win32/functions/threads/tss_get.c b/platform/win32/functions/threads/tss_get.c
new file mode 100644 (file)
index 0000000..b0a4441
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef REGTEST\r
+#include <threads.h>\r
+#include <windows.h>\r
+\r
+void *tss_get(tss_t key)\r
+{\r
+    return TlsGetValue(key->_Key);\r
+}\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+#ifndef REGTEST\r
+static tss_t key;\r
+static char v;\r
+#endif\r
+\r
+// Todo: make a thread and test destruction!\r
+\r
+int main( void )\r
+{\r
+#ifndef REGTEST\r
+    TESTCASE(tss_create(&key, NULL) == thrd_success);\r
+    TESTCASE(tss_get(key) == NULL);\r
+    TESTCASE(tss_set(key, &v) == thrd_success);\r
+    TESTCASE(tss_get(key) == &v);\r
+    tss_delete(key);\r
+#endif\r
+    return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file