1 #include "test/jemalloc_test.h" 2 3 #ifdef _WIN32 4 void 5 thd_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 13 void 14 thd_join(thd_t thd, void **ret) 15 { 16 17 if (WaitForSingleObject(thd, INFINITE) == WAIT_OBJECT_0 && ret) { 18 DWORD exit_code; 19 GetExitCodeThread(thd, (LPDWORD) &exit_code); 20 *ret = (void *)(uintptr_t)exit_code; 21 } 22 } 23 24 #else 25 void 26 thd_create(thd_t *thd, void *(*proc)(void *), void *arg) 27 { 28 29 if (pthread_create(thd, NULL, proc, arg) != 0) 30 test_fail("Error in pthread_create()\n"); 31 } 32 33 void 34 thd_join(thd_t thd, void **ret) 35 { 36 37 pthread_join(thd, ret); 38 } 39 #endif 40