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.

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

mercurial