mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-05-26 23:06:30 +03:00
Add hooking functionality
This allows us to hook chosen functions and do interesting things there (in particular: reentrancy checking).
This commit is contained in:
parent
36bd90b962
commit
0a0fcd3e6a
19 changed files with 183 additions and 11 deletions
12
src/hooks.c
Normal file
12
src/hooks.c
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
/*
|
||||
* The hooks are a little bit screwy -- they're not genuinely exported in the
|
||||
* sense that we want them available to end-users, but we do want them visible
|
||||
* from outside the generated library, so that we can use them in test code.
|
||||
*/
|
||||
JEMALLOC_EXPORT
|
||||
void (*hooks_arena_new_hook)() = NULL;
|
||||
|
||||
JEMALLOC_EXPORT
|
||||
void (*hooks_libc_hook)() = NULL;
|
||||
|
|
@ -8,7 +8,14 @@
|
|||
#endif
|
||||
|
||||
#ifdef JEMALLOC_PROF_LIBGCC
|
||||
/*
|
||||
* We have a circular dependency -- jemalloc_internal.h tells us if we should
|
||||
* use libgcc's unwinding functionality, but after we've included that, we've
|
||||
* already hooked _Unwind_Backtrace. We'll temporarily disable hooking.
|
||||
*/
|
||||
#undef _Unwind_Backtrace
|
||||
#include <unwind.h>
|
||||
#define _Unwind_Backtrace JEMALLOC_HOOK(_Unwind_Backtrace, hooks_libc_hook)
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -149,6 +149,15 @@ _tls_callback(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* We need to be able to say "read" here (in the "pragma section"), but have
|
||||
* hooked "read". We won't read for the rest of the file, so we can get away
|
||||
* with unhooking.
|
||||
*/
|
||||
#ifdef read
|
||||
# undef read
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# ifdef _M_IX86
|
||||
# pragma comment(linker, "/INCLUDE:__tls_used")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue