thd.c revision 0f4f1efd94d33a4bbf766d3d4e7e349fa7c0d3b9
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
17	WaitForSingleObject(thd, INFINITE);
18}
19
20#else
21void
22thd_create(thd_t *thd, void *(*proc)(void *), void *arg)
23{
24
25	if (pthread_create(thd, NULL, proc, arg) != 0)
26		test_fail("Error in pthread_create()\n");
27}
28
29void
30thd_join(thd_t thd, void **ret)
31{
32
33	pthread_join(thd, ret);
34}
35#endif
36