1 #include "test/jemalloc_test.h"
2 
3 #ifdef _WIN32
4 void
thd_create(thd_t * thd,void * (* proc)(void *),void * arg)5 thd_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 
13 void
thd_join(thd_t thd,void ** ret)14 thd_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
23 void
thd_create(thd_t * thd,void * (* proc)(void *),void * arg)24 thd_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 
30 void
thd_join(thd_t thd,void ** ret)31 thd_join(thd_t thd, void **ret) {
32 	pthread_join(thd, ret);
33 }
34 #endif
35