2013-12-13 06:41:02 +08:00
|
|
|
#include "test/jemalloc_test.h"
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
void
|
2017-01-16 08:56:30 +08:00
|
|
|
thd_create(thd_t *thd, void *(*proc)(void *), void *arg) {
|
2013-12-13 06:41:02 +08:00
|
|
|
LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc;
|
|
|
|
*thd = CreateThread(NULL, 0, routine, arg, 0, NULL);
|
2017-01-16 08:56:30 +08:00
|
|
|
if (*thd == NULL) {
|
2013-12-13 06:41:02 +08:00
|
|
|
test_fail("Error in CreateThread()\n");
|
2017-01-16 08:56:30 +08:00
|
|
|
}
|
2013-12-13 06:41:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-01-16 08:56:30 +08:00
|
|
|
thd_join(thd_t thd, void **ret) {
|
2014-05-29 08:03:00 +08:00
|
|
|
if (WaitForSingleObject(thd, INFINITE) == WAIT_OBJECT_0 && ret) {
|
|
|
|
DWORD exit_code;
|
|
|
|
GetExitCodeThread(thd, (LPDWORD) &exit_code);
|
|
|
|
*ret = (void *)(uintptr_t)exit_code;
|
|
|
|
}
|
2013-12-13 06:41:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
void
|
2017-01-16 08:56:30 +08:00
|
|
|
thd_create(thd_t *thd, void *(*proc)(void *), void *arg) {
|
|
|
|
if (pthread_create(thd, NULL, proc, arg) != 0) {
|
2013-12-13 06:41:02 +08:00
|
|
|
test_fail("Error in pthread_create()\n");
|
2017-01-16 08:56:30 +08:00
|
|
|
}
|
2013-12-13 06:41:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-01-16 08:56:30 +08:00
|
|
|
thd_join(thd_t thd, void **ret) {
|
2013-12-13 06:41:02 +08:00
|
|
|
pthread_join(thd, ret);
|
|
|
|
}
|
|
|
|
#endif
|