diff options
author | Jason Evans <je@fb.com> | 2013-12-12 22:41:02 (GMT) |
---|---|---|
committer | Jason Evans <je@fb.com> | 2013-12-12 22:41:02 (GMT) |
commit | 0f4f1efd94d33a4bbf766d3d4e7e349fa7c0d3b9 (patch) | |
tree | 8880cd7c807260d0e585ca1b1c263342758d9574 /test/src/thd.c | |
parent | 19609724f9dce1ac644b6cbf89acb740319eb498 (diff) | |
download | jemalloc-0f4f1efd94d33a4bbf766d3d4e7e349fa7c0d3b9.zip jemalloc-0f4f1efd94d33a4bbf766d3d4e7e349fa7c0d3b9.tar.gz jemalloc-0f4f1efd94d33a4bbf766d3d4e7e349fa7c0d3b9.tar.bz2 |
Add mq (message queue) to test infrastructure.
Add mtx (mutex) to test infrastructure, in order to avoid bootstrapping
complications that would result from directly using malloc_mutex.
Rename test infrastructure's thread abstraction from je_thread to thd.
Fix some header ordering issues.
Diffstat (limited to 'test/src/thd.c')
-rw-r--r-- | test/src/thd.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/src/thd.c b/test/src/thd.c new file mode 100644 index 0000000..233242a --- /dev/null +++ b/test/src/thd.c @@ -0,0 +1,35 @@ +#include "test/jemalloc_test.h" + +#ifdef _WIN32 +void +thd_create(thd_t *thd, void *(*proc)(void *), void *arg) +{ + LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc; + *thd = CreateThread(NULL, 0, routine, arg, 0, NULL); + if (*thd == NULL) + test_fail("Error in CreateThread()\n"); +} + +void +thd_join(thd_t thd, void **ret) +{ + + WaitForSingleObject(thd, INFINITE); +} + +#else +void +thd_create(thd_t *thd, void *(*proc)(void *), void *arg) +{ + + if (pthread_create(thd, NULL, proc, arg) != 0) + test_fail("Error in pthread_create()\n"); +} + +void +thd_join(thd_t thd, void **ret) +{ + + pthread_join(thd, ret); +} +#endif |