summaryrefslogtreecommitdiff
path: root/test/src/thd.c
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2014-01-22 11:11:22 -0800
committerJason Evans <jasone@canonware.com>2014-01-22 11:11:22 -0800
commitcc47dde16203a6ae7eb685b53e1ae501f3869bc6 (patch)
tree74e81d65651b2ca7e294a857797dda6635177454 /test/src/thd.c
parent0135fb806e4137dc9cdf152541926a2bc95e33f0 (diff)
parent798a48103014aabf8afb3d7efff90399a466dd8c (diff)
downloadjemalloc-3.5.0.tar.gz
Merge branch 'dev'3.5.0
Diffstat (limited to 'test/src/thd.c')
-rw-r--r--test/src/thd.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/src/thd.c b/test/src/thd.c
new file mode 100644
index 00000000..233242a1
--- /dev/null
+++ b/test/src/thd.c
@@ -0,0 +1,35 @@
+#include "test/jemalloc_test.h"
+
+#ifdef _WIN32
+void
+thd_create(thd_t *thd, void *(*proc)(void *), void *arg)
+{
+ LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc;
+ *thd = CreateThread(NULL, 0, routine, arg, 0, NULL);
+ if (*thd == NULL)
+ test_fail("Error in CreateThread()\n");
+}
+
+void
+thd_join(thd_t thd, void **ret)
+{
+
+ WaitForSingleObject(thd, INFINITE);
+}
+
+#else
+void
+thd_create(thd_t *thd, void *(*proc)(void *), void *arg)
+{
+
+ if (pthread_create(thd, NULL, proc, arg) != 0)
+ test_fail("Error in pthread_create()\n");
+}
+
+void
+thd_join(thd_t thd, void **ret)
+{
+
+ pthread_join(thd, ret);
+}
+#endif