thd.c revision 1.1.1.1
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 35