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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/memory/jemalloc/src/test/jemalloc_test.h.in	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +/*
     1.5 + * This header should be included by tests, rather than directly including
     1.6 + * jemalloc/jemalloc.h, because --with-install-suffix may cause the header to
     1.7 + * have a different name.
     1.8 + */
     1.9 +#include "jemalloc/jemalloc@install_suffix@.h"
    1.10 +#include "jemalloc/internal/jemalloc_internal.h"
    1.11 +
    1.12 +/* Abstraction layer for threading in tests */
    1.13 +#ifdef _WIN32
    1.14 +#include <windows.h>
    1.15 +
    1.16 +typedef HANDLE je_thread_t;
    1.17 +
    1.18 +void
    1.19 +je_thread_create(je_thread_t *thread, void *(*proc)(void *), void *arg)
    1.20 +{
    1.21 +	LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc;
    1.22 +	*thread = CreateThread(NULL, 0, routine, arg, 0, NULL);
    1.23 +	if (*thread == NULL) {
    1.24 +		malloc_printf("Error in CreateThread()\n");
    1.25 +		exit(1);
    1.26 +	}
    1.27 +}
    1.28 +
    1.29 +void
    1.30 +je_thread_join(je_thread_t thread, void **ret)
    1.31 +{
    1.32 +	WaitForSingleObject(thread, INFINITE);
    1.33 +}
    1.34 +
    1.35 +#else
    1.36 +#include <pthread.h>
    1.37 +
    1.38 +typedef pthread_t je_thread_t;
    1.39 +
    1.40 +void
    1.41 +je_thread_create(je_thread_t *thread, void *(*proc)(void *), void *arg)
    1.42 +{
    1.43 +
    1.44 +	if (pthread_create(thread, NULL, proc, arg) != 0) {
    1.45 +		malloc_printf("Error in pthread_create()\n");
    1.46 +		exit(1);
    1.47 +	}
    1.48 +}
    1.49 +
    1.50 +void
    1.51 +je_thread_join(je_thread_t thread, void **ret)
    1.52 +{
    1.53 +
    1.54 +	pthread_join(thread, ret);
    1.55 +}
    1.56 +#endif

mercurial