memory/jemalloc/src/test/jemalloc_test.h.in

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 * This header should be included by tests, rather than directly including
michael@0 3 * jemalloc/jemalloc.h, because --with-install-suffix may cause the header to
michael@0 4 * have a different name.
michael@0 5 */
michael@0 6 #include "jemalloc/jemalloc@install_suffix@.h"
michael@0 7 #include "jemalloc/internal/jemalloc_internal.h"
michael@0 8
michael@0 9 /* Abstraction layer for threading in tests */
michael@0 10 #ifdef _WIN32
michael@0 11 #include <windows.h>
michael@0 12
michael@0 13 typedef HANDLE je_thread_t;
michael@0 14
michael@0 15 void
michael@0 16 je_thread_create(je_thread_t *thread, void *(*proc)(void *), void *arg)
michael@0 17 {
michael@0 18 LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc;
michael@0 19 *thread = CreateThread(NULL, 0, routine, arg, 0, NULL);
michael@0 20 if (*thread == NULL) {
michael@0 21 malloc_printf("Error in CreateThread()\n");
michael@0 22 exit(1);
michael@0 23 }
michael@0 24 }
michael@0 25
michael@0 26 void
michael@0 27 je_thread_join(je_thread_t thread, void **ret)
michael@0 28 {
michael@0 29 WaitForSingleObject(thread, INFINITE);
michael@0 30 }
michael@0 31
michael@0 32 #else
michael@0 33 #include <pthread.h>
michael@0 34
michael@0 35 typedef pthread_t je_thread_t;
michael@0 36
michael@0 37 void
michael@0 38 je_thread_create(je_thread_t *thread, void *(*proc)(void *), void *arg)
michael@0 39 {
michael@0 40
michael@0 41 if (pthread_create(thread, NULL, proc, arg) != 0) {
michael@0 42 malloc_printf("Error in pthread_create()\n");
michael@0 43 exit(1);
michael@0 44 }
michael@0 45 }
michael@0 46
michael@0 47 void
michael@0 48 je_thread_join(je_thread_t thread, void **ret)
michael@0 49 {
michael@0 50
michael@0 51 pthread_join(thread, ret);
michael@0 52 }
michael@0 53 #endif

mercurial