diff options
Diffstat (limited to 'src/witness.c')
| -rw-r--r-- | src/witness.c | 120 |
1 files changed, 42 insertions, 78 deletions
diff --git a/src/witness.c b/src/witness.c index c3a65f7..f42b72a 100644 --- a/src/witness.c +++ b/src/witness.c @@ -1,23 +1,22 @@ -#define JEMALLOC_WITNESS_C_ -#include "jemalloc/internal/jemalloc_internal.h" +#define JEMALLOC_WITNESS_C_ +#include "jemalloc/internal/jemalloc_preamble.h" +#include "jemalloc/internal/jemalloc_internal_includes.h" + +#include "jemalloc/internal/assert.h" +#include "jemalloc/internal/malloc_io.h" void witness_init(witness_t *witness, const char *name, witness_rank_t rank, - witness_comp_t *comp) -{ - + witness_comp_t *comp, void *opaque) { witness->name = name; witness->rank = rank; witness->comp = comp; + witness->opaque = opaque; } -#ifdef JEMALLOC_JET -#undef witness_lock_error -#define witness_lock_error JEMALLOC_N(n_witness_lock_error) -#endif -void -witness_lock_error(const witness_list_t *witnesses, const witness_t *witness) -{ +static void +witness_lock_error_impl(const witness_list_t *witnesses, + const witness_t *witness) { witness_t *w; malloc_printf("<jemalloc>: Lock rank order reversal:"); @@ -27,55 +26,28 @@ witness_lock_error(const witness_list_t *witnesses, const witness_t *witness) malloc_printf(" %s(%u)\n", witness->name, witness->rank); abort(); } -#ifdef JEMALLOC_JET -#undef witness_lock_error -#define witness_lock_error JEMALLOC_N(witness_lock_error) -witness_lock_error_t *witness_lock_error = JEMALLOC_N(n_witness_lock_error); -#endif - -#ifdef JEMALLOC_JET -#undef witness_owner_error -#define witness_owner_error JEMALLOC_N(n_witness_owner_error) -#endif -void -witness_owner_error(const witness_t *witness) -{ +witness_lock_error_t *JET_MUTABLE witness_lock_error = witness_lock_error_impl; +static void +witness_owner_error_impl(const witness_t *witness) { malloc_printf("<jemalloc>: Should own %s(%u)\n", witness->name, witness->rank); abort(); } -#ifdef JEMALLOC_JET -#undef witness_owner_error -#define witness_owner_error JEMALLOC_N(witness_owner_error) -witness_owner_error_t *witness_owner_error = JEMALLOC_N(n_witness_owner_error); -#endif - -#ifdef JEMALLOC_JET -#undef witness_not_owner_error -#define witness_not_owner_error JEMALLOC_N(n_witness_not_owner_error) -#endif -void -witness_not_owner_error(const witness_t *witness) -{ +witness_owner_error_t *JET_MUTABLE witness_owner_error = + witness_owner_error_impl; +static void +witness_not_owner_error_impl(const witness_t *witness) { malloc_printf("<jemalloc>: Should not own %s(%u)\n", witness->name, witness->rank); abort(); } -#ifdef JEMALLOC_JET -#undef witness_not_owner_error -#define witness_not_owner_error JEMALLOC_N(witness_not_owner_error) -witness_not_owner_error_t *witness_not_owner_error = - JEMALLOC_N(n_witness_not_owner_error); -#endif +witness_not_owner_error_t *JET_MUTABLE witness_not_owner_error = + witness_not_owner_error_impl; -#ifdef JEMALLOC_JET -#undef witness_depth_error -#define witness_depth_error JEMALLOC_N(n_witness_depth_error) -#endif -void -witness_depth_error(const witness_list_t *witnesses, +static void +witness_depth_error_impl(const witness_list_t *witnesses, witness_rank_t rank_inclusive, unsigned depth) { witness_t *w; @@ -87,50 +59,42 @@ witness_depth_error(const witness_list_t *witnesses, malloc_printf("\n"); abort(); } -#ifdef JEMALLOC_JET -#undef witness_depth_error -#define witness_depth_error JEMALLOC_N(witness_depth_error) -witness_depth_error_t *witness_depth_error = JEMALLOC_N(n_witness_depth_error); -#endif +witness_depth_error_t *JET_MUTABLE witness_depth_error = + witness_depth_error_impl; void -witnesses_cleanup(tsd_t *tsd) -{ - - witness_assert_lockless(tsd_tsdn(tsd)); +witnesses_cleanup(witness_tsd_t *witness_tsd) { + witness_assert_lockless(witness_tsd_tsdn(witness_tsd)); /* Do nothing. */ } void -witness_fork_cleanup(tsd_t *tsd) -{ - - /* Do nothing. */ -} - -void -witness_prefork(tsd_t *tsd) -{ - - tsd_witness_fork_set(tsd, true); +witness_prefork(witness_tsd_t *witness_tsd) { + if (!config_debug) { + return; + } + witness_tsd->forking = true; } void -witness_postfork_parent(tsd_t *tsd) -{ - - tsd_witness_fork_set(tsd, false); +witness_postfork_parent(witness_tsd_t *witness_tsd) { + if (!config_debug) { + return; + } + witness_tsd->forking = false; } void -witness_postfork_child(tsd_t *tsd) -{ +witness_postfork_child(witness_tsd_t *witness_tsd) { + if (!config_debug) { + return; + } #ifndef JEMALLOC_MUTEX_INIT_CB witness_list_t *witnesses; - witnesses = tsd_witnessesp_get(tsd); + witnesses = &witness_tsd->witnesses; ql_new(witnesses); #endif - tsd_witness_fork_set(tsd, false); + witness_tsd->forking = false; } |
