Add memalign() and valloc() overrides.
If memalign() and/or valloc() are present on the system, override them in order to avoid mixed allocator usage.
This commit is contained in:
parent
a09f55c87d
commit
6a0d2918ce
@ -710,6 +710,14 @@ if test "x${enable_tls}" = "x0" ; then
|
|||||||
AC_DEFINE_UNQUOTED([NO_TLS], [ ])
|
AC_DEFINE_UNQUOTED([NO_TLS], [ ])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
dnl ============================================================================
|
||||||
|
dnl Check for allocator-related functions that should be wrapped.
|
||||||
|
|
||||||
|
AC_CHECK_FUNC([memalign],
|
||||||
|
[AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN])])
|
||||||
|
AC_CHECK_FUNC([valloc],
|
||||||
|
[AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC])])
|
||||||
|
|
||||||
dnl ============================================================================
|
dnl ============================================================================
|
||||||
dnl Darwin-related configuration.
|
dnl Darwin-related configuration.
|
||||||
|
|
||||||
|
@ -98,6 +98,13 @@
|
|||||||
*/
|
*/
|
||||||
#undef JEMALLOC_IVSALLOC
|
#undef JEMALLOC_IVSALLOC
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define overrides for non-standard allocator-related functions if they
|
||||||
|
* are present on the system.
|
||||||
|
*/
|
||||||
|
#undef JEMALLOC_OVERRIDE_MEMALIGN
|
||||||
|
#undef JEMALLOC_OVERRIDE_VALLOC
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings.
|
* Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings.
|
||||||
*/
|
*/
|
||||||
|
@ -1145,6 +1145,45 @@ JEMALLOC_P(free)(void *ptr)
|
|||||||
* End malloc(3)-compatible functions.
|
* End malloc(3)-compatible functions.
|
||||||
*/
|
*/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
/*
|
||||||
|
* Begin non-standard override functions.
|
||||||
|
*
|
||||||
|
* These overrides are omitted if the JEMALLOC_PREFIX is defined, since the
|
||||||
|
* entire point is to avoid accidental mixed allocator usage.
|
||||||
|
*/
|
||||||
|
#ifndef JEMALLOC_PREFIX
|
||||||
|
|
||||||
|
#ifdef JEMALLOC_OVERRIDE_MEMALIGN
|
||||||
|
JEMALLOC_ATTR(malloc)
|
||||||
|
JEMALLOC_ATTR(visibility("default"))
|
||||||
|
void *
|
||||||
|
JEMALLOC_P(memalign)(size_t alignment, size_t size)
|
||||||
|
{
|
||||||
|
void *ret;
|
||||||
|
|
||||||
|
posix_memalign(&ret, alignment, size);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JEMALLOC_OVERRIDE_VALLOC
|
||||||
|
JEMALLOC_ATTR(malloc)
|
||||||
|
JEMALLOC_ATTR(visibility("default"))
|
||||||
|
void *
|
||||||
|
JEMALLOC_P(valloc)(size_t size)
|
||||||
|
{
|
||||||
|
void *ret;
|
||||||
|
|
||||||
|
posix_memalign(&ret, PAGE_SIZE, size);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* JEMALLOC_PREFIX */
|
||||||
|
/*
|
||||||
|
* End non-standard override functions.
|
||||||
|
*/
|
||||||
|
/******************************************************************************/
|
||||||
/*
|
/*
|
||||||
* Begin non-standard functions.
|
* Begin non-standard functions.
|
||||||
*/
|
*/
|
||||||
@ -1240,6 +1279,7 @@ iallocm(size_t size, size_t alignment, bool zero)
|
|||||||
return (imalloc(size));
|
return (imalloc(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JEMALLOC_ATTR(nonnull(1))
|
||||||
JEMALLOC_ATTR(visibility("default"))
|
JEMALLOC_ATTR(visibility("default"))
|
||||||
int
|
int
|
||||||
JEMALLOC_P(allocm)(void **ptr, size_t *rsize, size_t size, int flags)
|
JEMALLOC_P(allocm)(void **ptr, size_t *rsize, size_t size, int flags)
|
||||||
@ -1297,6 +1337,7 @@ OOM:
|
|||||||
return (ALLOCM_ERR_OOM);
|
return (ALLOCM_ERR_OOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JEMALLOC_ATTR(nonnull(1))
|
||||||
JEMALLOC_ATTR(visibility("default"))
|
JEMALLOC_ATTR(visibility("default"))
|
||||||
int
|
int
|
||||||
JEMALLOC_P(rallocm)(void **ptr, size_t *rsize, size_t size, size_t extra,
|
JEMALLOC_P(rallocm)(void **ptr, size_t *rsize, size_t size, size_t extra,
|
||||||
@ -1369,6 +1410,7 @@ OOM:
|
|||||||
return (ALLOCM_ERR_OOM);
|
return (ALLOCM_ERR_OOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JEMALLOC_ATTR(nonnull(1))
|
||||||
JEMALLOC_ATTR(visibility("default"))
|
JEMALLOC_ATTR(visibility("default"))
|
||||||
int
|
int
|
||||||
JEMALLOC_P(sallocm)(const void *ptr, size_t *rsize, int flags)
|
JEMALLOC_P(sallocm)(const void *ptr, size_t *rsize, int flags)
|
||||||
@ -1389,6 +1431,7 @@ JEMALLOC_P(sallocm)(const void *ptr, size_t *rsize, int flags)
|
|||||||
return (ALLOCM_SUCCESS);
|
return (ALLOCM_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JEMALLOC_ATTR(nonnull(1))
|
||||||
JEMALLOC_ATTR(visibility("default"))
|
JEMALLOC_ATTR(visibility("default"))
|
||||||
int
|
int
|
||||||
JEMALLOC_P(dallocm)(void *ptr, int flags)
|
JEMALLOC_P(dallocm)(void *ptr, int flags)
|
||||||
|
Loading…
Reference in New Issue
Block a user