From 019044e4c6e2ad711cefa40c1bb3323659e8412a Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sat, 25 Nov 2023 23:17:07 -0600 Subject: [PATCH] Adopted better struct field names, cast to lfsr_openedmdir_t - Renamed mdir->u.m to mdir->u.mdir. - Prefer mdir->u.rbyd.* where possible. - Changed file/dir mdirs to be stored directly, requiring a cast to lfsr_openedmdir_t to enroll in the opened mdir list. --- lfs.c | 270 +++++++++++----------- lfs.h | 8 +- tests/test_alloc.toml | 33 +-- tests/test_mtree.toml | 507 ++++++++++++++++++++++-------------------- 4 files changed, 418 insertions(+), 400 deletions(-) diff --git a/lfs.c b/lfs.c index 51cd785f..253cf510 100644 --- a/lfs.c +++ b/lfs.c @@ -4728,12 +4728,12 @@ static int lfsr_btree_traverse(lfs_t *lfs, const lfsr_btree_t *btree, static inline bool lfsr_bshrub_isbshrub( const lfsr_mdir_t *mdir, const lfsr_bshrub_t *bshrub) { - return mdir->u.m.blocks[0] == bshrub->rbyd.block; + return mdir->u.mdir.blocks[0] == bshrub->rbyd.block; } static inline bool lfsr_bshrub_isbtree( const lfsr_mdir_t *mdir, const lfsr_bshrub_t *bshrub) { - return mdir->u.m.blocks[0] != bshrub->rbyd.block; + return mdir->u.mdir.blocks[0] != bshrub->rbyd.block; } static inline int lfsr_bshrub_cmp( @@ -5006,7 +5006,7 @@ static int lfsr_data_readmptr(lfs_t *lfs, lfsr_data_t *data, // mdir convenience functions static inline const lfsr_mptr_t *lfsr_mdir_mptr(const lfsr_mdir_t *mdir) { - return (const lfsr_mptr_t*)mdir->u.m.blocks; + return (const lfsr_mptr_t*)mdir->u.mdir.blocks; } static inline int lfsr_mdir_cmp(const lfsr_mdir_t *a, const lfsr_mdir_t *b) { @@ -5098,7 +5098,7 @@ static int lfsr_mdir_fetch(lfs_t *lfs, lfsr_mdir_t *mdir, if (err != LFS_ERR_CORRUPT) { mdir->mid = mid; // keep track of other block for compactions - mdir->u.m.blocks[1] = blocks_[1]; + mdir->u.mdir.blocks[1] = blocks_[1]; return 0; } @@ -5200,7 +5200,7 @@ static int lfsr_mtree_lookup(lfs_t *lfs, lfsr_smid_t mid, LFS_ASSERT(mid >= 0); LFS_ASSERT(mid < (lfsr_smid_t)lfsr_mweight(lfs)); mdir_->mid = mid; - mdir_->u.m = lfs->mroot.u.m; + mdir_->u = lfs->mroot.u; return 0; // looking up direct mdir? @@ -5248,7 +5248,7 @@ static int lfsr_mtree_seek(lfs_t *lfs, lfsr_mdir_t *mdir, lfs_off_t off) { lfsr_srid_t rid = lfsr_mdir_rid(lfs, mdir) + off; // lookup mdirs until we find our rid, we need to do this because // we don't know how many rids are in each mdir until we fetch - while (rid >= mdir->u.m.weight) { + while (rid >= mdir->u.rbyd.weight) { // end of mtree? if (bid+lfsr_mweight(lfs) >= lfsr_mtree_weight(lfs)) { // if we hit the end of the mtree, park the mdir so all future @@ -5258,7 +5258,7 @@ static int lfsr_mtree_seek(lfs_t *lfs, lfsr_mdir_t *mdir, lfs_off_t off) { } bid += lfsr_mweight(lfs); - rid -= mdir->u.m.weight; + rid -= mdir->u.rbyd.weight; int err = lfsr_mtree_lookup(lfs, bid, mdir); if (err) { return err; @@ -5284,23 +5284,23 @@ static int lfsr_mdir_alloc(lfs_t *lfs, lfsr_mdir_t *mdir, lfsr_smid_t mid) { // allocate two blocks for (int i = 0; i < 2; i++) { - int err = lfs_alloc(lfs, &mdir->u.m.blocks[i]); + int err = lfs_alloc(lfs, &mdir->u.mdir.blocks[i]); if (err) { return err; } } - mdir->u.m.weight = 0; - mdir->u.m.trunk = 0; - mdir->u.m.eoff = 0; - mdir->u.m.cksum = 0; + mdir->u.rbyd.weight = 0; + mdir->u.rbyd.trunk = 0; + mdir->u.rbyd.eoff = 0; + mdir->u.rbyd.cksum = 0; // read the new revision count // // we use whatever is on-disk to avoid needing to rewrite the // redund block uint32_t rev; - int err = lfsr_bd_read(lfs, mdir->u.m.blocks[1], 0, sizeof(uint32_t), + int err = lfsr_bd_read(lfs, mdir->u.mdir.blocks[1], 0, sizeof(uint32_t), &rev, sizeof(uint32_t)); if (err && err != LFS_ERR_CORRUPT) { return err; @@ -5315,7 +5315,7 @@ static int lfsr_mdir_alloc(lfs_t *lfs, lfsr_mdir_t *mdir, lfsr_smid_t mid) { } // erase, preparing for compact - err = lfsr_bd_erase(lfs, mdir->u.m.blocks[0]); + err = lfsr_bd_erase(lfs, mdir->u.mdir.blocks[0]); if (err) { return err; } @@ -5337,7 +5337,7 @@ static int lfsr_mdir_swap(lfs_t *lfs, lfsr_mdir_t *mdir_, // first thing we need to do is read our current revision count uint32_t rev; - int err = lfsr_bd_read(lfs, mdir->u.m.blocks[0], 0, sizeof(uint32_t), + int err = lfsr_bd_read(lfs, mdir->u.mdir.blocks[0], 0, sizeof(uint32_t), &rev, sizeof(uint32_t)); if (err && err != LFS_ERR_CORRUPT) { return err; @@ -5355,15 +5355,15 @@ static int lfsr_mdir_swap(lfs_t *lfs, lfsr_mdir_t *mdir_, } // swap our blocks - mdir_->u.m.blocks[0] = mdir->u.m.blocks[1]; - mdir_->u.m.blocks[1] = mdir->u.m.blocks[0]; - mdir_->u.m.weight = 0; - mdir_->u.m.trunk = 0; - mdir_->u.m.eoff = 0; - mdir_->u.m.cksum = 0; + mdir_->u.mdir.blocks[0] = mdir->u.mdir.blocks[1]; + mdir_->u.mdir.blocks[1] = mdir->u.mdir.blocks[0]; + mdir_->u.rbyd.weight = 0; + mdir_->u.rbyd.trunk = 0; + mdir_->u.rbyd.eoff = 0; + mdir_->u.rbyd.cksum = 0; // erase, preparing for compact - err = lfsr_bd_erase(lfs, mdir_->u.m.blocks[0]); + err = lfsr_bd_erase(lfs, mdir_->u.mdir.blocks[0]); if (err) { return err; } @@ -5455,8 +5455,8 @@ static int lfsr_mdir_commit__(lfs_t *lfs, lfsr_mdir_t *mdir, // // it is important that these rbyds share eoff/cksum/etc // - mdir_.u.m.trunk = bshrubcommit->bshrub->rbyd_.trunk; - mdir_.u.m.weight = bshrubcommit->bshrub->rbyd_.weight; + mdir_.u.rbyd.trunk = bshrubcommit->bshrub->rbyd_.trunk; + mdir_.u.rbyd.weight = bshrubcommit->bshrub->rbyd_.weight; // append any shrub attributes for (lfs_size_t j = 0; j < bshrubcommit->attr_count; j++) { @@ -5471,10 +5471,10 @@ static int lfsr_mdir_commit__(lfs_t *lfs, lfsr_mdir_t *mdir, } // revert mdir to main trunk/weight - bshrubcommit->bshrub->rbyd_.trunk = mdir_.u.m.trunk; - bshrubcommit->bshrub->rbyd_.weight = mdir_.u.m.weight; - mdir_.u.m.trunk = mdir->u.m.trunk; - mdir_.u.m.weight = mdir->u.m.weight; + bshrubcommit->bshrub->rbyd_.trunk = mdir_.u.rbyd.trunk; + bshrubcommit->bshrub->rbyd_.weight = mdir_.u.rbyd.weight; + mdir_.u.rbyd.trunk = mdir->u.rbyd.trunk; + mdir_.u.rbyd.weight = mdir->u.rbyd.weight; // lazily encode inlined trunks in case they change underneath // us due to mdir compactions @@ -5527,12 +5527,12 @@ static int lfsr_mdir_commit__(lfs_t *lfs, lfsr_mdir_t *mdir, // If we finish the commit it becomes immediately visibile, but we really // need to remove this mdir_ from the mtree. Leave the actual remove up to // upper layers. - if (mdir_.u.m.weight == 0 + if (mdir_.u.rbyd.weight == 0 // unless we are an mroot && !(mdir_.mid == -1 || lfsr_mdir_cmp(&mdir_, &lfs->mroot) == 0)) { // mark weight as zero, but note! we can not longer read from this mdir // as our pcache may get clobbered - mdir->u.m.weight = 0; + mdir->u.rbyd.weight = 0; return LFS_ERR_NOENT; } @@ -5555,7 +5555,7 @@ static int lfsr_mdir_commit__(lfs_t *lfs, lfsr_mdir_t *mdir, lfsr_fs_flushgdelta(lfs); } - mdir->u.m = mdir_.u.m; + mdir->u = mdir_.u; return 0; } @@ -5707,9 +5707,9 @@ static int lfsr_mdir_compact__(lfs_t *lfs, lfsr_mdir_t *mdir_, lfsr_file_t *file = (lfsr_file_t*)opened; // belongs to our mdir? if (lfsr_file_isunsynced(file) - && lfsr_mdir_cmp(&file->m.mdir, mdir) == 0 - && lfsr_mdir_rid(lfs, &file->m.mdir) >= start_rid - && (lfsr_rid_t)lfsr_mdir_rid(lfs, &file->m.mdir) + && lfsr_mdir_cmp(&file->mdir, mdir) == 0 + && lfsr_mdir_rid(lfs, &file->mdir) >= start_rid + && (lfsr_rid_t)lfsr_mdir_rid(lfs, &file->mdir) < (lfsr_rid_t)end_rid) { // inlined sprout? if (lfsr_file_isbsprout(file)) { @@ -5826,7 +5826,7 @@ static lfs_ssize_t lfsr_mdir_estimate_(lfs_t *lfs, const lfsr_mdir_t *mdir, lfsr_file_t *file = (lfsr_file_t*)opened; // belongs to our mdir? if (lfsr_file_isunsynced(file) - && lfsr_mdir_cmp(&file->m.mdir, mdir) == 0) { + && lfsr_mdir_cmp(&file->mdir, mdir) == 0) { // inlined sprout? if (lfsr_file_isbsprout(file)) { dsize += LFSR_TAG_DSIZE @@ -5864,7 +5864,7 @@ static lfs_ssize_t lfsr_mdir_estimate(lfs_t *lfs, const lfsr_mdir_t *mdir, // during a split so they shouldn't affect the split_rid // lfsr_srid_t lower_rid = lfs_smax32(start_rid, 0); - lfsr_srid_t upper_rid = lfs_min32(mdir->u.m.weight, end_rid)-1; + lfsr_srid_t upper_rid = lfs_min32(mdir->u.rbyd.weight, end_rid)-1; lfs_size_t lower_dsize = 0; lfs_size_t upper_dsize = 0; @@ -6058,8 +6058,8 @@ static int lfsr_mroot_commit(lfs_t *lfs, LFS_DEBUG("Relocating mroot 0x{%"PRIx32",%"PRIx32"} " "-> 0x{%"PRIx32",%"PRIx32"}", - mrootchild.u.m.blocks[0], mrootchild.u.m.blocks[1], - mrootchild_.u.m.blocks[0], mrootchild_.u.m.blocks[1]); + mrootchild.u.mdir.blocks[0], mrootchild.u.mdir.blocks[1], + mrootchild_.u.mdir.blocks[0], mrootchild_.u.mdir.blocks[1]); mrootchild = mrootparent_; @@ -6085,9 +6085,9 @@ static int lfsr_mroot_commit(lfs_t *lfs, LFS_DEBUG("Extending mroot 0x{%"PRIx32",%"PRIx32"}" " -> 0x{%"PRIx32",%"PRIx32"}" ", 0x{%"PRIx32",%"PRIx32"}", - mrootchild.u.m.blocks[0], mrootchild.u.m.blocks[1], - mrootchild.u.m.blocks[0], mrootchild.u.m.blocks[1], - mrootchild_.u.m.blocks[0], mrootchild_.u.m.blocks[1]); + mrootchild.u.mdir.blocks[0], mrootchild.u.mdir.blocks[1], + mrootchild.u.mdir.blocks[0], mrootchild.u.mdir.blocks[1], + mrootchild_.u.mdir.blocks[0], mrootchild_.u.mdir.blocks[1]); // compact into the new mroot anchor lfsr_mdir_t mrootanchor_; @@ -6163,7 +6163,7 @@ static int lfsr_mroot_commit(lfs_t *lfs, } // update any opened mdirs in our mroot - opened->mdir.u.m = mroot_.u.m; + opened->mdir.u = mroot_.u; } } } @@ -6235,8 +6235,8 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, const lfsr_attr_t *attrs, lfs_size_t attr_count) { LFS_ASSERT(mdir->mid == -1 || lfsr_mtree_isnull(lfs) - || mdir->u.m.weight > 0); - LFS_ASSERT(lfsr_mdir_rid(lfs, mdir) <= mdir->u.m.weight); + || mdir->u.rbyd.weight > 0); + LFS_ASSERT(lfsr_mdir_rid(lfs, mdir) <= mdir->u.rbyd.weight); // parse out any pending gstate, these will get automatically xored // with on-disk gdeltas in lower-level functions @@ -6299,7 +6299,7 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, } // keep mdir_ in sync with mroot - mdir_.u.m = lfs->mroot.u.m; + mdir_.u = lfs->mroot.u; // otherwise commit normally } else { @@ -6380,40 +6380,40 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, "-> 0x{%"PRIx32",%"PRIx32"}, " "0x{%"PRIx32",%"PRIx32"}", mdir->mid >> lfs->mbits, - mdir->u.m.blocks[0], mdir->u.m.blocks[1], - mdir_.u.m.blocks[0], mdir_.u.m.blocks[1], - msibling_.u.m.blocks[0], msibling_.u.m.blocks[1]); + mdir->u.mdir.blocks[0], mdir->u.mdir.blocks[1], + mdir_.u.mdir.blocks[0], mdir_.u.mdir.blocks[1], + msibling_.u.mdir.blocks[0], msibling_.u.mdir.blocks[1]); // because of defered commits, both children can still be reduced // to zero, need to catch this here // both siblings reduced to zero - if (mdir_.u.m.weight == 0 && msibling_.u.m.weight == 0) { + if (mdir_.u.rbyd.weight == 0 && msibling_.u.rbyd.weight == 0) { LFS_DEBUG("Dropping mdir %"PRId32" " "0x{%"PRIx32",%"PRIx32"}", mdir_.mid >> lfs->mbits, - mdir_.u.m.blocks[0], mdir_.u.m.blocks[1]); + mdir_.u.mdir.blocks[0], mdir_.u.mdir.blocks[1]); LFS_DEBUG("Dropping mdir %"PRId32" " "0x{%"PRIx32",%"PRIx32"}", msibling_.mid >> lfs->mbits, - msibling_.u.m.blocks[0], msibling_.u.m.blocks[1]); + msibling_.u.mdir.blocks[0], msibling_.u.mdir.blocks[1]); goto drop; // one sibling reduced to zero - } else if (msibling_.u.m.weight == 0) { + } else if (msibling_.u.rbyd.weight == 0) { LFS_DEBUG("Dropping mdir %"PRId32" " "0x{%"PRIx32",%"PRIx32"}", msibling_.mid >> lfs->mbits, - msibling_.u.m.blocks[0], msibling_.u.m.blocks[1]); + msibling_.u.mdir.blocks[0], msibling_.u.mdir.blocks[1]); goto relocate; // other sibling reduced to zero - } else if (mdir_.u.m.weight == 0) { + } else if (mdir_.u.rbyd.weight == 0) { LFS_DEBUG("Dropping mdir %"PRId32" " "0x{%"PRIx32",%"PRIx32"}", mdir_.mid >> lfs->mbits, - mdir_.u.m.blocks[0], mdir_.u.m.blocks[1]); - mdir_.u.m = msibling_.u.m; + mdir_.u.mdir.blocks[0], mdir_.u.mdir.blocks[1]); + mdir_.u = msibling_.u; goto relocate; } @@ -6443,9 +6443,9 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, if (lfsr_mid_bid(lfs, grm->rms[j]) == lfsr_mid_bid(lfs, lfs_smax32(mdir->mid, 0))) { if (lfsr_mid_rid(lfs, grm->rms[j]) - >= mdir_.u.m.weight) { + >= mdir_.u.rbyd.weight) { grm->rms[j] += lfsr_mweight(lfs) - - mdir_.u.m.weight; + - mdir_.u.rbyd.weight; } } else if (grm->rms[j] > mdir->mid) { grm->rms[j] += mdelta; @@ -6512,7 +6512,7 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, LFS_DEBUG("Dropping mdir %"PRId32" " "0x{%"PRIx32",%"PRIx32"}", mdir->mid >> lfs->mbits, - mdir->u.m.blocks[0], mdir->u.m.blocks[1]); + mdir->u.mdir.blocks[0], mdir->u.mdir.blocks[1]); // consume gstate so we don't lose any info err = lfsr_fs_consumegdelta(lfs, mdir); @@ -6584,8 +6584,8 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, LFS_DEBUG("Relocating mdir %"PRId32" " "0x{%"PRIx32",%"PRIx32"} -> 0x{%"PRIx32",%"PRIx32"}", mdir->mid >> lfs->mbits, - mdir->u.m.blocks[0], mdir->u.m.blocks[1], - mdir_.u.m.blocks[0], mdir_.u.m.blocks[1]); + mdir->u.mdir.blocks[0], mdir->u.mdir.blocks[1], + mdir_.u.mdir.blocks[0], mdir_.u.mdir.blocks[1]); relocate:; // new mtree? @@ -6685,12 +6685,12 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, if (lfsr_mdir_cmp(&opened->mdir, mdir) == 0) { if (mdelta > 0 && lfsr_mdir_rid(lfs, &opened->mdir) - >= mdir_.u.m.weight) { + >= mdir_.u.rbyd.weight) { opened->mdir.mid += lfsr_mweight(lfs) - - mdir_.u.m.weight; - opened->mdir.u.m = msibling_.u.m; + - mdir_.u.rbyd.weight; + opened->mdir.u = msibling_.u; } else { - opened->mdir.u.m = mdir_.u.m; + opened->mdir.u = mdir_.u; } } else if (opened->mdir.mid > mdir->mid) { opened->mdir.mid += mdelta; @@ -6709,7 +6709,7 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, // removed? if (dir->bookmark < attrs[i].rid - attrs[i].delta) { // mark dir as dropped - dir->m.mdir.mid = -1; + dir->mdir.mid = -1; dir->bookmark = -1; goto next; } else { @@ -6727,9 +6727,9 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, == lfsr_mid_bid(lfs, lfs_smax32(mdir->mid, 0))) { if (mdelta > 0 && lfsr_mid_rid(lfs, dir->bookmark) - >= mdir_.u.m.weight) { + >= mdir_.u.rbyd.weight) { dir->bookmark += lfsr_mweight(lfs) - - mdir_.u.m.weight; + - mdir_.u.rbyd.weight; } } else if (dir->bookmark > mdir->mid) { dir->bookmark += mdelta; @@ -6741,13 +6741,13 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, // update mdir to follow requested rid if (mdir->mid == -1) { - mdir->u.m = lfs->mroot.u.m; + mdir->u = lfs->mroot.u; } else if (mdelta > 0 - && lfsr_mdir_rid(lfs, mdir) >= mdir_.u.m.weight) { - mdir->mid += lfsr_mweight(lfs) - mdir_.u.m.weight; - mdir->u.m = msibling_.u.m; + && lfsr_mdir_rid(lfs, mdir) >= mdir_.u.rbyd.weight) { + mdir->mid += lfsr_mweight(lfs) - mdir_.u.rbyd.weight; + mdir->u = msibling_.u; } else { - mdir->u.m = mdir_.u.m; + mdir->u = mdir_.u; } return 0; @@ -6761,7 +6761,7 @@ static int lfsr_mdir_namelookup(lfs_t *lfs, const lfsr_mdir_t *mdir, lfsr_did_t did, const char *name, lfs_size_t name_size, lfsr_srid_t *rid_, lfsr_tag_t *tag_, lfsr_data_t *data_) { // empty mdir? make sure rid_ = 0 at least - if (mdir->u.m.weight == 0) { + if (mdir->u.rbyd.weight == 0) { if (rid_) { *rid_ = 0; } @@ -7293,7 +7293,7 @@ static int lfsr_traversal_read(lfs_t *lfs, lfsr_traversal_t *traversal, // return to mtree traversal if (!lfsr_traversal_isall(traversal) || lfsr_mdir_rid(lfs, &traversal->mdir) - >= traversal->mdir.u.m.weight) { + >= traversal->mdir.u.rbyd.weight) { traversal->state = LFSR_TRAVERSAL_MTREE; continue; } @@ -7371,7 +7371,7 @@ static int lfsr_traversal_read(lfs_t *lfs, lfsr_traversal_t *traversal, // TODO validate? // transition to next file - traversal->u.opened = file->m.next; + traversal->u.opened = file->next; tinfo->tag = LFSR_TAG_BLOCK; return 0; @@ -7379,7 +7379,7 @@ static int lfsr_traversal_read(lfs_t *lfs, lfsr_traversal_t *traversal, // found a bshrub/btree? } else if (lfsr_file_isbshruborbtree(file)) { // start traversing - traversal->mdir = file->m.mdir; + traversal->mdir = file->mdir; traversal->bshrub = file->u.bshrub; traversal->btraversal = LFSR_BTRAVERSAL(); traversal->state = LFSR_TRAVERSAL_OPENEDBTREE; @@ -7387,7 +7387,7 @@ static int lfsr_traversal_read(lfs_t *lfs, lfsr_traversal_t *traversal, // no? continue to next file } else { - traversal->u.opened = file->m.next; + traversal->u.opened = file->next; continue; } @@ -8136,9 +8136,9 @@ int lfsr_mount(lfs_t *lfs, const struct lfs_config *cfg) { "bd %"PRId32"x%"PRId32, LFS_DISK_VERSION_MAJOR, LFS_DISK_VERSION_MINOR, - lfs->mroot.u.m.blocks[0], - lfs->mroot.u.m.blocks[1], - lfs->mroot.u.m.trunk, + lfs->mroot.u.mdir.blocks[0], + lfs->mroot.u.mdir.blocks[1], + lfs->mroot.u.rbyd.trunk, lfsr_mtree_weight(lfs) / lfsr_mweight(lfs), lfsr_mweight(lfs), lfs->cfg->block_size, @@ -8267,8 +8267,8 @@ static int lfs_alloc(lfs_t *lfs, lfs_block_t *block) { // mark any blocks we see at in-use, including any btree/mdir blocks if (tinfo.tag == LFSR_TAG_MDIR) { - lfs_alloc_setinuse(lfs, tinfo.u.mdir.u.m.blocks[1]); - lfs_alloc_setinuse(lfs, tinfo.u.mdir.u.m.blocks[0]); + lfs_alloc_setinuse(lfs, tinfo.u.mdir.u.mdir.blocks[1]); + lfs_alloc_setinuse(lfs, tinfo.u.mdir.u.mdir.blocks[0]); } else if (tinfo.tag == LFSR_TAG_BRANCH) { lfs_alloc_setinuse(lfs, tinfo.u.rbyd.block); @@ -8348,7 +8348,7 @@ static int lfsr_fs_fixgrm(lfs_t *lfs) { } // remove the rid while also updating our grm - LFS_ASSERT(lfsr_mid_rid(lfs, lfs->grm.rms[0]) < mdir.u.m.weight); + LFS_ASSERT(lfsr_mid_rid(lfs, lfs->grm.rms[0]) < mdir.u.rbyd.weight); err = lfsr_mdir_commit(lfs, &mdir, LFSR_ATTRS( LFSR_ATTR(mdir.mid, RM, -1, NULL()), LFSR_ATTR(-1, GRM, 0, GRM(&grm)))); @@ -8873,13 +8873,13 @@ int lfsr_dir_open(lfs_t *lfs, lfsr_dir_t *dir, const char *path) { } // add to tracked mdirs - lfsr_mdir_addopened(lfs, LFS_TYPE_DIR, &dir->m); + lfsr_mdir_addopened(lfs, LFS_TYPE_DIR, (lfsr_openedmdir_t*)dir); return 0; } int lfsr_dir_close(lfs_t *lfs, lfsr_dir_t *dir) { // remove from tracked mdirs - lfsr_mdir_removeopened(lfs, LFS_TYPE_DIR, &dir->m); + lfsr_mdir_removeopened(lfs, LFS_TYPE_DIR, (lfsr_openedmdir_t*)dir); return 0; } @@ -8903,7 +8903,7 @@ int lfsr_dir_read(lfs_t *lfs, lfsr_dir_t *dir, struct lfs_info *info) { } // seek in case our mdir was dropped - int err = lfsr_mtree_seek(lfs, &dir->m.mdir, 0); + int err = lfsr_mtree_seek(lfs, &dir->mdir, 0); if (err) { return err; } @@ -8911,13 +8911,13 @@ int lfsr_dir_read(lfs_t *lfs, lfsr_dir_t *dir, struct lfs_info *info) { // fill out our info struct // // this will return LFS_ERR_NOENT if our dids mismatch - err = lfsr_mdir_stat(lfs, &dir->m.mdir, dir->m.mdir.mid, dir->did, info); + err = lfsr_mdir_stat(lfs, &dir->mdir, dir->mdir.mid, dir->did, info); if (err) { return err; } // eagerly look up the next entry - err = lfsr_mtree_seek(lfs, &dir->m.mdir, 1); + err = lfsr_mtree_seek(lfs, &dir->mdir, 1); if (err && err != LFS_ERR_NOENT) { return err; } @@ -8943,7 +8943,7 @@ int lfsr_dir_seek(lfs_t *lfs, lfsr_dir_t *dir, lfs_soff_t off) { // // note the -2 to adjust for dot entries if (off > 2) { - err = lfsr_mtree_seek(lfs, &dir->m.mdir, off - 2); + err = lfsr_mtree_seek(lfs, &dir->mdir, off - 2); if (err && err != LFS_ERR_NOENT) { return err; } @@ -8966,20 +8966,20 @@ int lfsr_dir_rewind(lfs_t *lfs, lfsr_dir_t *dir) { // lookup our bookmark in the mtree int err = lfsr_mtree_namelookup(lfs, dir->did, NULL, 0, - &dir->m.mdir, NULL, NULL); + &dir->mdir, NULL, NULL); if (err) { LFS_ASSERT(err != LFS_ERR_NOENT); return err; } // keep track of bookmark so we can adjust pos correctly - dir->bookmark = dir->m.mdir.mid; + dir->bookmark = dir->mdir.mid; dir->pos = 0; // eagerly lookup the next entry // // this makes handling of corner cases with mixed removes/dir reads easier - err = lfsr_mtree_seek(lfs, &dir->m.mdir, 1); + err = lfsr_mtree_seek(lfs, &dir->mdir, 1); if (err && err != LFS_ERR_NOENT) { return err; } @@ -9008,24 +9008,24 @@ static inline bool lfsr_file_isbsprout(const lfsr_file_t *file) { return (lfs_size_t)file->u.bsprout.data.u.disk.size > (LFSR_FILE_ISDIRECT | 0) && file->u.bsprout.data.u.disk.block - == file->m.mdir.u.m.blocks[0]; + == file->mdir.u.mdir.blocks[0]; } static inline bool lfsr_file_isbptr(const lfsr_file_t *file) { return (lfs_size_t)file->u.bsprout.data.u.disk.size > (LFSR_FILE_ISDIRECT | 0) && file->u.bsprout.data.u.disk.block - != file->m.mdir.u.m.blocks[0]; + != file->mdir.u.mdir.blocks[0]; } static inline bool lfsr_file_isbshrub(const lfsr_file_t *file) { return !(file->u.bsprout.data.u.disk.size & LFSR_FILE_ISDIRECT) - && lfsr_bshrub_isbshrub(&file->m.mdir, &file->u.bshrub); + && lfsr_bshrub_isbshrub(&file->mdir, &file->u.bshrub); } static inline bool lfsr_file_isbtree(const lfsr_file_t *file) { return !(file->u.bsprout.data.u.disk.size & LFSR_FILE_ISDIRECT) - && lfsr_bshrub_isbtree(&file->m.mdir, &file->u.bshrub); + && lfsr_bshrub_isbtree(&file->mdir, &file->u.bshrub); } static inline bool lfsr_file_isbshruborbtree(const lfsr_file_t *file) { @@ -9128,7 +9128,7 @@ int lfsr_file_opencfg(lfs_t *lfs, lfsr_file_t *file, const char *name; lfs_size_t name_size; int err = lfsr_mtree_pathlookup(lfs, path, - &file->m.mdir, &tag, + &file->mdir, &tag, &did, &name, &name_size); if (err && err != LFS_ERR_NOENT) { return err; @@ -9152,8 +9152,8 @@ int lfsr_file_opencfg(lfs_t *lfs, lfsr_file_t *file, // but it's the only way for us to save the file name. // // TODO or is it? ;) - err = lfsr_mdir_commit(lfs, &file->m.mdir, LFSR_ATTRS( - LFSR_ATTR(file->m.mdir.mid, + err = lfsr_mdir_commit(lfs, &file->mdir, LFSR_ATTRS( + LFSR_ATTR(file->mdir.mid, REG, +1, CAT( LFSR_DATA_LEB128(did), LFSR_DATA_BUF(name, name_size))))); @@ -9177,8 +9177,8 @@ int lfsr_file_opencfg(lfs_t *lfs, lfsr_file_t *file, // read any inlined state lfsr_tag_t tag; lfsr_data_t data; - err = lfsr_mdir_lookupnext(lfs, &file->m.mdir, - file->m.mdir.mid, LFSR_TAG_DATA, + err = lfsr_mdir_lookupnext(lfs, &file->mdir, + file->mdir.mid, LFSR_TAG_DATA, &tag, &data); if (err && err != LFS_ERR_NOENT) { return err; @@ -9209,7 +9209,7 @@ int lfsr_file_opencfg(lfs_t *lfs, lfsr_file_t *file, } int err = lfsr_bshrub_fetch(lfs, - &file->m.mdir, &file->u.bshrub, + &file->mdir, &file->u.bshrub, trunk, weight); if (err) { return err; @@ -9240,7 +9240,7 @@ int lfsr_file_opencfg(lfs_t *lfs, lfsr_file_t *file, file->buffer_size = 0; // add to tracked mdirs - lfsr_mdir_addopened(lfs, LFS_TYPE_REG, &file->m); + lfsr_mdir_addopened(lfs, LFS_TYPE_REG, (lfsr_openedmdir_t*)file); return 0; } @@ -9259,7 +9259,7 @@ int lfsr_file_close(lfs_t *lfs, lfsr_file_t *file) { int err = lfsr_file_sync(lfs, file); // remove from tracked mdirs - lfsr_mdir_removeopened(lfs, LFS_TYPE_REG, &file->m); + lfsr_mdir_removeopened(lfs, LFS_TYPE_REG, (lfsr_openedmdir_t*)file); // clean up memory if (!file->cfg->buffer) { @@ -9319,7 +9319,7 @@ static int lfsr_file_ulookupnext(lfs_t *lfs, const lfsr_file_t *file, lfsr_tag_t tag; lfsr_bid_t weight; lfsr_data_t data; - int err = lfsr_bshrub_lookupnext(lfs, &file->m.mdir, &file->u.bshrub, + int err = lfsr_bshrub_lookupnext(lfs, &file->mdir, &file->u.bshrub, pos, &bid, &tag, &weight, &data); if (err) { @@ -9521,14 +9521,14 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, data = lfsr_data_frombptr(&file->u.bptr, bptr_buf); } - int err = lfsr_bshrub_alloc(lfs, &file->m.mdir, &file->u.bshrub); + int err = lfsr_bshrub_alloc(lfs, &file->mdir, &file->u.bshrub); if (err) { return err; } if (tag) { err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(0, TAG(tag), +weight, DATA(data)))); if (err) { @@ -9569,7 +9569,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, // a data copy if (lfsr_data_size(&data_) == lfsr_data_size(&slice_)) { err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(bid_, GROW, -overlap_, NULL()))); if (err) { @@ -9587,7 +9587,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, uint8_t bptr_buf[LFSR_BPTR_DSIZE]; err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(bid_, GROW(WIDE(BLOCK)), -overlap_, FROMBPTR(&bptr_, bptr_buf)))); @@ -9600,7 +9600,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, } else { // write the last fragment first to avoid overflow issues err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(bid_, GROW(WIDE(DATA)), -overlap_ - lfs_aligndown( lfsr_data_size(&slice_)-1, @@ -9619,7 +9619,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, lfs->cfg->fragment_size); i += lfs->cfg->fragment_size) { err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(bid_-(weight_-1) + i, DATA, +lfs->cfg->fragment_size, DISK( @@ -9660,7 +9660,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, uint8_t bptr_buf[LFSR_BPTR_DSIZE]; err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(pos, BLOCK, +(weight_ - overlap_), FROMBPTR(&bptr_, bptr_buf)))); @@ -9674,7 +9674,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, // TODO can this be simplified a bit? // write the last fragment first to avoid overflow issues err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(pos, DATA, +weight_ - overlap_ - lfs_aligndown( @@ -9694,7 +9694,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, lfs->cfg->fragment_size); i += lfs->cfg->fragment_size) { err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(pos + i, DATA, +lfs->cfg->fragment_size, DISK( @@ -9722,7 +9722,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, if (lfsr_data_size(&slice_) == 0) { delta += bid_+1 - (pos + weight); err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(bid_, RM, -weight_, NULL()))); if (err) { @@ -9740,7 +9740,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, uint8_t bptr_buf[LFSR_BPTR_DSIZE]; err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(bid_, GROW(WIDE(BLOCK)), -overlap_, FROMBPTR(&bptr_, bptr_buf)))); @@ -9753,7 +9753,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, } else { // write the last fragment first to avoid overflow issues err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(bid_, GROW(WIDE(DATA)), -overlap_ - lfs_aligndown( lfsr_data_size(&slice_)-1, @@ -9772,7 +9772,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, lfs->cfg->fragment_size); i += lfs->cfg->fragment_size) { err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(bid_-(weight_-1) + i, DATA, +lfs->cfg->fragment_size, DISK( @@ -9789,7 +9789,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, } else { // remove err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(bid_, RM, -weight_, NULL()))); if (err) { @@ -9812,7 +9812,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, // we can usually get away with a simple grow attribute if (pos_ > 0) { int err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(pos_-1, GROW, +hole, NULL()))); if (err) { @@ -9822,7 +9822,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, // otherwise we need a hole attr } else { int err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(pos_, DATA, +hole, NULL()))); if (err) { @@ -9838,7 +9838,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, // finally append our data if (weight + delta > 0 && lfsr_data_size(&data) != 0) { int err = lfsr_bshrub_commit(lfs, - &file->m.mdir, &file->u.bshrub, LFSR_ATTRS( + &file->mdir, &file->u.bshrub, LFSR_ATTRS( LFSR_ATTR(pos, TAG(tag), +(weight + delta), DATA(data)))); if (err) { @@ -10283,7 +10283,7 @@ int lfsr_file_sync(lfs_t *lfs, lfsr_file_t *file) { } // do nothing if our file has been removed - if (file->m.mdir.mid == -1) { + if (file->mdir.mid == -1) { return 0; } @@ -10309,12 +10309,12 @@ int lfsr_file_sync(lfs_t *lfs, lfsr_file_t *file) { LFS_ASSERT(file->buffer_pos == 0 || file->buffer_size == 0); // commit our file's metadata - err = lfsr_mdir_commit(lfs, &file->m.mdir, LFSR_ATTRS( + err = lfsr_mdir_commit(lfs, &file->mdir, LFSR_ATTRS( (file->buffer_size > 0 - ? LFSR_ATTR(file->m.mdir.mid, + ? LFSR_ATTR(file->mdir.mid, WIDE(DATA), 0, BUF( file->buffer, file->buffer_size)) - : LFSR_ATTR(file->m.mdir.mid, + : LFSR_ATTR(file->mdir.mid, WIDE(RM(STRUCT)), 0, NULL())))); if (err) { goto failed; @@ -10331,8 +10331,8 @@ int lfsr_file_sync(lfs_t *lfs, lfsr_file_t *file) { if (file->size > 0) { // we need to look up the inlined data again... // TODO deduplicate? - err = lfsr_mdir_lookup(lfs, &file->m.mdir, - file->m.mdir.mid, LFSR_TAG_DATA, + err = lfsr_mdir_lookup(lfs, &file->mdir, + file->mdir.mid, LFSR_TAG_DATA, NULL, &file->u.bsprout.data); if (err) { return err; @@ -10358,20 +10358,20 @@ int lfsr_file_sync(lfs_t *lfs, lfsr_file_t *file) { uint8_t buf[(LFSR_BPTR_DSIZE > LFSR_BTREE_DSIZE) ? LFSR_BPTR_DSIZE : LFSR_BTREE_DSIZE]; - err = lfsr_mdir_commit(lfs, &file->m.mdir, LFSR_ATTRS( + err = lfsr_mdir_commit(lfs, &file->mdir, LFSR_ATTRS( (lfsr_file_isbnull(file)) - ? LFSR_ATTR(file->m.mdir.mid, + ? LFSR_ATTR(file->mdir.mid, WIDE(RM(STRUCT)), 0, NULL()) : (lfsr_file_isbsprout(file)) - ? LFSR_ATTR(file->m.mdir.mid, + ? LFSR_ATTR(file->mdir.mid, WIDE(DATA), 0, DATA(file->u.bsprout.data)) : (lfsr_file_isbptr(file)) - ? LFSR_ATTR(file->m.mdir.mid, + ? LFSR_ATTR(file->mdir.mid, WIDE(BLOCK), 0, FROMBPTR(&file->u.bptr, buf)) : (lfsr_file_isbshrub(file)) - ? LFSR_ATTR(file->m.mdir.mid, + ? LFSR_ATTR(file->mdir.mid, WIDE(BSHRUBTRUNK), 0, BSHRUBTRUNK(&file->u.bshrub)) - : LFSR_ATTR(file->m.mdir.mid, + : LFSR_ATTR(file->mdir.mid, WIDE(BTREE), 0, FROMBTREE(&file->u.btree, buf)))); if (err) { goto failed; diff --git a/lfs.h b/lfs.h index 101a41c0..fa228d33 100644 --- a/lfs.h +++ b/lfs.h @@ -398,7 +398,7 @@ typedef struct lfsr_mdir { lfs_off_t eoff; uint32_t cksum; lfs_block_t blocks[2]; - } m; + } mdir; lfsr_rbyd_t rbyd; } u; } lfsr_mdir_t; @@ -490,7 +490,8 @@ typedef struct lfs_dir { } lfs_dir_t; typedef struct lfsr_dir { - lfsr_openedmdir_t m; + lfsr_openedmdir_t *next; + lfsr_mdir_t mdir; lfsr_did_t did; lfsr_smid_t bookmark; lfs_soff_t pos; @@ -537,7 +538,8 @@ typedef struct lfsr_bshrub { } lfsr_bshrub_t; typedef struct lfsr_file { - lfsr_openedmdir_t m; + lfsr_openedmdir_t *next; + lfsr_mdir_t mdir; uint32_t flags; lfs_off_t pos; lfs_off_t size; diff --git a/tests/test_alloc.toml b/tests/test_alloc.toml index d07e4344..1b848cba 100644 --- a/tests/test_alloc.toml +++ b/tests/test_alloc.toml @@ -176,13 +176,14 @@ code = ''' if (tinfo.tag == LFSR_TAG_MDIR) { printf("traversal: 0x%x mdir 0x{%x,%x}\n", tinfo.tag, - tinfo.u.mdir.u.m.blocks[0], tinfo.u.mdir.u.m.blocks[1]); + tinfo.u.mdir.u.mdir.blocks[0], + tinfo.u.mdir.u.mdir.blocks[1]); // keep track of seen blocks - seen[tinfo.u.mdir.u.m.blocks[1] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[1] % 8); - seen[tinfo.u.mdir.u.m.blocks[0] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[0] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[1] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[1] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[0] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[0] % 8); } else if (tinfo.tag == LFSR_TAG_BRANCH) { printf("traversal: 0x%x btree 0x%x.%x\n", @@ -331,13 +332,14 @@ code = ''' if (tinfo.tag == LFSR_TAG_MDIR) { printf("traversal: 0x%x mdir 0x{%x,%x}\n", tinfo.tag, - tinfo.u.mdir.u.m.blocks[0], tinfo.u.mdir.u.m.blocks[1]); + tinfo.u.mdir.u.mdir.blocks[0], + tinfo.u.mdir.u.mdir.blocks[1]); // keep track of seen blocks - seen[tinfo.u.mdir.u.m.blocks[1] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[1] % 8); - seen[tinfo.u.mdir.u.m.blocks[0] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[0] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[1] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[1] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[0] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[0] % 8); } else if (tinfo.tag == LFSR_TAG_BRANCH) { printf("traversal: 0x%x btree 0x%x.%x\n", @@ -476,13 +478,14 @@ code = ''' if (tinfo.tag == LFSR_TAG_MDIR) { printf("traversal: 0x%x mdir 0x{%x,%x}\n", tinfo.tag, - tinfo.u.mdir.u.m.blocks[0], tinfo.u.mdir.u.m.blocks[1]); + tinfo.u.mdir.u.mdir.blocks[0], + tinfo.u.mdir.u.mdir.blocks[1]); // keep track of seen blocks - seen[tinfo.u.mdir.u.m.blocks[1] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[1] % 8); - seen[tinfo.u.mdir.u.m.blocks[0] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[0] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[1] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[1] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[0] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[0] % 8); } else if (tinfo.tag == LFSR_TAG_BRANCH) { printf("traversal: 0x%x btree 0x%x.%x\n", diff --git a/tests/test_mtree.toml b/tests/test_mtree.toml index 7db7fb95..54843fbd 100644 --- a/tests/test_mtree.toml +++ b/tests/test_mtree.toml @@ -184,7 +184,7 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -194,7 +194,7 @@ code = ''' // assert that our entry is still in the mtree lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -209,7 +209,7 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -218,7 +218,7 @@ code = ''' // assert that our entry is still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -257,18 +257,18 @@ code = ''' // assert mdirs were unininlined and split assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our entries are still in the mtree lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "a", 1) == 0); lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "b", 1) == 0); @@ -282,17 +282,17 @@ code = ''' // assert mdirs were unininlined and split assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our entries are still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "a", 1) == 0); lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "b", 1) == 0); @@ -330,12 +330,12 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // now add another large entry to the mdir, forcing a split lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+1, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); memset(buffer, 'c', SIZE); lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( @@ -348,7 +348,7 @@ code = ''' // assert mdir was split correctly assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot still has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -357,13 +357,13 @@ code = ''' // assert that our entries are still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "b", 1) == 0); lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "c", 1) == 0); @@ -376,7 +376,7 @@ code = ''' // assert mdir was split correctly assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot still has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -385,13 +385,13 @@ code = ''' // assert that our entries are still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "b", 1) == 0); lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "c", 1) == 0); @@ -450,7 +450,7 @@ code = ''' mid += lfsr_mweight(&lfs)) { lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -476,7 +476,7 @@ code = ''' mid += lfsr_mweight(&lfs)) { lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -522,7 +522,7 @@ code = ''' lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; // limit our mid to our mdir's weight mdir.mid = lfsr_mdir_bid(&lfs, &mdir)-(lfsr_mweight(&lfs)-1) - + (mdir.mid % (mdir.u.m.weight+1)); + + (mdir.mid % (mdir.u.rbyd.weight+1)); // force a compaction? if (FORCE_COMPACTION) { @@ -554,7 +554,7 @@ code = ''' mid += lfsr_mweight(&lfs)) { lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -584,7 +584,7 @@ code = ''' mid += lfsr_mweight(&lfs)) { lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -635,12 +635,12 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // remove the entry, forcing the mdir to be dropped lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( LFSR_ATTR(0, RM, -1, NULL()))) => 0; @@ -648,7 +648,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 0*lfsr_mweight(&lfs)); // assert mroot still has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -664,7 +664,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 0*lfsr_mweight(&lfs)); // assert mroot still has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -704,12 +704,12 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // remove the entry, forcing the mdir to be dropped lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); // force mdir to compact while we're removing mdir.u.rbyd.eoff = -1; @@ -720,7 +720,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 0*lfsr_mweight(&lfs)); // assert mroot still has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -736,7 +736,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 0*lfsr_mweight(&lfs)); // assert mroot still has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -779,7 +779,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 0*lfsr_mweight(&lfs)); // assert mroot has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -795,7 +795,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 0*lfsr_mweight(&lfs)); // assert mroot has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -839,12 +839,12 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that one entry is still in the mtree lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -859,11 +859,11 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that one entry is still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -906,12 +906,12 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that one entry is still in the mtree lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -926,11 +926,11 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that one entry is still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -973,7 +973,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 0*lfsr_mweight(&lfs)); // assert mroot has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); lfsr_unmount(&lfs) => 0; @@ -984,7 +984,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 0*lfsr_mweight(&lfs)); // assert mroot has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); lfsr_unmount(&lfs) => 0; ''' @@ -1019,12 +1019,12 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // now add another large entry to the mdir, forcing a split lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+1, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); memset(buffer, 'c', SIZE); lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( @@ -1042,7 +1042,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -1051,7 +1051,7 @@ code = ''' // assert that one entry is still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -1066,7 +1066,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -1075,7 +1075,7 @@ code = ''' // assert that one entry is still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -1114,12 +1114,12 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // now add another large entry to the mdir, forcing a split lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+1, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); memset(buffer, 'c', SIZE); lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( @@ -1136,7 +1136,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -1145,7 +1145,7 @@ code = ''' // assert that one entry is still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -1160,7 +1160,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -1169,7 +1169,7 @@ code = ''' // assert that one entry is still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -1208,12 +1208,12 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // now add another large entry to the mdir, forcing a split lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+1, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); memset(buffer, 'c', SIZE); lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( @@ -1230,7 +1230,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 0*lfsr_mweight(&lfs)); // assert mroot has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -1246,7 +1246,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 0*lfsr_mweight(&lfs)); // assert mroot has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -1301,7 +1301,7 @@ code = ''' 0*lfsr_mweight(&lfs)+0, &mdir) => 0; // drop should make sure we never have empty mdirs - assert(lfsr_mtree_ismptr(&lfs) || mdir.u.m.weight > 0); + assert(lfsr_mtree_ismptr(&lfs) || mdir.u.rbyd.weight > 0); // force a compaction? if (FORCE_COMPACTION) { @@ -1322,7 +1322,7 @@ code = ''' mid += lfsr_mweight(&lfs)) { lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -1348,7 +1348,7 @@ code = ''' mid += lfsr_mweight(&lfs)) { lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -1410,7 +1410,7 @@ code = ''' mid += lfsr_mweight(&lfs)) { lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -1428,7 +1428,7 @@ code = ''' 0*lfsr_mweight(&lfs)+0, &mdir) => 0; // drop should make sure we never have empty mdirs - assert(lfsr_mtree_ismptr(&lfs) || mdir.u.m.weight > 0); + assert(lfsr_mtree_ismptr(&lfs) || mdir.u.rbyd.weight > 0); // force a compaction? if (FORCE_COMPACTION) { @@ -1449,7 +1449,7 @@ code = ''' mid += lfsr_mweight(&lfs)) { lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -1476,7 +1476,7 @@ code = ''' mid += lfsr_mweight(&lfs)) { lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -1521,10 +1521,10 @@ code = ''' lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; // limit our mid to our mdir's weight mdir.mid = lfsr_mdir_bid(&lfs, &mdir)-(lfsr_mweight(&lfs)-1) - + (mdir.mid % (mdir.u.m.weight+1)); + + (mdir.mid % (mdir.u.rbyd.weight+1)); // choose to create or delete, note we make sure to never delete to zero - uint8_t op = (lfsr_mdir_rid(&lfs, &mdir) == mdir.u.m.weight - || (lfsr_mdir_rid(&lfs, &mdir) == mdir.u.m.weight-1 + uint8_t op = (lfsr_mdir_rid(&lfs, &mdir) == mdir.u.rbyd.weight + || (lfsr_mdir_rid(&lfs, &mdir) == mdir.u.rbyd.weight-1 && lfsr_mtree_weight(&lfs) == lfsr_mweight(&lfs)) ? 0 : TEST_PRNG(&prng) % 2); @@ -1571,9 +1571,9 @@ code = ''' lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; // drop should make sure we never have empty mdirs - assert(lfsr_mtree_ismptr(&lfs) || mdir.u.m.weight > 0); + assert(lfsr_mtree_ismptr(&lfs) || mdir.u.rbyd.weight > 0); - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -1605,9 +1605,9 @@ code = ''' lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; // drop should make sure we never have empty mdirs - assert(lfsr_mtree_ismptr(&lfs) || mdir.u.m.weight > 0); + assert(lfsr_mtree_ismptr(&lfs) || mdir.u.rbyd.weight > 0); - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -1661,12 +1661,12 @@ code = ''' // assert mtree has one mdir assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // force mdir to compact twice, this should relocate lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_t old_mdir = mdir; @@ -1687,7 +1687,7 @@ code = ''' // assert that our entry is still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -1702,7 +1702,7 @@ code = ''' // assert mtree has one mdir assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert we relocated assert(lfsr_mdir_cmp(&old_mdir, &mdir) != 0); @@ -1714,7 +1714,7 @@ code = ''' // assert that our entry is still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -1755,12 +1755,12 @@ code = ''' // assert mdirs were unininlined and split assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // force mdir to compact twice, this should relocate lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_t old_mdir = mdir; @@ -1776,13 +1776,13 @@ code = ''' // assert that our entries are still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "c", 1) == 0); lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "b", 1) == 0); @@ -1796,20 +1796,20 @@ code = ''' // assert mdirs were unininlined and split assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert we relocated assert(lfsr_mdir_cmp(&old_mdir, &mdir) != 0); // assert that our entries are still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "c", 1) == 0); lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "b", 1) == 0); @@ -1849,12 +1849,12 @@ code = ''' // assert mdirs were unininlined and split assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // force mdir to compact twice, this should relocate lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_t old_mdir = mdir; @@ -1870,13 +1870,13 @@ code = ''' // assert that our entries are still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "a", 1) == 0); lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "c", 1) == 0); @@ -1890,20 +1890,20 @@ code = ''' // assert mdirs were unininlined and split assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert we relocated assert(lfsr_mdir_cmp(&old_mdir, &mdir) != 0); // assert that our entries are still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "a", 1) == 0); lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "c", 1) == 0); @@ -2128,7 +2128,7 @@ code = ''' // assert mtree has one mdir assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // setup mroot to need to compact, this should trigger a relocation when // we relocate the mdir below @@ -2138,7 +2138,7 @@ code = ''' // force mdir to compact twice, this should relocate lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_t old_mdir = mdir; @@ -2162,7 +2162,7 @@ code = ''' // assert that our entry is still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -2177,7 +2177,7 @@ code = ''' // assert mtree has one mdir assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert we relocated our mdir assert(lfsr_mdir_cmp(&old_mdir, &mdir) != 0); @@ -2192,7 +2192,7 @@ code = ''' // assert that our entry is still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -2233,7 +2233,7 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // setup mroot to need to compact, this should trigger a relocation when // we relocate the mdir below @@ -2243,7 +2243,7 @@ code = ''' // now add another large entry to the mdir, forcing a split lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+1, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); memset(buffer, 'c', SIZE); lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( @@ -2256,7 +2256,7 @@ code = ''' // assert mdir was split correctly assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot still has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert we relocated our mroot assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0); @@ -2268,13 +2268,13 @@ code = ''' // assert that our entries are still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "b", 1) == 0); lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "c", 1) == 0); @@ -2288,7 +2288,7 @@ code = ''' // assert mdir was split correctly assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot still has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert we relocated our mroot assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0); @@ -2300,13 +2300,13 @@ code = ''' // assert that our entries are still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "b", 1) == 0); lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "c", 1) == 0); @@ -2346,7 +2346,7 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // setup mroot to need to compact, this should trigger a relocation when // we relocate the mdir below @@ -2356,7 +2356,7 @@ code = ''' // remove the entry, forcing the mdir to be dropped lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( LFSR_ATTR(mdir.mid, RM, -1, NULL()))) => 0; @@ -2364,7 +2364,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 0*lfsr_mweight(&lfs)); // assert mroot still has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert we relocated our mroot assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0); @@ -2383,7 +2383,7 @@ code = ''' // assert mdir was dropped assert(lfsr_mtree_weight(&lfs) == 0*lfsr_mweight(&lfs)); // assert mroot still has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert we relocated our mroot assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0); @@ -2435,7 +2435,7 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert we relocated our mroot assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0); @@ -2448,7 +2448,7 @@ code = ''' // assert that our entry is still in the mtree lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -2463,7 +2463,7 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert we relocated our mroot assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0); @@ -2475,7 +2475,7 @@ code = ''' // assert that our entry is still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -2522,7 +2522,7 @@ code = ''' // assert mdirs were unininlined and split assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert we relocated our mroot assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0); @@ -2530,13 +2530,13 @@ code = ''' // assert that our entries are still in the mtree lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "a", 1) == 0); lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "b", 1) == 0); @@ -2550,20 +2550,20 @@ code = ''' // assert mdirs were unininlined and split assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert we relocated our mroot assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0); // assert that our entries are still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "a", 1) == 0); lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "b", 1) == 0); @@ -2604,10 +2604,10 @@ code = ''' lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; // limit our mid to our mdir's weight mdir.mid = lfsr_mdir_bid(&lfs, &mdir)-(lfsr_mweight(&lfs)-1) - + (mdir.mid % (mdir.u.m.weight+1)); + + (mdir.mid % (mdir.u.rbyd.weight+1)); // choose to create or delete, note we make sure to never delete to zero - uint8_t op = (lfsr_mdir_rid(&lfs, &mdir) == mdir.u.m.weight - || (lfsr_mdir_rid(&lfs, &mdir) == mdir.u.m.weight-1 + uint8_t op = (lfsr_mdir_rid(&lfs, &mdir) == mdir.u.rbyd.weight + || (lfsr_mdir_rid(&lfs, &mdir) == mdir.u.rbyd.weight-1 && lfsr_mtree_weight(&lfs) == lfsr_mweight(&lfs)) ? 0 : TEST_PRNG(&prng) % 3); @@ -2667,9 +2667,9 @@ code = ''' lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; // drop should make sure we never have empty mdirs - assert(lfsr_mtree_ismptr(&lfs) || mdir.u.m.weight > 0); + assert(lfsr_mtree_ismptr(&lfs) || mdir.u.rbyd.weight > 0); - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -2701,9 +2701,9 @@ code = ''' lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; // drop should make sure we never have empty mdirs - assert(lfsr_mtree_ismptr(&lfs) || mdir.u.m.weight > 0); + assert(lfsr_mtree_ismptr(&lfs) || mdir.u.rbyd.weight > 0); - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -2742,9 +2742,9 @@ code = ''' assert(lfsr_mtree_ismptr(&lfs)); lfsr_openedmdir_t left_neighbor = { - .mdir={.mid=0, .u.m=lfs.mroot.u.m}}; + .mdir={.mid=0, .u.mdir=lfs.mroot.u.mdir}}; lfsr_openedmdir_t right_neighbor = { - .mdir={.mid=1, .u.m=lfs.mroot.u.m}}; + .mdir={.mid=1, .u.mdir=lfs.mroot.u.mdir}}; lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -2753,7 +2753,7 @@ code = ''' LFSR_ATTR(1, REG, +1, BUF("c", 1)))) => 0; // assert that our entry is still in the mtree - assert(lfs.mroot.u.m.weight == 3); + assert(lfs.mroot.u.rbyd.weight == 3); uint8_t buffer[1]; lfsr_mdir_get(&lfs, &lfs.mroot, 1, LFSR_TAG_REG, @@ -2762,11 +2762,11 @@ code = ''' // assert that our neighbors were updated correctly assert(left_neighbor.mdir.mid == 0); - assert(memcmp(&left_neighbor.mdir.u.m, &lfs.mroot.u.m, - sizeof(lfs.mroot.u.m)) == 0); + assert(memcmp(&left_neighbor.mdir.u.mdir, &lfs.mroot.u.mdir, + sizeof(lfs.mroot.u.mdir)) == 0); assert(right_neighbor.mdir.mid == 2); - assert(memcmp(&right_neighbor.mdir.u.m, &lfs.mroot.u.m, - sizeof(lfs.mroot.u.m)) == 0); + assert(memcmp(&right_neighbor.mdir.u.mdir, &lfs.mroot.u.mdir, + sizeof(lfs.mroot.u.mdir)) == 0); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -2792,9 +2792,9 @@ code = ''' assert(lfsr_mtree_ismptr(&lfs)); lfsr_openedmdir_t left_neighbor = { - .mdir={.mid=0, .u.m=lfs.mroot.u.m}}; + .mdir={.mid=0, .u.mdir=lfs.mroot.u.mdir}}; lfsr_openedmdir_t right_neighbor = { - .mdir={.mid=1, .u.m=lfs.mroot.u.m}}; + .mdir={.mid=1, .u.mdir=lfs.mroot.u.mdir}}; lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -2803,13 +2803,13 @@ code = ''' LFSR_ATTR(0, RM, -1, NULL()))) => 0; // assert that an entry was removed - assert(lfs.mroot.u.m.weight == 1); + assert(lfs.mroot.u.rbyd.weight == 1); // assert that our neighbors were updated correctly assert(left_neighbor.mdir.mid == -1); assert(right_neighbor.mdir.mid == 0); - assert(memcmp(&right_neighbor.mdir.u.m, &lfs.mroot.u.m, - sizeof(lfs.mroot.u.m)) == 0); + assert(memcmp(&right_neighbor.mdir.u.mdir, &lfs.mroot.u.mdir, + sizeof(lfs.mroot.u.mdir)) == 0); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -2835,9 +2835,9 @@ code = ''' assert(lfsr_mtree_ismptr(&lfs)); lfsr_openedmdir_t left_neighbor = { - .mdir={.mid=0, .u.m=lfs.mroot.u.m}}; + .mdir={.mid=0, .u.mdir=lfs.mroot.u.mdir}}; lfsr_openedmdir_t right_neighbor = { - .mdir={.mid=1, .u.m=lfs.mroot.u.m}}; + .mdir={.mid=1, .u.mdir=lfs.mroot.u.mdir}}; lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -2846,12 +2846,12 @@ code = ''' LFSR_ATTR(1, RM, -1, NULL()))) => 0; // assert that an entry was removed - assert(lfs.mroot.u.m.weight == 1); + assert(lfs.mroot.u.rbyd.weight == 1); // assert that our neighbors were updated correctly assert(left_neighbor.mdir.mid == 0); - assert(memcmp(&left_neighbor.mdir.u.m, &lfs.mroot.u.m, - sizeof(lfs.mroot.u.m)) == 0); + assert(memcmp(&left_neighbor.mdir.u.mdir, &lfs.mroot.u.mdir, + sizeof(lfs.mroot.u.mdir)) == 0); assert(right_neighbor.mdir.mid == -1); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); @@ -2880,9 +2880,9 @@ code = ''' assert(lfsr_mtree_ismptr(&lfs)); lfsr_openedmdir_t left_neighbor = { - .mdir={.mid=0, .u.m=lfs.mroot.u.m}}; + .mdir={.mid=0, .u.mdir=lfs.mroot.u.mdir}}; lfsr_openedmdir_t right_neighbor = { - .mdir={.mid=1, .u.m=lfs.mroot.u.m}}; + .mdir={.mid=1, .u.mdir=lfs.mroot.u.mdir}}; lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -2904,7 +2904,7 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -2914,7 +2914,7 @@ code = ''' // assert that our entry is still in the mtree lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+1, &mdir) => 0; - assert(mdir.u.m.weight == 2); + assert(mdir.u.rbyd.weight == 2); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "d", 1) == 0); @@ -2924,15 +2924,15 @@ code = ''' lfsr_mdir_t msibling; lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &msibling) => 0; - assert(msibling.u.m.weight == 1); + assert(msibling.u.rbyd.weight == 1); // assert that our neighbors were updated correctly assert(left_neighbor.mdir.mid == 0*lfsr_mweight(&lfs)+0); - assert(memcmp(&left_neighbor.mdir.u.m, &mdir.u.m, - sizeof(mdir.u.m)) == 0); + assert(memcmp(&left_neighbor.mdir.u.mdir, &mdir.u.mdir, + sizeof(mdir.u.mdir)) == 0); assert(right_neighbor.mdir.mid == 1*lfsr_mweight(&lfs)+0); - assert(memcmp(&right_neighbor.mdir.u.m, &msibling.u.m, - sizeof(msibling.u.m)) == 0); + assert(memcmp(&right_neighbor.mdir.u.mdir, &msibling.u.mdir, + sizeof(msibling.u.mdir)) == 0); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -2960,9 +2960,9 @@ code = ''' assert(lfsr_mtree_ismptr(&lfs)); lfsr_openedmdir_t left_neighbor = { - .mdir={.mid=0, .u.m=lfs.mroot.u.m}}; + .mdir={.mid=0, .u.mdir=lfs.mroot.u.mdir}}; lfsr_openedmdir_t right_neighbor = { - .mdir={.mid=1, .u.m=lfs.mroot.u.m}}; + .mdir={.mid=1, .u.mdir=lfs.mroot.u.mdir}}; lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -2983,12 +2983,12 @@ code = ''' // assert mdirs were unininlined and split assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our entries are still in the mtree lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+1, &mdir) => 0; - assert(mdir.u.m.weight == 2); + assert(mdir.u.rbyd.weight == 2); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "c", 1) == 0); @@ -2996,18 +2996,18 @@ code = ''' lfsr_mdir_t msibling; lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &msibling) => 0; - assert(msibling.u.m.weight == 2); + assert(msibling.u.rbyd.weight == 2); lfsr_mdir_get(&lfs, &msibling, msibling.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "d", 1) == 0); // assert that our neighbors were updated correctly assert(left_neighbor.mdir.mid == 0*lfsr_mweight(&lfs)+0); - assert(memcmp(&left_neighbor.mdir.u.m, &mdir.u.m, - sizeof(mdir.u.m)) == 0); + assert(memcmp(&left_neighbor.mdir.u.mdir, &mdir.u.mdir, + sizeof(mdir.u.mdir)) == 0); assert(right_neighbor.mdir.mid == 1*lfsr_mweight(&lfs)+1); - assert(memcmp(&right_neighbor.mdir.u.m, &msibling.u.m, - sizeof(msibling.u.m)) == 0); + assert(memcmp(&right_neighbor.mdir.u.mdir, &msibling.u.mdir, + sizeof(msibling.u.mdir)) == 0); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -3044,7 +3044,7 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // setup our neighbors // @@ -3052,19 +3052,19 @@ code = ''' // aggresively split the mtree if there are already neighbors in the mdir lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( LFSR_ATTR(mdir.mid+0, REG, +1, BUF("a", 1)), LFSR_ATTR(mdir.mid+2, REG, +1, BUF("b", 1)))) => 0; // this test only works if these all fit in the mdir assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); - assert(mdir.u.m.weight == 3); + assert(mdir.u.rbyd.weight == 3); lfsr_openedmdir_t left_neighbor = { - .mdir={.mid=mdir.mid+0, .u.m=mdir.u.m}}; + .mdir={.mid=mdir.mid+0, .u.mdir=mdir.u.mdir}}; lfsr_openedmdir_t right_neighbor = { - .mdir={.mid=mdir.mid+2, .u.m=mdir.u.m}}; + .mdir={.mid=mdir.mid+2, .u.mdir=mdir.u.mdir}}; lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -3081,7 +3081,7 @@ code = ''' // assert mdir was split correctly assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot still has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -3090,7 +3090,7 @@ code = ''' // assert that our entries are still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+1, &mdir) => 0; - assert(mdir.u.m.weight == 2); + assert(mdir.u.rbyd.weight == 2); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "d", 1) == 0); @@ -3098,18 +3098,18 @@ code = ''' lfsr_mdir_t msibling; lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &msibling) => 0; - assert(msibling.u.m.weight == 2); + assert(msibling.u.rbyd.weight == 2); lfsr_mdir_get(&lfs, &msibling, msibling.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "e", 1) == 0); // assert that our neighbors were updated correctly assert(left_neighbor.mdir.mid == 0*lfsr_mweight(&lfs)+0); - assert(memcmp(&left_neighbor.mdir.u.m, &mdir.u.m, - sizeof(mdir.u.m)) == 0); + assert(memcmp(&left_neighbor.mdir.u.mdir, &mdir.u.mdir, + sizeof(mdir.u.mdir)) == 0); assert(right_neighbor.mdir.mid == 1*lfsr_mweight(&lfs)+1); - assert(memcmp(&right_neighbor.mdir.u.m, &msibling.u.m, - sizeof(msibling.u.m)) == 0); + assert(memcmp(&right_neighbor.mdir.u.mdir, &msibling.u.mdir, + sizeof(msibling.u.mdir)) == 0); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -3139,9 +3139,9 @@ code = ''' assert(lfsr_mtree_ismptr(&lfs)); lfsr_openedmdir_t left_neighbor = { - .mdir={.mid=0, .u.m=lfs.mroot.u.m}}; + .mdir={.mid=0, .u.mdir=lfs.mroot.u.mdir}}; lfsr_openedmdir_t right_neighbor = { - .mdir={.mid=1, .u.m=lfs.mroot.u.m}}; + .mdir={.mid=1, .u.mdir=lfs.mroot.u.mdir}}; lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -3171,11 +3171,11 @@ code = ''' // assert that our neighbors were updated correctly assert(left_neighbor.mdir.mid == 0); - assert(memcmp(&left_neighbor.mdir.u.m, &lfs.mroot.u.m, - sizeof(lfs.mroot.u.m)) == 0); + assert(memcmp(&left_neighbor.mdir.u.mdir, &lfs.mroot.u.mdir, + sizeof(lfs.mroot.u.mdir)) == 0); assert(right_neighbor.mdir.mid == 1); - assert(memcmp(&right_neighbor.mdir.u.m, &lfs.mroot.u.m, - sizeof(lfs.mroot.u.m)) == 0); + assert(memcmp(&right_neighbor.mdir.u.mdir, &lfs.mroot.u.mdir, + sizeof(lfs.mroot.u.mdir)) == 0); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -3214,7 +3214,7 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // setup our neighbors // @@ -3222,19 +3222,19 @@ code = ''' // aggresively split the mtree if there are already neighbors in the mdir lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( LFSR_ATTR(mdir.mid+0, REG, +1, BUF("a", 1)), LFSR_ATTR(mdir.mid+2, REG, +1, BUF("b", 1)))) => 0; // this test only works if these all fit in the mdir assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); - assert(mdir.u.m.weight == 3); + assert(mdir.u.rbyd.weight == 3); lfsr_openedmdir_t left_neighbor = { - .mdir={.mid=mdir.mid+0, .u.m=mdir.u.m}}; + .mdir={.mid=mdir.mid+0, .u.mdir=mdir.u.mdir}}; lfsr_openedmdir_t right_neighbor = { - .mdir={.mid=mdir.mid+2, .u.m=mdir.u.m}}; + .mdir={.mid=mdir.mid+2, .u.mdir=mdir.u.mdir}}; lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -3258,7 +3258,7 @@ code = ''' // assert that our entry is still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+1, &mdir) => 0; - assert(mdir.u.m.weight == 3); + assert(mdir.u.rbyd.weight == 3); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -3266,9 +3266,11 @@ code = ''' // assert that our neighbors were updated correctly assert(left_neighbor.mdir.mid == 0*lfsr_mweight(&lfs)+0); - assert(memcmp(&left_neighbor.mdir.u.m, &mdir.u.m, sizeof(mdir.u.m)) == 0); + assert(memcmp(&left_neighbor.mdir.u.mdir, &mdir.u.mdir, + sizeof(mdir.u.mdir)) == 0); assert(right_neighbor.mdir.mid == 0*lfsr_mweight(&lfs)+2); - assert(memcmp(&right_neighbor.mdir.u.m, &mdir.u.m, sizeof(mdir.u.m)) == 0); + assert(memcmp(&right_neighbor.mdir.u.mdir, &mdir.u.mdir, + sizeof(mdir.u.mdir)) == 0); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -3311,7 +3313,7 @@ code = ''' // now force one of our siblings to split lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+1, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); memset(buffer, 'c', SIZE); lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( LFSR_ATTR(mdir.mid, REG, +1, BUF(buffer, SIZE)))) => 0; @@ -3330,19 +3332,19 @@ code = ''' lfsr_openedmdir_t left_neighbor; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &left_neighbor.mdir) => 0; - assert(left_neighbor.mdir.u.m.weight == 1); + assert(left_neighbor.mdir.u.rbyd.weight == 1); lfsr_openedmdir_t right_neighbor; lfsr_mtree_lookup(&lfs, 2*lfsr_mweight(&lfs)+0, &right_neighbor.mdir) => 0; - assert(right_neighbor.mdir.u.m.weight == 1); + assert(right_neighbor.mdir.u.rbyd.weight == 1); lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); // cause middle mdir to split lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+1, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); memset(buffer, 'd', SIZE); lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( LFSR_ATTR(mdir.mid, REG, +1, BUF(buffer, SIZE)))) => 0; @@ -3357,11 +3359,13 @@ code = ''' // assert that our neighbors were updated correctly assert(left_neighbor.mdir.mid == 0*lfsr_mweight(&lfs)+0); lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(memcmp(&left_neighbor.mdir.u.m, &mdir.u.m, sizeof(mdir.u.m)) == 0); + assert(memcmp(&left_neighbor.mdir.u.mdir, &mdir.u.mdir, + sizeof(mdir.u.mdir)) == 0); assert(right_neighbor.mdir.mid == 3*lfsr_mweight(&lfs)+0); lfsr_mtree_lookup(&lfs, 3*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(memcmp(&right_neighbor.mdir.u.m, &mdir.u.m, sizeof(mdir.u.m)) == 0); + assert(memcmp(&right_neighbor.mdir.u.mdir, &mdir.u.mdir, + sizeof(mdir.u.mdir)) == 0); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -3404,7 +3408,7 @@ code = ''' // now force one of our siblings to split lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+1, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); memset(buffer, 'c', SIZE); lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( LFSR_ATTR(mdir.mid, REG, +1, BUF(buffer, SIZE)))) => 0; @@ -3423,19 +3427,19 @@ code = ''' lfsr_openedmdir_t left_neighbor; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &left_neighbor.mdir) => 0; - assert(left_neighbor.mdir.u.m.weight == 1); + assert(left_neighbor.mdir.u.rbyd.weight == 1); lfsr_openedmdir_t right_neighbor; lfsr_mtree_lookup(&lfs, 2*lfsr_mweight(&lfs)+0, &right_neighbor.mdir) => 0; - assert(right_neighbor.mdir.u.m.weight == 1); + assert(right_neighbor.mdir.u.rbyd.weight == 1); lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); // cause middle mdir to drop lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( LFSR_ATTR(mdir.mid, RM, -1, NULL()))) => 0; @@ -3445,11 +3449,13 @@ code = ''' // assert that our neighbors were updated correctly assert(left_neighbor.mdir.mid == 0*lfsr_mweight(&lfs)+0); lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(memcmp(&left_neighbor.mdir.u.m, &mdir.u.m, sizeof(mdir.u.m)) == 0); + assert(memcmp(&left_neighbor.mdir.u.mdir, &mdir.u.mdir, + sizeof(mdir.u.mdir)) == 0); assert(right_neighbor.mdir.mid == 1*lfsr_mweight(&lfs)+0); lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(memcmp(&right_neighbor.mdir.u.m, &mdir.u.m, sizeof(mdir.u.m)) == 0); + assert(memcmp(&right_neighbor.mdir.u.mdir, &mdir.u.mdir, + sizeof(mdir.u.mdir)) == 0); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor); lfsr_mdir_removeopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor); @@ -3477,7 +3483,7 @@ code = ''' LFSR_ATTR(0, REG, +1, BUF("a", 1)))) => 0; // assert that our entry is still in the mtree - assert(lfs.mroot.u.m.weight == 1); + assert(lfs.mroot.u.rbyd.weight == 1); uint8_t buffer[1]; lfsr_mdir_get(&lfs, &lfs.mroot, 0, LFSR_TAG_REG, @@ -3504,13 +3510,14 @@ code = ''' if (tinfo.tag == LFSR_TAG_MDIR) { printf("traversal: 0x%x mdir 0x{%x,%x}\n", tinfo.tag, - tinfo.u.mdir.u.m.blocks[0], tinfo.u.mdir.u.m.blocks[1]); + tinfo.u.mdir.u.mdir.blocks[0], + tinfo.u.mdir.u.mdir.blocks[1]); // keep track of seen blocks - seen[tinfo.u.mdir.u.m.blocks[1] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[1] % 8); - seen[tinfo.u.mdir.u.m.blocks[0] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[0] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[1] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[1] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[0] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[0] % 8); } else if (tinfo.tag == LFSR_TAG_BRANCH) { printf("traversal: 0x%x btree 0x%x.%x\n", @@ -3541,7 +3548,7 @@ code = ''' // and the tree should still work // assert that our entry is still in the mtree - assert(lfs.mroot.u.m.weight == 1); + assert(lfs.mroot.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &lfs.mroot, 0, LFSR_TAG_REG, buffer, 1) => 1; @@ -3582,7 +3589,7 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -3592,7 +3599,7 @@ code = ''' // assert that our entry is still in the mtree lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -3618,13 +3625,14 @@ code = ''' if (tinfo.tag == LFSR_TAG_MDIR) { printf("traversal: 0x%x mdir 0x{%x,%x}\n", tinfo.tag, - tinfo.u.mdir.u.m.blocks[0], tinfo.u.mdir.u.m.blocks[1]); + tinfo.u.mdir.u.mdir.blocks[0], + tinfo.u.mdir.u.mdir.blocks[1]); // keep track of seen blocks - seen[tinfo.u.mdir.u.m.blocks[1] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[1] % 8); - seen[tinfo.u.mdir.u.m.blocks[0] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[0] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[1] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[1] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[0] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[0] % 8); } else if (tinfo.tag == LFSR_TAG_BRANCH) { printf("traversal: 0x%x btree 0x%x.%x\n", @@ -3657,7 +3665,7 @@ code = ''' // assert mdir was unininlined correctly assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our attr is still in the mroot lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1), @@ -3666,7 +3674,7 @@ code = ''' // assert that our entry is still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; @@ -3706,12 +3714,12 @@ code = ''' // assert mdirs were unininlined and split assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our entries are still in the mtree lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "a", 1) == 0); @@ -3719,7 +3727,7 @@ code = ''' lfsr_mdir_t msibling; lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &msibling) => 0; - assert(msibling.u.m.weight == 1); + assert(msibling.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &msibling, msibling.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "b", 1) == 0); @@ -3744,13 +3752,14 @@ code = ''' if (tinfo.tag == LFSR_TAG_MDIR) { printf("traversal: 0x%x mdir 0x{%x,%x}\n", tinfo.tag, - tinfo.u.mdir.u.m.blocks[0], tinfo.u.mdir.u.m.blocks[1]); + tinfo.u.mdir.u.mdir.blocks[0], + tinfo.u.mdir.u.mdir.blocks[1]); // keep track of seen blocks - seen[tinfo.u.mdir.u.m.blocks[1] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[1] % 8); - seen[tinfo.u.mdir.u.m.blocks[0] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[0] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[1] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[1] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[0] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[0] % 8); } else if (tinfo.tag == LFSR_TAG_BRANCH) { printf("traversal: 0x%x btree 0x%x.%x\n", @@ -3783,18 +3792,18 @@ code = ''' // assert mdirs were unininlined and split assert(lfsr_mtree_weight(&lfs) == 2*lfsr_mweight(&lfs)); // assert mroot now has no entries - assert(lfs.mroot.u.m.weight == 0); + assert(lfs.mroot.u.rbyd.weight == 0); // assert that our entries are still in the mtree lfsr_mtree_lookup(&lfs, 0*lfsr_mweight(&lfs)+0, &mdir) => 0; - assert(mdir.u.m.weight == 1); + assert(mdir.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "a", 1) == 0); lfsr_mtree_lookup(&lfs, 1*lfsr_mweight(&lfs)+0, &msibling) => 0; - assert(msibling.u.m.weight == 1); + assert(msibling.u.rbyd.weight == 1); lfsr_mdir_get(&lfs, &msibling, msibling.mid, LFSR_TAG_REG, buffer, SIZE) => SIZE; assert(memcmp(buffer, "b", 1) == 0); @@ -3862,13 +3871,14 @@ code = ''' if (tinfo.tag == LFSR_TAG_MDIR) { printf("traversal: 0x%x mdir 0x{%x,%x}\n", tinfo.tag, - tinfo.u.mdir.u.m.blocks[0], tinfo.u.mdir.u.m.blocks[1]); + tinfo.u.mdir.u.mdir.blocks[0], + tinfo.u.mdir.u.mdir.blocks[1]); // keep track of seen blocks - seen[tinfo.u.mdir.u.m.blocks[1] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[1] % 8); - seen[tinfo.u.mdir.u.m.blocks[0] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[0] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[1] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[1] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[0] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[0] % 8); } else if (tinfo.tag == LFSR_TAG_BRANCH) { printf("traversal: 0x%x btree 0x%x.%x\n", @@ -3960,7 +3970,7 @@ code = ''' mid += lfsr_mweight(&lfs)) { lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -3991,13 +4001,14 @@ code = ''' if (tinfo.tag == LFSR_TAG_MDIR) { printf("traversal: 0x%x mdir 0x{%x,%x}\n", tinfo.tag, - tinfo.u.mdir.u.m.blocks[0], tinfo.u.mdir.u.m.blocks[1]); + tinfo.u.mdir.u.mdir.blocks[0], + tinfo.u.mdir.u.mdir.blocks[1]); // keep track of seen blocks - seen[tinfo.u.mdir.u.m.blocks[1] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[1] % 8); - seen[tinfo.u.mdir.u.m.blocks[0] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[0] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[1] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[1] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[0] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[0] % 8); } else if (tinfo.tag == LFSR_TAG_BRANCH) { printf("traversal: 0x%x btree 0x%x.%x\n", @@ -4036,7 +4047,7 @@ code = ''' mid += lfsr_mweight(&lfs)) { lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -4082,7 +4093,7 @@ code = ''' lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; // limit our mid to our mdir's weight mdir.mid = lfsr_mdir_bid(&lfs, &mdir)-(lfsr_mweight(&lfs)-1) - + (mdir.mid % (mdir.u.m.weight+1)); + + (mdir.mid % (mdir.u.rbyd.weight+1)); // force a compaction? if (FORCE_COMPACTION) { @@ -4114,7 +4125,7 @@ code = ''' mid += lfsr_mweight(&lfs)) { lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -4149,13 +4160,14 @@ code = ''' if (tinfo.tag == LFSR_TAG_MDIR) { printf("traversal: 0x%x mdir 0x{%x,%x}\n", tinfo.tag, - tinfo.u.mdir.u.m.blocks[0], tinfo.u.mdir.u.m.blocks[1]); + tinfo.u.mdir.u.mdir.blocks[0], + tinfo.u.mdir.u.mdir.blocks[1]); // keep track of seen blocks - seen[tinfo.u.mdir.u.m.blocks[1] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[1] % 8); - seen[tinfo.u.mdir.u.m.blocks[0] / 8] - |= 1 << (tinfo.u.mdir.u.m.blocks[0] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[1] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[1] % 8); + seen[tinfo.u.mdir.u.mdir.blocks[0] / 8] + |= 1 << (tinfo.u.mdir.u.mdir.blocks[0] % 8); } else if (tinfo.tag == LFSR_TAG_BRANCH) { printf("traversal: 0x%x btree 0x%x.%x\n", @@ -4195,7 +4207,7 @@ code = ''' mid += lfsr_mweight(&lfs)) { lfsr_mdir_t mdir; lfsr_mtree_lookup(&lfs, mid, &mdir) => 0; - for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.m.weight; + for (; lfsr_mdir_rid(&lfs, &mdir) < mdir.u.rbyd.weight; mdir.mid += 1) { uint8_t buffer[4]; lfsr_mdir_get(&lfs, &mdir, mdir.mid, LFSR_TAG_REG, @@ -4245,7 +4257,8 @@ code = ''' if (tinfo.tag == LFSR_TAG_MDIR) { printf("traversal: 0x%x mdir 0x{%x,%x}\n", tinfo.tag, - tinfo.u.mdir.u.m.blocks[0], tinfo.u.mdir.u.m.blocks[1]); + tinfo.u.mdir.u.mdir.blocks[0], + tinfo.u.mdir.u.mdir.blocks[1]); } else if (tinfo.tag == LFSR_TAG_BRANCH) { printf("traversal: 0x%x btree 0x%x.%x\n",