aboutsummaryrefslogtreecommitdiff
path: root/examples/redis-unstable/deps/jemalloc/test/src/thd.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/redis-unstable/deps/jemalloc/test/src/thd.c')
-rw-r--r--examples/redis-unstable/deps/jemalloc/test/src/thd.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/redis-unstable/deps/jemalloc/test/src/thd.c b/examples/redis-unstable/deps/jemalloc/test/src/thd.c
new file mode 100644
index 0000000..9a15eab
--- /dev/null
+++ b/examples/redis-unstable/deps/jemalloc/test/src/thd.c
@@ -0,0 +1,34 @@
1#include "test/jemalloc_test.h"
2
3#ifdef _WIN32
4void
5thd_create(thd_t *thd, void *(*proc)(void *), void *arg) {
6 LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc;
7 *thd = CreateThread(NULL, 0, routine, arg, 0, NULL);
8 if (*thd == NULL) {
9 test_fail("Error in CreateThread()\n");
10 }
11}
12
13void
14thd_join(thd_t thd, void **ret) {
15 if (WaitForSingleObject(thd, INFINITE) == WAIT_OBJECT_0 && ret) {
16 DWORD exit_code;
17 GetExitCodeThread(thd, (LPDWORD) &exit_code);
18 *ret = (void *)(uintptr_t)exit_code;
19 }
20}
21
22#else
23void
24thd_create(thd_t *thd, void *(*proc)(void *), void *arg) {
25 if (pthread_create(thd, NULL, proc, arg) != 0) {
26 test_fail("Error in pthread_create()\n");
27 }
28}
29
30void
31thd_join(thd_t thd, void **ret) {
32 pthread_join(thd, ret);
33}
34#endif