1 #define JEMALLOC_WITNESS_C_
2 #include "jemalloc/internal/jemalloc_preamble.h"
3 #include "jemalloc/internal/jemalloc_internal_includes.h"
5 #include "jemalloc/internal/assert.h"
6 #include "jemalloc/internal/malloc_io.h"
9 witness_init(witness_t *witness, const char *name, witness_rank_t rank,
10 witness_comp_t *comp, void *opaque) {
14 witness->opaque = opaque;
18 witness_lock_error_impl(const witness_list_t *witnesses,
19 const witness_t *witness) {
22 malloc_printf("<jemalloc>: Lock rank order reversal:");
23 ql_foreach(w, witnesses, link) {
24 malloc_printf(" %s(%u)", w->name, w->rank);
26 malloc_printf(" %s(%u)\n", witness->name, witness->rank);
29 witness_lock_error_t *JET_MUTABLE witness_lock_error = witness_lock_error_impl;
32 witness_owner_error_impl(const witness_t *witness) {
33 malloc_printf("<jemalloc>: Should own %s(%u)\n", witness->name,
37 witness_owner_error_t *JET_MUTABLE witness_owner_error =
38 witness_owner_error_impl;
41 witness_not_owner_error_impl(const witness_t *witness) {
42 malloc_printf("<jemalloc>: Should not own %s(%u)\n", witness->name,
46 witness_not_owner_error_t *JET_MUTABLE witness_not_owner_error =
47 witness_not_owner_error_impl;
50 witness_depth_error_impl(const witness_list_t *witnesses,
51 witness_rank_t rank_inclusive, unsigned depth) {
54 malloc_printf("<jemalloc>: Should own %u lock%s of rank >= %u:", depth,
55 (depth != 1) ? "s" : "", rank_inclusive);
56 ql_foreach(w, witnesses, link) {
57 malloc_printf(" %s(%u)", w->name, w->rank);
62 witness_depth_error_t *JET_MUTABLE witness_depth_error =
63 witness_depth_error_impl;
66 witnesses_cleanup(witness_tsd_t *witness_tsd) {
67 witness_assert_lockless(witness_tsd_tsdn(witness_tsd));
73 witness_prefork(witness_tsd_t *witness_tsd) {
77 witness_tsd->forking = true;
81 witness_postfork_parent(witness_tsd_t *witness_tsd) {
85 witness_tsd->forking = false;
89 witness_postfork_child(witness_tsd_t *witness_tsd) {
93 #ifndef JEMALLOC_MUTEX_INIT_CB
94 witness_list_t *witnesses;
96 witnesses = &witness_tsd->witnesses;
99 witness_tsd->forking = false;