Stop using glibc malloc hooks

glibc deprecated malloc hooks in 2011 and will be removing them soon.
These hooks aren't safe and aren't necessary when the malloc API is
fully exported.
This commit is contained in:
Tulio Magno Quites Machado Filho 2016-08-08 13:50:10 -03:00 committed by Aliaksey Kandratsenka
parent c92f0ed089
commit 7822b5b0b9
2 changed files with 0 additions and 44 deletions

View File

@ -456,16 +456,6 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([#if defined(__GNUC__) && ((__GNUC__ < 4) || (__
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])])
# glibc's __malloc_hook/etc were declared volatile starting in glibc 2.14
AC_MSG_CHECKING([if __malloc_hook is declared volatile])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <malloc.h>
void* (* volatile __malloc_hook)(size_t, const void*) = 0;],)],
[AC_DEFINE(MALLOC_HOOK_MAYBE_VOLATILE, volatile,
Define to 'volatile' if __malloc_hook is declared volatile)
AC_MSG_RESULT([yes])],
[AC_DEFINE(MALLOC_HOOK_MAYBE_VOLATILE, )
AC_MSG_RESULT([no])])
# Nanosleep requires extra libraries on some architectures (solaris).
# This sets NANOSLEEP_LIBS. nanosleep doesn't exist on mingw, which
# is fine for us because we don't compile libspinlock, which uses it.

View File

@ -86,40 +86,6 @@ extern "C" {
#endif // #if defined(__GNUC__) && !defined(__MACH__)
// We also have to hook libc malloc. While our work with weak symbols
// should make sure libc malloc is never called in most situations, it
// can be worked around by shared libraries with the DEEPBIND
// environment variable set. The below hooks libc to call our malloc
// routines even in that situation. In other situations, this hook
// should never be called.
extern "C" {
static void* glibc_override_malloc(size_t size, const void *caller) {
return tc_malloc(size);
}
static void* glibc_override_realloc(void *ptr, size_t size,
const void *caller) {
return tc_realloc(ptr, size);
}
static void glibc_override_free(void *ptr, const void *caller) {
tc_free(ptr);
}
static void* glibc_override_memalign(size_t align, size_t size,
const void *caller) {
return tc_memalign(align, size);
}
void* (* MALLOC_HOOK_MAYBE_VOLATILE __malloc_hook)(size_t, const void*)
= &glibc_override_malloc;
void* (* MALLOC_HOOK_MAYBE_VOLATILE __realloc_hook)(void*, size_t, const void*)
= &glibc_override_realloc;
void (* MALLOC_HOOK_MAYBE_VOLATILE __free_hook)(void*, const void*)
= &glibc_override_free;
void* (* MALLOC_HOOK_MAYBE_VOLATILE __memalign_hook)(size_t,size_t, const void*)
= &glibc_override_memalign;
} // extern "C"
// No need to write ReplaceSystemAlloc(); one of the #includes above
// did it for us.