1 #define JEMALLOC_WITNESS_C_
2 #include "jemalloc/internal/jemalloc_internal.h"
5 witness_init(witness_t
*witness
, const char *name
, witness_rank_t rank
,
15 #undef witness_lock_error
16 #define witness_lock_error JEMALLOC_N(n_witness_lock_error)
19 witness_lock_error(const witness_list_t
*witnesses
, const witness_t
*witness
)
23 malloc_printf("<jemalloc>: Lock rank order reversal:");
24 ql_foreach(w
, witnesses
, link
) {
25 malloc_printf(" %s(%u)", w
->name
, w
->rank
);
27 malloc_printf(" %s(%u)\n", witness
->name
, witness
->rank
);
31 #undef witness_lock_error
32 #define witness_lock_error JEMALLOC_N(witness_lock_error)
33 witness_lock_error_t
*witness_lock_error
= JEMALLOC_N(n_witness_lock_error
);
37 #undef witness_owner_error
38 #define witness_owner_error JEMALLOC_N(n_witness_owner_error)
41 witness_owner_error(const witness_t
*witness
)
44 malloc_printf("<jemalloc>: Should own %s(%u)\n", witness
->name
,
49 #undef witness_owner_error
50 #define witness_owner_error JEMALLOC_N(witness_owner_error)
51 witness_owner_error_t
*witness_owner_error
= JEMALLOC_N(n_witness_owner_error
);
55 #undef witness_not_owner_error
56 #define witness_not_owner_error JEMALLOC_N(n_witness_not_owner_error)
59 witness_not_owner_error(const witness_t
*witness
)
62 malloc_printf("<jemalloc>: Should not own %s(%u)\n", witness
->name
,
67 #undef witness_not_owner_error
68 #define witness_not_owner_error JEMALLOC_N(witness_not_owner_error)
69 witness_not_owner_error_t
*witness_not_owner_error
=
70 JEMALLOC_N(n_witness_not_owner_error
);
74 #undef witness_depth_error
75 #define witness_depth_error JEMALLOC_N(n_witness_depth_error)
78 witness_depth_error(const witness_list_t
*witnesses
,
79 witness_rank_t rank_inclusive
, unsigned depth
) {
82 malloc_printf("<jemalloc>: Should own %u lock%s of rank >= %u:", depth
,
83 (depth
!= 1) ? "s" : "", rank_inclusive
);
84 ql_foreach(w
, witnesses
, link
) {
85 malloc_printf(" %s(%u)", w
->name
, w
->rank
);
91 #undef witness_depth_error
92 #define witness_depth_error JEMALLOC_N(witness_depth_error)
93 witness_depth_error_t
*witness_depth_error
= JEMALLOC_N(n_witness_depth_error
);
97 witnesses_cleanup(tsd_t
*tsd
)
100 witness_assert_lockless(tsd_tsdn(tsd
));
106 witness_fork_cleanup(tsd_t
*tsd
)
113 witness_prefork(tsd_t
*tsd
)
116 tsd_witness_fork_set(tsd
, true);
120 witness_postfork_parent(tsd_t
*tsd
)
123 tsd_witness_fork_set(tsd
, false);
127 witness_postfork_child(tsd_t
*tsd
)
129 #ifndef JEMALLOC_MUTEX_INIT_CB
130 witness_list_t
*witnesses
;
132 witnesses
= tsd_witnessesp_get(tsd
);
135 tsd_witness_fork_set(tsd
, false);