Add witness_assert_positive_depth_to_rank().
This commit is contained in:
parent
4d8c22f9a5
commit
9ea235f8fe
@ -139,6 +139,9 @@ emap_assert_not_mapped(tsdn_t *tsdn, emap_t *emap, edata_t *edata) {
|
|||||||
static inline void
|
static inline void
|
||||||
emap_update_rtree_at_addr(tsdn_t *tsdn, rtree_t *rtree, edata_t *expected_edata,
|
emap_update_rtree_at_addr(tsdn_t *tsdn, rtree_t *rtree, edata_t *expected_edata,
|
||||||
uintptr_t addr, extent_state_t state) {
|
uintptr_t addr, extent_state_t state) {
|
||||||
|
witness_assert_positive_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
|
||||||
|
WITNESS_RANK_CORE);
|
||||||
|
|
||||||
rtree_ctx_t rtree_ctx_fallback;
|
rtree_ctx_t rtree_ctx_fallback;
|
||||||
rtree_ctx_t *rtree_ctx = tsdn_rtree_ctx(tsdn, &rtree_ctx_fallback);
|
rtree_ctx_t *rtree_ctx = tsdn_rtree_ctx(tsdn, &rtree_ctx_fallback);
|
||||||
|
|
||||||
|
@ -243,26 +243,13 @@ witness_assert_not_owner(witness_tsdn_t *witness_tsdn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
/* Returns depth. Not intended for direct use. */
|
||||||
witness_assert_depth_to_rank(witness_tsdn_t *witness_tsdn,
|
static inline unsigned
|
||||||
witness_rank_t rank_inclusive, unsigned depth) {
|
witness_depth_to_rank(witness_list_t *witnesses, witness_rank_t rank_inclusive)
|
||||||
witness_tsd_t *witness_tsd;
|
{
|
||||||
unsigned d;
|
unsigned d = 0;
|
||||||
witness_list_t *witnesses;
|
witness_t *w = ql_last(witnesses, link);
|
||||||
witness_t *w;
|
|
||||||
|
|
||||||
if (!config_debug) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (witness_tsdn_null(witness_tsdn)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
witness_tsd = witness_tsdn_tsd(witness_tsdn);
|
|
||||||
|
|
||||||
d = 0;
|
|
||||||
witnesses = &witness_tsd->witnesses;
|
|
||||||
w = ql_last(witnesses, link);
|
|
||||||
if (w != NULL) {
|
if (w != NULL) {
|
||||||
ql_reverse_foreach(w, witnesses, link) {
|
ql_reverse_foreach(w, witnesses, link) {
|
||||||
if (w->rank < rank_inclusive) {
|
if (w->rank < rank_inclusive) {
|
||||||
@ -271,6 +258,20 @@ witness_assert_depth_to_rank(witness_tsdn_t *witness_tsdn,
|
|||||||
d++;
|
d++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
witness_assert_depth_to_rank(witness_tsdn_t *witness_tsdn,
|
||||||
|
witness_rank_t rank_inclusive, unsigned depth) {
|
||||||
|
if (!config_debug || witness_tsdn_null(witness_tsdn)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
witness_list_t *witnesses = &witness_tsdn_tsd(witness_tsdn)->witnesses;
|
||||||
|
unsigned d = witness_depth_to_rank(witnesses, rank_inclusive);
|
||||||
|
|
||||||
if (d != depth) {
|
if (d != depth) {
|
||||||
witness_depth_error(witnesses, rank_inclusive, depth);
|
witness_depth_error(witnesses, rank_inclusive, depth);
|
||||||
}
|
}
|
||||||
@ -286,6 +287,21 @@ witness_assert_lockless(witness_tsdn_t *witness_tsdn) {
|
|||||||
witness_assert_depth(witness_tsdn, 0);
|
witness_assert_depth(witness_tsdn, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
witness_assert_positive_depth_to_rank(witness_tsdn_t *witness_tsdn,
|
||||||
|
witness_rank_t rank_inclusive) {
|
||||||
|
if (!config_debug || witness_tsdn_null(witness_tsdn)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
witness_list_t *witnesses = &witness_tsdn_tsd(witness_tsdn)->witnesses;
|
||||||
|
unsigned d = witness_depth_to_rank(witnesses, rank_inclusive);
|
||||||
|
|
||||||
|
if (d == 0) {
|
||||||
|
witness_depth_error(witnesses, rank_inclusive, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
witness_lock(witness_tsdn_t *witness_tsdn, witness_t *witness) {
|
witness_lock(witness_tsdn_t *witness_tsdn, witness_t *witness) {
|
||||||
witness_tsd_t *witness_tsd;
|
witness_tsd_t *witness_tsd;
|
||||||
|
Loading…
Reference in New Issue
Block a user