1#include "test/jemalloc_test.h"
2
3#ifdef _WIN32
4void
5thd_create(thd_t *thd, void *(*proc)(void *), void *arg)
6{
7	LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc;
8	*thd = CreateThread(NULL, 0, routine, arg, 0, NULL);
9	if (*thd == NULL)
10		test_fail("Error in CreateThread()\n");
11}
12
13void
14thd_join(thd_t thd, void **ret)
15{
16	if (WaitForSingleObject(thd, INFINITE) == WAIT_OBJECT_0 && ret) {
17		DWORD exit_code;
18		GetExitCodeThread(thd, (LPDWORD) &exit_code);
19		*ret = (void *)(uintptr_t)exit_code;
20	}
21}
22
23#else
24void
25thd_create(thd_t *thd, void *(*proc)(void *), void *arg)
26{
27	if (pthread_create(thd, NULL, proc, arg) != 0)
28		test_fail("Error in pthread_create()\n");
29}
30
31void
32thd_join(thd_t thd, void **ret)
33{
34	pthread_join(thd, ret);
35}
36#endif
37