summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/kit/thread.c45
-rw-r--r--source/kit/thread.h24
-rw-r--r--source/test/unittests/thread.test.c18
3 files changed, 0 insertions, 87 deletions
diff --git a/source/kit/thread.c b/source/kit/thread.c
deleted file mode 100644
index 66ff050..0000000
--- a/source/kit/thread.c
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "thread.h"
-
-#ifdef _MSC_VER
-# include "atomic.h"
-
-# include <stdlib.h>
-# include <windows.h>
-
-typedef struct {
- HANDLE thread;
- kit_thread_routine_ routine;
- void *user_data;
- void *return_value;
-} thread_data;
-
-DWORD __stdcall run_thread_(void *p) {
- thread_data *data = (thread_data *) p;
- data->return_value = data->routine(data->user_data);
-}
-
-int pthread_create(pthread_t *new_thread, void *attrs,
- kit_thread_routine_ routine, void *user_data) {
- thread_data *data = (thread_data *) malloc(sizeof(thread_data));
- if (data == NULL)
- return -1;
- data->routine = routine;
- data->user_data = user_data;
- data->thread = CreateThread(NULL, 0, run_thread_, data, 0, NULL);
- if (data->thread == NULL)
- return -1;
- if (new_thread != NULL)
- *new_thread = data;
- return 0;
-}
-
-void *pthread_join(pthread_t thread, void *return_value) {
- thread_data *data = (thread_data *) thread;
- if (data == NULL || data->thread == NULL)
- return (void *) 0;
- WaitForSingleObject(data->thread, INFINITE);
- void *return_value = data->return_value;
- free(data);
- return return_value;
-}
-#endif
diff --git a/source/kit/thread.h b/source/kit/thread.h
deleted file mode 100644
index 0fab0c8..0000000
--- a/source/kit/thread.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef KIT_THREAD_H
-#define KIT_THREAD_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _MSC_VER
-# include "pthread.h"
-#else
-typedef void *(*kit_thread_routine_)(void *);
-typedef void *pthread_t;
-
-int pthread_create(pthread_t *new_thread, void *attrs,
- kit_thread_routine_ routine, void *user_data);
-
-void *pthread_join(pthread_t thread, void *return_value);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/source/test/unittests/thread.test.c b/source/test/unittests/thread.test.c
deleted file mode 100644
index fed564b..0000000
--- a/source/test/unittests/thread.test.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "../../kit/thread.h"
-
-#define KIT_TEST_FILE thread
-#include "../../kit_test/test.h"
-
-static void *test_thread_fn(void *data) {
- ptrdiff_t *value = (ptrdiff_t *) data;
- return (void *) (*value + 20);
-}
-
-TEST("run thread") {
- pthread_t t;
- ptrdiff_t value = 22;
- pthread_create(&t, NULL, test_thread_fn, &value);
- void *result;
- pthread_join(t, &result);
- REQUIRE((ptrdiff_t) result == 42);
-}