]> pd.if.org Git - pdclib/blobdiff - platform/win32/functions/threads/tss_delete.c
win32: initial pass at thread support
[pdclib] / platform / win32 / functions / threads / tss_delete.c
diff --git a/platform/win32/functions/threads/tss_delete.c b/platform/win32/functions/threads/tss_delete.c
new file mode 100644 (file)
index 0000000..57a43fd
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef REGTEST\r
+#include <windows.h>\r
+#include <threads.h>\r
+#include <stdlib.h>\r
+\r
+extern struct _PDCLIB_tss * _PDCLIB_tss_first;\r
+void tss_delete( tss_t key )\r
+{\r
+    struct _PDCLIB_tss * prev = NULL;\r
+    struct _PDCLIB_tss * cur  = _PDCLIB_tss_first;\r
+    while(cur) {\r
+        if(cur == key) {\r
+            if(prev) {\r
+                prev->_Next = key->_Next;\r
+            } else {\r
+                _PDCLIB_tss_first = key->_Next;\r
+            }\r
+\r
+            TlsFree(key->_Key);\r
+            free(key);\r
+            return;\r
+        }\r
+    }\r
+\r
+    // Not actually a TSS key\r
+    abort();\r
+}\r
+#endif\r
+\r
+#ifdef TEST\r
+#include <_PDCLIB_test.h>\r
+\r
+/* Tested in tss_get.c */\r
+int main( void )\r
+{\r
+    return TEST_RESULTS;\r
+}\r
+\r
+#endif
\ No newline at end of file