mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-24 13:53:11 +00:00
Test for availability of malloc hooks via autoconf
__*_hook() is glibc, but on at least one glibc platform (homebrew), the __GLIBC__ define isn't set correctly and we miss being able to use these hooks. Do a feature test for it during configuration so that we enable it anywhere the hooks are actually available.
This commit is contained in:
committed by
Jason Evans
parent
602c8e0971
commit
3e24afa28e
31
configure.ac
31
configure.ac
@@ -1340,6 +1340,37 @@ if test "x${enable_zone_allocator}" = "x1" ; then
|
||||
AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
|
||||
fi
|
||||
|
||||
dnl ============================================================================
|
||||
dnl Check for glibc malloc hooks
|
||||
|
||||
JE_COMPILABLE([glibc malloc hook], [
|
||||
#include <stddef.h>
|
||||
|
||||
extern void (* __free_hook)(void *ptr);
|
||||
extern void *(* __malloc_hook)(size_t size);
|
||||
extern void *(* __realloc_hook)(void *ptr, size_t size);
|
||||
], [
|
||||
void *ptr = 0L;
|
||||
if (__malloc_hook) ptr = __malloc_hook(1);
|
||||
if (__realloc_hook) ptr = __realloc_hook(ptr, 2);
|
||||
if (__free_hook && ptr) __free_hook(ptr);
|
||||
], [je_cv_glibc_malloc_hook])
|
||||
if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then
|
||||
AC_DEFINE([JEMALLOC_GLIBC_MALLOC_HOOK], [ ])
|
||||
fi
|
||||
|
||||
JE_COMPILABLE([glibc memalign hook], [
|
||||
#include <stddef.h>
|
||||
|
||||
extern void *(* __memalign_hook)(size_t alignment, size_t size);
|
||||
], [
|
||||
void *ptr = 0L;
|
||||
if (__memalign_hook) ptr = __memalign_hook(16, 7);
|
||||
], [je_cv_glibc_memalign_hook])
|
||||
if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then
|
||||
AC_DEFINE([JEMALLOC_GLIBC_MEMALIGN_HOOK], [ ])
|
||||
fi
|
||||
|
||||
dnl ============================================================================
|
||||
dnl Check for typedefs, structures, and compiler characteristics.
|
||||
AC_HEADER_STDBOOL
|
||||
|
||||
Reference in New Issue
Block a user