From 3a90d1046b79a354b4b603c0474fbd1f733864d0 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Fri, 26 Jan 2024 22:56:58 -0600 Subject: [PATCH] Reverted insert tags appending, fixed insert issues in named btrees Changing insert tags to append seems to have broken insertion into named btrees in a subtle way. Consider what happens when we insert immediately before a bid that splits the btree: 1. namelookup returns the right rbyd, with rid=-1 2. converting this into a bid gives us the left rbyd, with rid=weight 3. the commit to insert the bid ends up inserting into the left rbyd This doesn't initially seem like an issue, both entries are effectively the same right? Well, not when you have names. The split name tells you what _follows_, so this unintentional flipping causes the new name to get placed in the wrong bucket. It's not clear if it's possible to fix this, at least not without inverting the split names to indicate what precedes, but that's a step too far. This was not detected earlier because I disabled the low-level rbyd/btree/mtree tests temporarily due to high porting cost. Guess that goes to show there's a cost to deferring test ports for too long. --- This issue, along with being inconsistencies between rids/bids and mids, and being a relatively unintuitive pattern, is the final nail in the coffin for insert tags inserting after. Now, insert tags insert before, like in most other systems, and insert tags in attr-list just have an implicit +1 before them to allow splits in attr-lists to work. This is not a pure revert, as some of the changes with all the code moving around revealed some better detail-level ideas. And yes, rbyd/btree tests are up to date now. Unfortunately the mtree tests require a bit more work. --- One thing definitely worth noting, btree merges were broken! A mistake in the has-parent condition meant we were never attempting to merge btrees! This hid some bugs in the actual btree merge code caused by mixing the implicit swap of child rbyds to deduplicate code paths with btree commit now needing to track bid/rid separately from the attr-list. This should be fixed now. Interesting to note this bug has been in lfsr_btree_commit_ for a while now! I think ever since we switched to using trunks for the has-parent check. We just haven't been merging btree nodes at all. But since not-merging isn't technically an error, it's difficult to test for. Code changes: code stack before: 33808 2896 after: 33964 (+0.5%) 2896 (+0.0%) --- lfs.c | 116 ++++++++++++-------- tests/test_btree.toml | 26 ++--- tests/test_rbyd.toml | 246 +++++++++++++++++++++--------------------- 3 files changed, 205 insertions(+), 183 deletions(-) diff --git a/lfs.c b/lfs.c index efa05a26..4ff82d69 100644 --- a/lfs.c +++ b/lfs.c @@ -2547,6 +2547,9 @@ static int lfsr_rbyd_appendattr(lfs_t *lfs, lfsr_rbyd_t *rbyd, if (delta > 0) { LFS_ASSERT(rid <= rbyd->weight); + // it's a bit ugly, but adjusting the rid here makes the following + // logic work out more consistently + rid -= 1; rid_ = rid + 1; other_rid_ = rid + 1; } else { @@ -3151,15 +3154,20 @@ static int lfsr_rbyd_appendattrs(lfs_t *lfs, const lfsr_attr_t *attrs, lfs_size_t attr_count) { // append each tag to the tree for (lfs_size_t i = 0; i < attr_count; i++) { + // treat inserts after the first tag as though they are splits, + // sequential inserts don't really make sense otherwise + if (i > 0 + && !lfsr_tag_isgrow(attrs[i].tag) + && attrs[i].delta > 0) { + rid += 1; + } + // don't write tags outside of the requested range - lfsr_srid_t rid_ = rid + ( - (!lfsr_tag_isgrow(attrs[i].tag) && attrs[i].delta > 0) - ? 1 : 0); - if (rid_ >= start_rid + if (rid >= start_rid // note the use of rid+1 and unsigned comparison here to // treat end_rid=-1 as "unbounded" in such a way that rid=-1 // is still included - && (lfs_size_t)(rid_ + 1) <= (lfs_size_t)end_rid) { + && (lfs_size_t)(rid + 1) <= (lfs_size_t)end_rid) { int err = lfsr_rbyd_appendattr(lfs, rbyd, rid - lfs_smax32(start_rid, 0), attrs[i].tag, attrs[i].delta, attrs[i].data); @@ -3170,15 +3178,18 @@ static int lfsr_rbyd_appendattrs(lfs_t *lfs, // we need to make sure we keep start_rid/end_rid updated with // weight changes - if (rid_ < start_rid) { + if (rid < start_rid) { start_rid += attrs[i].delta; } - if (rid_ < end_rid) { + if (rid < end_rid) { end_rid += attrs[i].delta; } // adjust rid rid += attrs[i].delta; + if (!lfsr_tag_isgrow(attrs[i].tag) && attrs[i].delta > 0) { + rid -= 1; + } } return 0; @@ -3985,7 +3996,7 @@ static int lfsr_btree_commit_(lfs_t *lfs, lfsr_btree_t *btree, lfsr_attr_t attrs__[static 4], uint8_t buf__[static 2*LFSR_BRANCH_DSIZE]) { lfsr_bid_t bid = *bid_; - LFS_ASSERT((lfsr_sbid_t)bid < btree->weight); + LFS_ASSERT(bid <= (lfsr_bid_t)btree->weight); const lfsr_attr_t *attrs = *attrs_; lfs_size_t attr_count = *attr_count_; @@ -3998,7 +4009,8 @@ static int lfsr_btree_commit_(lfs_t *lfs, lfsr_btree_t *btree, lfsr_srid_t rid = bid; if (btree->weight > 0) { lfsr_srid_t rid_; - int err = lfsr_btree_lookupnext_(lfs, btree, bid, + int err = lfsr_btree_lookupnext_(lfs, btree, + lfs_min32(bid, btree->weight-1), &bid, &rbyd, &rid_, NULL, NULL, NULL); if (err) { LFS_ASSERT(err != LFS_ERR_NOENT); @@ -4014,7 +4026,7 @@ static int lfsr_btree_commit_(lfs_t *lfs, lfsr_btree_t *btree, while (true) { // we will always need our parent, so go ahead and find it lfsr_rbyd_t parent = {.trunk=0, .weight=0}; - lfsr_srid_t pid = -1; + lfsr_srid_t pid = 0; // are we root? if (rbyd.blocks[0] == btree->blocks[0] || !lfsr_rbyd_hastrunk(&rbyd)) { @@ -4084,6 +4096,7 @@ static int lfsr_btree_commit_(lfs_t *lfs, lfsr_btree_t *btree, finalize:; // done? if (!lfsr_rbyd_hastrunk(&parent)) { + LFS_ASSERT(bid == 0); *btree = rbyd_; *attr_count_ = 0; return 0; @@ -4141,7 +4154,7 @@ static int lfsr_btree_commit_(lfs_t *lfs, lfsr_btree_t *btree, lfsr_rbyd_t sibling; if ((lfs_size_t)estimate <= lfs->cfg->block_size/4 // no parent? can't merge - && !lfsr_rbyd_hastrunk(&parent)) { + && lfsr_rbyd_hastrunk(&parent)) { // try the right sibling if (pid+1 < parent.weight) { // try looking up the sibling @@ -4237,6 +4250,7 @@ static int lfsr_btree_commit_(lfs_t *lfs, lfsr_btree_t *btree, // if we're merging our left sibling, swap our rbyds // so our sibling is on the right bid -= sibling.weight; + rid += sibling.weight; pid -= rbyd.weight; rbyd_ = sibling; @@ -4458,7 +4472,7 @@ static int lfsr_btree_commit_(lfs_t *lfs, lfsr_btree_t *btree, // we must have a parent at this point, but is our parent the root // and is the root degenerate? - LFS_ASSERT(lfsr_rbyd_hastrunk(&parent) != 0); + LFS_ASSERT(lfsr_rbyd_hastrunk(&parent)); if (rbyd.weight+sibling.weight == btree->weight) { // collapse the root, decreasing the height of the tree *btree = rbyd_; @@ -4483,7 +4497,7 @@ static int lfsr_btree_commit_(lfs_t *lfs, lfsr_btree_t *btree, attrs = attrs__; rbyd = parent; - rid = pid; + rid = pid + sibling.weight; continue; } } @@ -5508,11 +5522,12 @@ static int lfsr_mdir_commit__(lfs_t *lfs, lfsr_mdir_t *mdir, // treat end_rid=-1 as "unbounded" in such a way that rid=-1 // is still included && (lfs_size_t)(rid + 1) <= (lfs_size_t)end_rid) { + for (lfs_size_t i = 0; i < attr_count; i++) { - // adjust for inserts - if (!lfsr_tag_isgrow(attrs[i].tag) && attrs[i].delta > 0) { - rid -= 1; - } + // we just happen to never split in an mdir commit + LFS_ASSERT(!(i > 0 + && !lfsr_tag_isgrow(attrs[i].tag) + && attrs[i].delta > 0)); // ignore any gstate tags here, these need to be handled // specially by upper-layers @@ -5706,6 +5721,9 @@ static int lfsr_mdir_commit__(lfs_t *lfs, lfsr_mdir_t *mdir, // adjust rid rid += attrs[i].delta; + if (!lfsr_tag_isgrow(attrs[i].tag) && attrs[i].delta > 0) { + rid -= 1; + } } } @@ -6319,7 +6337,7 @@ static int lfsr_mtree_commit_(lfs_t *lfs, lfsr_smid_t mid, // commit to mtree int err = lfsr_btree_commit(lfs, &mtree_, - lfsr_mid_bid(lfs, mid), + lfs_min32(lfsr_mid_bid(lfs, mid), mtree_.weight), attrs, attr_count); if (err) { return err; @@ -6595,7 +6613,7 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, if (lfsr_mtree_ismptr(lfs)) { uint8_t mdir_buf[LFSR_MPTR_DSIZE]; uint8_t msibling_buf[LFSR_MPTR_DSIZE]; - err = lfsr_mtree_commit_(lfs, -1, LFSR_ATTRS( + err = lfsr_mtree_commit_(lfs, 0, LFSR_ATTRS( LFSR_ATTR( MDIR, +lfsr_mweight(lfs), FROMMPTR(lfsr_mdir_mptr(&mdir_), mdir_buf)), @@ -6793,7 +6811,6 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, // adjust mid mid += attrs[i].delta; - // adjust for inserts if (!lfsr_tag_isgrow(attrs[i].tag) && attrs[i].delta > 0) { mid -= 1; } @@ -6862,7 +6879,7 @@ static int lfsr_mdir_namelookup(lfs_t *lfs, const lfsr_mdir_t *mdir, // adjust mid if necessary // - // note missing mids end up pointing to the _next_ mid, unlike in rbyds + // note missing mids end up pointing to the next mid lfsr_smid_t mid = LFSR_MID(lfs, mdir->mid, (lfs_cmp(cmp) < 0) ? rid+1 : rid); @@ -9916,7 +9933,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, // possible in case we ever don't track temporary copies. // try to merge commits where possible - lfsr_bid_t bid_ = lfsr_bshrub_size(&file->bshrub)-1; + lfsr_bid_t bid = lfsr_bshrub_size(&file->bshrub); lfsr_attr_t attrs[5]; lfs_size_t attr_count = 0; lfs_size_t attr_tnuoc = 0; @@ -9949,7 +9966,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, LFS_ASSERT(attr_count <= sizeof(attrs)/sizeof(lfsr_attr_t)); LFS_ASSERT(buf_size <= sizeof(buf)); - int err = lfsr_bshrub_commit(lfs, file, -1, attrs, attr_count); + int err = lfsr_bshrub_commit(lfs, file, 0, attrs, attr_count); if (err) { return err; } @@ -9963,11 +9980,13 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, if (pos > lfsr_bshrub_size(&file->bshrub)) { // can we coalesce? if (lfsr_bshrub_size(&file->bshrub) > 0) { + bid = lfs_min32(bid, lfsr_bshrub_size(&file->bshrub)-1); attrs[attr_count++] = LFSR_ATTR( GROW, +(pos - lfsr_bshrub_size(&file->bshrub)), NULL()); // new hole } else { + bid = lfs_min32(bid, lfsr_bshrub_size(&file->bshrub)); attrs[attr_count++] = LFSR_ATTR( DATA, +(pos - lfsr_bshrub_size(&file->bshrub)), NULL()); } @@ -9980,7 +9999,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, lfsr_bptr_t bptr_; lfsr_ecksum_t becksum_; int err = lfsr_bshrub_lookupnext(lfs, file, pos, - &bid_, &tag_, &weight_, &bptr_, &becksum_); + &bid, &tag_, &weight_, &bptr_, &becksum_); if (err) { LFS_ASSERT(err != LFS_ERR_NOENT); return err; @@ -9989,9 +10008,9 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, // note, an entry can be both a left and right sibling lfsr_data_t left_slice_ = lfsr_data_slice(bptr_.data, -1, - pos - (bid_-(weight_-1))); + pos - (bid-(weight_-1))); lfsr_data_t right_slice_ = lfsr_data_slice(bptr_.data, - pos+weight - (bid_-(weight_-1)), + pos+weight - (bid-(weight_-1)), -1); // left sibling needs carving but falls underneath our @@ -10003,7 +10022,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, lfs->cfg->fragment_size, -1); - err = lfsr_bshrub_commit(lfs, file, bid_, LFSR_ATTRS( + err = lfsr_bshrub_commit(lfs, file, bid, LFSR_ATTRS( LFSR_ATTR( GROW(SUBMASK(DATA)), -(weight_ - lfs->cfg->fragment_size), @@ -10019,7 +10038,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, weight_ -= lfs->cfg->fragment_size; left_slice_ = lfsr_data_slice(bptr_.data, -1, - pos - (bid_-(weight_-1))); + pos - (bid-(weight_-1))); } // right sibling needs carving but falls underneath our @@ -10030,7 +10049,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, bptr_.data = lfsr_data_truncate(bptr_.data, lfsr_data_size(&bptr_.data) - lfs->cfg->fragment_size); - err = lfsr_bshrub_commit(lfs, file, bid_, LFSR_ATTRS( + err = lfsr_bshrub_commit(lfs, file, bid, LFSR_ATTRS( LFSR_ATTR( GROW(SUBMASK(BLOCK)), -(weight_ - lfsr_data_size(&bptr_.data)), @@ -10043,19 +10062,19 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, return err; } - bid_ -= (weight_-lfsr_data_size(&bptr_.data)); + bid -= (weight_-lfsr_data_size(&bptr_.data)); weight_ -= (weight_-lfsr_data_size(&bptr_.data)); right_slice_ = lfsr_data_slice(bptr_.data, - pos+weight - (bid_-(weight_-1)), + pos+weight - (bid-(weight_-1)), -1); } // found left sibling? - if (bid_-(weight_-1) < pos) { + if (bid-(weight_-1) < pos) { // can we get away with a grow attribute? if (lfsr_data_size(&bptr_.data) == lfsr_data_size(&left_slice_)) { attrs[attr_count++] = LFSR_ATTR( - GROW, -(bid_+1 - pos), NULL()); + GROW, -(bid+1 - pos), NULL()); // carve bptr? } else if (tag_ == LFSR_TAG_BLOCK) { @@ -10065,14 +10084,14 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, .cksum = bptr_.cksum, }; attrs[attr_count++] = LFSR_ATTR( - GROW(SUBMASK(BLOCK)), -(bid_+1 - pos), + GROW(SUBMASK(BLOCK)), -(bid+1 - pos), FROMBPTR(&bptr__, &buf[buf_size])); buf_size += LFSR_BPTR_DSIZE; // carve fragment? } else { attrs[attr_count++] = LFSR_ATTR( - GROW(SUBMASK(DATA)), -(bid_+1 - pos), + GROW(SUBMASK(DATA)), -(bid+1 - pos), DATA(left_slice_)); } @@ -10084,30 +10103,29 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, // spans more than one entry? we can't do everything in one commit, // so commit what we have and move on to next entry - if (pos+weight > bid_+1) { + if (pos+weight > bid+1) { LFS_ASSERT(lfsr_data_size(&right_slice_) == 0); LFS_ASSERT(attr_count <= sizeof(attrs)/sizeof(lfsr_attr_t)); LFS_ASSERT(buf_size <= sizeof(buf)); - err = lfsr_bshrub_commit(lfs, file, bid_, + err = lfsr_bshrub_commit(lfs, file, bid, attrs, attr_count); if (err) { return err; } - delta += lfs_min32(weight, bid_+1 - pos); - weight -= lfs_min32(weight, bid_+1 - pos); - bid_ = lfsr_bshrub_size(&file->bshrub)-1; + delta += lfs_min32(weight, bid+1 - pos); + weight -= lfs_min32(weight, bid+1 - pos); attr_count = 0; buf_size = 0; continue; } // found right sibling? - if (pos+weight < bid_+1) { + if (pos+weight < bid+1) { // can we coalesce a hole? if (lfsr_data_size(&right_slice_) == 0) { - delta += bid_+1 - (pos+weight); + delta += bid+1 - (pos+weight); // carve bptr? } else if (tag_ == LFSR_TAG_BLOCK) { @@ -10117,7 +10135,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, .cksum = bptr_.cksum, }; attrs[attr_count+attr_tnuoc++] = LFSR_ATTR( - BLOCK, +(bid_+1 - (pos+weight)), + BLOCK, +(bid+1 - (pos+weight)), FROMBPTR(&bptr__, &buf[buf_size])); buf_size += LFSR_BPTR_DSIZE; @@ -10132,13 +10150,13 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, // carve fragment? } else { attrs[attr_count+attr_tnuoc++] = LFSR_ATTR( - DATA, +(bid_+1 - (pos+weight)), + DATA, +(bid+1 - (pos+weight)), DATA(right_slice_)); } } - delta += lfs_min32(weight, bid_+1 - pos); - weight -= lfs_min32(weight, bid_+1 - pos); + delta += lfs_min32(weight, bid+1 - pos); + weight -= lfs_min32(weight, bid+1 - pos); break; } @@ -10146,6 +10164,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, if (weight + delta > 0) { // can we coalesce a hole? if ((!bptr || lfsr_data_size(&bptr->data) == 0) && pos > 0) { + bid = lfs_min32(bid, lfsr_bshrub_size(&file->bshrub)-1); memmove(&attrs[attr_count+1], &attrs[attr_count], attr_tnuoc*sizeof(lfsr_attr_t)); attrs[attr_count++] = LFSR_ATTR( @@ -10153,6 +10172,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, // need a new hole? } else if (!bptr || lfsr_data_size(&bptr->data) == 0) { + bid = lfs_min32(bid, lfsr_bshrub_size(&file->bshrub)); memmove(&attrs[attr_count+1], &attrs[attr_count], attr_tnuoc*sizeof(lfsr_attr_t)); attrs[attr_count++] = LFSR_ATTR( @@ -10160,6 +10180,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, // append new fragment? } else if (tag == LFSR_TAG_DATA) { + bid = lfs_min32(bid, lfsr_bshrub_size(&file->bshrub)); memmove(&attrs[attr_count+1], &attrs[attr_count], attr_tnuoc*sizeof(lfsr_attr_t)); attrs[attr_count++] = LFSR_ATTR( @@ -10167,6 +10188,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, // append a new block? } else if (tag == LFSR_TAG_BLOCK) { + bid = lfs_min32(bid, lfsr_bshrub_size(&file->bshrub)); memmove(&attrs[attr_count+1], &attrs[attr_count], attr_tnuoc*sizeof(lfsr_attr_t)); attrs[attr_count++] = LFSR_ATTR( @@ -10194,7 +10216,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, LFS_ASSERT(attr_count+attr_tnuoc <= sizeof(attrs)/sizeof(lfsr_attr_t)); LFS_ASSERT(buf_size <= sizeof(buf)); - int err = lfsr_bshrub_commit(lfs, file, bid_, + int err = lfsr_bshrub_commit(lfs, file, bid, attrs, attr_count+attr_tnuoc); if (err) { return err; diff --git a/tests/test_btree.toml b/tests/test_btree.toml index 261a5172..c2ac6e80 100644 --- a/tests/test_btree.toml +++ b/tests/test_btree.toml @@ -28,7 +28,7 @@ code = ''' lfs_size_t bid, lfsr_tag_t tag, lfs_size_t weight, lfsr_data_t data) { LFS_ASSERT(bid <= btree->weight); - return lfsr_btree_commit(lfs, btree, bid-1, LFSR_ATTRS( + return lfsr_btree_commit(lfs, btree, bid, LFSR_ATTRS( LFSR_ATTR(TAG(tag), +weight, DATA(data)))); } @@ -3184,7 +3184,7 @@ code = ''' // create a single-entry tree lfsr_btree_t btree; lfsr_btree_alloc(&lfs, &btree) => 0; - lfsr_btree_commit(&lfs, &btree, -1, LFSR_ATTRS( + lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS( LFSR_ATTR(NAME, +1, CAT(LFSR_DATA_LEB128(0), LFSR_DATA_BUF("aaa", 3))), LFSR_ATTR(DATA, 0, BUF("0", 1)))) => 0; @@ -3236,7 +3236,7 @@ code = ''' // create a two-entry tree lfsr_btree_t btree; lfsr_btree_alloc(&lfs, &btree) => 0; - lfsr_btree_commit(&lfs, &btree, -1, LFSR_ATTRS( + lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS( LFSR_ATTR(NAME, +1, CAT(LFSR_DATA_LEB128(0), LFSR_DATA_BUF("aaa", 3))), LFSR_ATTR(DATA, 0, BUF("0", 1)))) => 0; @@ -3300,7 +3300,7 @@ code = ''' // create a two-entry tree lfsr_btree_t btree; lfsr_btree_alloc(&lfs, &btree) => 0; - lfsr_btree_commit(&lfs, &btree, -1, LFSR_ATTRS( + lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS( LFSR_ATTR(NAME, +1, CAT(LFSR_DATA_LEB128(0), LFSR_DATA_BUF("aaa", 3))), LFSR_ATTR(DATA, 0, BUF("0", 1)))) => 0; @@ -3376,7 +3376,7 @@ code = ''' // create a two-entry tree lfsr_btree_t btree; lfsr_btree_alloc(&lfs, &btree) => 0; - lfsr_btree_commit(&lfs, &btree, -1, LFSR_ATTRS( + lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS( LFSR_ATTR(NAME, +1, CAT(LFSR_DATA_LEB128(0), LFSR_DATA_BUF("aaa", 3))), LFSR_ATTR( DATA, 0, BUF("0", 1)))) => 0; @@ -3458,7 +3458,7 @@ code = ''' char name[3] = { alphas[(0/26/26) % 26], alphas[(0/26) % 26], alphas[0 % 26] }; - lfsr_btree_commit(&lfs, &btree, -1, LFSR_ATTRS( + lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS( LFSR_ATTR(NAME, +1, CAT(LFSR_DATA_LEB128(0), LFSR_DATA_BUF(name, 3))), LFSR_ATTR(DATA, 0, BUF(&nums[0 % 10], 1)))) => 0; @@ -3527,7 +3527,7 @@ code = ''' // create a btree lfsr_btree_t btree; lfsr_btree_alloc(&lfs, &btree) => 0; - lfsr_btree_commit(&lfs, &btree, -1, LFSR_ATTRS( + lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS( LFSR_ATTR(NAME, +1, CAT(LFSR_DATA_LEB128(0), LFSR_DATA_BUF("___", 3))), LFSR_ATTR(DATA, 0, BUF("_", 1)))) => 0; @@ -3645,7 +3645,7 @@ code = ''' char name[3] = { alphas[(0/26/26) % 26], alphas[(0/26) % 26], alphas[0 % 26] }; - lfsr_btree_commit(&lfs, &btree, -1, LFSR_ATTRS( + lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS( LFSR_ATTR(NAME, +W, CAT(LFSR_DATA_LEB128(0), LFSR_DATA_BUF(name, 3))), LFSR_ATTR(DATA, 0, BUF(&nums[0 % 10], 1)))) => 0; @@ -3715,7 +3715,7 @@ code = ''' // create a btree lfsr_btree_t btree; lfsr_btree_alloc(&lfs, &btree) => 0; - lfsr_btree_commit(&lfs, &btree, -1, LFSR_ATTRS( + lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS( LFSR_ATTR(NAME, +W, CAT(LFSR_DATA_LEB128(0), LFSR_DATA_BUF("___", 3))), LFSR_ATTR(DATA, 0, BUF("_", 1)))) => 0; @@ -3869,7 +3869,7 @@ code = ''' // create a btree lfsr_btree_t btree; lfsr_btree_alloc(&lfs, &btree) => 0; - lfsr_btree_commit(&lfs, &btree, -1, LFSR_ATTRS( + lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS( LFSR_ATTR(NAME, +1, CAT(LFSR_DATA_LEB128(0), LFSR_DATA_BUF("___", 3))), LFSR_ATTR(DATA, 0, BUF("_", 1)))) => 0; @@ -3919,7 +3919,7 @@ code = ''' assert(lfs_cmp(cmp) != 0); if (lfs_cmp(cmp) > 0) { int err = lfsr_btree_commit(&lfs, &btree, - split_bid-1, LFSR_ATTRS( + split_bid, LFSR_ATTRS( LFSR_ATTR(NAME, +1, CAT( LFSR_DATA_LEB128(0), LFSR_DATA_BUF(name, 3))), @@ -4039,7 +4039,7 @@ code = ''' // create a btree lfsr_btree_t btree; lfsr_btree_alloc(&lfs, &btree) => 0; - lfsr_btree_commit(&lfs, &btree, -1, LFSR_ATTRS( + lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS( LFSR_ATTR(NAME, +W, CAT(LFSR_DATA_LEB128(0), LFSR_DATA_BUF("___", 3))), LFSR_ATTR(DATA, 0, BUF("_", 1)))) => 0; @@ -4101,7 +4101,7 @@ code = ''' assert(lfs_cmp(cmp) != 0); if (lfs_cmp(cmp) > 0) { int err = lfsr_btree_commit(&lfs, &btree, - split_bid-(split_weight-1)-1, LFSR_ATTRS( + split_bid-(split_weight-1), LFSR_ATTRS( LFSR_ATTR(NAME, +weight, CAT( LFSR_DATA_LEB128(0), LFSR_DATA_BUF(name, 3))), diff --git a/tests/test_rbyd.toml b/tests/test_rbyd.toml index 977dcd3e..b7b6864d 100644 --- a/tests/test_rbyd.toml +++ b/tests/test_rbyd.toml @@ -3695,7 +3695,7 @@ code = ''' // try to create one rid rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; assert(rbyd.weight == 1); @@ -3710,7 +3710,7 @@ code = ''' // try to create two ids rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; @@ -3730,7 +3730,7 @@ code = ''' // create a third to the right rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), LFSR_ATTR(REG, +1, BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; @@ -3772,7 +3772,7 @@ code = ''' // try to create one rid rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; assert(rbyd.weight == 1); @@ -3789,9 +3789,9 @@ code = ''' // try to create two ids rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( - LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( + LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; + lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; assert(rbyd.weight == 2); @@ -3810,9 +3810,9 @@ code = ''' // try to create two in the other direction rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; assert(rbyd.weight == 2); @@ -3831,11 +3831,11 @@ code = ''' // create a third to the right rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( - LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( - LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; + LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( + LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; + lfsr_rbyd_commit(&lfs, &rbyd, 2, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; assert(rbyd.weight == 3); @@ -3858,11 +3858,11 @@ code = ''' // create a third to the left rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( - LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( + LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; + lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; assert(rbyd.weight == 3); @@ -3885,11 +3885,11 @@ code = ''' // create a third in the middle rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; assert(rbyd.weight == 3); @@ -3975,7 +3975,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -4033,7 +4033,7 @@ code = ''' // the tag requested rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 00000000, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; @@ -4097,9 +4097,9 @@ code = ''' // the tag requested rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( - LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( + LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; + lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; lfsr_rbyd_lookupnext(&lfs, &rbyd, -1, 0, @@ -4140,9 +4140,9 @@ code = ''' // also try the other direction rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_lookupnext(&lfs, &rbyd, -1, 0, @@ -4245,7 +4245,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -4315,7 +4315,7 @@ code = ''' : (uint16_t)TEST_PRNG(&prng); x = x % (rbyd.weight+1); - int err = lfsr_rbyd_commit(&lfs, &rbyd, x-1, LFSR_ATTRS( + int err = lfsr_rbyd_commit(&lfs, &rbyd, x, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[x % 6], 4)))); if (err == LFS_ERR_RANGE) { break; @@ -4361,7 +4361,7 @@ code = ''' // try to create one rid rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)))) => 0; @@ -4381,7 +4381,7 @@ code = ''' // try to create two ids rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), @@ -4411,7 +4411,7 @@ code = ''' // create a third to the right rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), @@ -4485,7 +4485,7 @@ code = ''' // try to create one rid rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)))) => 0; @@ -4506,11 +4506,11 @@ code = ''' // try to create two ids rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xbb\xbb", 2)))) => 0; @@ -4539,11 +4539,11 @@ code = ''' // try to create two in the other direction rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xbb\xbb", 2)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)))) => 0; @@ -4572,15 +4572,15 @@ code = ''' // create a third to the right rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xbb\xbb", 2)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 2, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 2, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xcc\xcc", 2)))) => 0; @@ -4634,15 +4634,15 @@ code = ''' // create a third to the left rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xbb\xbb", 2)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xcc\xcc", 2)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)))) => 0; @@ -4679,15 +4679,15 @@ code = ''' // create a third in the middle rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xcc\xcc", 2)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xbb\xbb", 2)))) => 0; @@ -4788,7 +4788,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)))) => 0; // note uattrs have a smaller size to help debugging for (unsigned u = 0; u < M; u++) { @@ -4857,7 +4857,7 @@ code = ''' // the tag requested rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), @@ -4951,11 +4951,11 @@ code = ''' // the tag requested rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xbb\xbb", 2)))) => 0; @@ -5026,11 +5026,11 @@ code = ''' // also try the other direction rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xbb\xbb", 2)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)))) => 0; @@ -5164,7 +5164,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)))) => 0; // note uattrs have a smaller size to help debugging for (unsigned u = 0; u < M; u++) { @@ -5248,7 +5248,7 @@ code = ''' lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; for (unsigned j = 0; j < N; j++) { - lfsr_rbyd_commit(&lfs, &rbyd, j-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, j, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[j % 6], 4)))) => 0; // note uattrs have a smaller size to help debugging for (unsigned u = 0; u < M; u++) { @@ -5407,7 +5407,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)))) => 0; // note uattrs have a smaller size to help debugging for (unsigned u = 0; u < M; u++) { @@ -5575,7 +5575,7 @@ code = ''' lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; for (unsigned j = 0; j < N; j++) { - lfsr_rbyd_commit(&lfs, &rbyd, j-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, j, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[j % 6], 4)))) => 0; // note uattrs have a smaller size to help debugging for (unsigned u = 0; u < M; u++) { @@ -5717,7 +5717,7 @@ code = ''' attrs[1+u] = LFSR_ATTR(UATTR(u+1), 0, BUF(names[x % 6], 2)); } - int err = lfsr_rbyd_commit(&lfs, &rbyd, x-1, attrs, 1+M); + int err = lfsr_rbyd_commit(&lfs, &rbyd, x, attrs, 1+M); if (err == LFS_ERR_RANGE) { break; } @@ -5821,7 +5821,7 @@ code = ''' LFSR_ATTR(UATTR(perm[j]+1), 0, BUF(names[perm[j] % 6], 1)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -5960,7 +5960,7 @@ code = ''' LFSR_ATTR(UATTR(perm[j]+1), 0, BUF(names[perm[j] % 6], 1)))) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)))) => 0; for (unsigned u = 0; u < M; u++) { @@ -6071,7 +6071,7 @@ code = ''' // try to delete one rid rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( @@ -6091,7 +6091,7 @@ code = ''' // try to delete the other rid rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( @@ -6111,7 +6111,7 @@ code = ''' // try to delete the largest of three rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), LFSR_ATTR(REG, +1, BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; @@ -6134,7 +6134,7 @@ code = ''' // try to delete the smallest of three rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), LFSR_ATTR(REG, +1, BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; @@ -6157,7 +6157,7 @@ code = ''' // try to delete the middle rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), LFSR_ATTR(REG, +1, BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; @@ -6197,7 +6197,7 @@ code = ''' // try to delete one rid rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), @@ -6233,7 +6233,7 @@ code = ''' // try to delete the other rid rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), @@ -6269,7 +6269,7 @@ code = ''' // try to delete the largest of three rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), @@ -6318,7 +6318,7 @@ code = ''' // try to delete the smallest of three rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), @@ -6368,7 +6368,7 @@ code = ''' // try to delete the middle rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), @@ -6484,7 +6484,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)))) => 0; } assert(rbyd.weight == N); @@ -6527,7 +6527,7 @@ code = ''' // try recreating the rid to make sure things still work printf("--- create: %d ---\n", j); - lfsr_rbyd_commit(&lfs, &rbyd, j-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, j, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[j % 6], 6)))) => 0; assert(rbyd.weight == N); @@ -6640,7 +6640,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)))) => 0; // note uattrs have a smaller size to help debugging for (unsigned u = 0; u < M; u++) { @@ -6701,7 +6701,7 @@ code = ''' // try recreating the rid to make sure things still work printf("--- create: %d ---\n", j); - lfsr_rbyd_commit(&lfs, &rbyd, j-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, j, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[j % 6], 6)))) => 0; for (unsigned u = 0; u < M; u++) { lfsr_rbyd_commit(&lfs, &rbyd, j, LFSR_ATTRS( @@ -6831,7 +6831,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)))) => 0; } assert(rbyd.weight == N); @@ -6957,7 +6957,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)))) => 0; // note uattrs have a smaller size to help debugging for (unsigned u = 0; u < M; u++) { @@ -7057,7 +7057,7 @@ code = ''' // create and delete one rid rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(RM, -1, NULL()))) => 0; @@ -7074,7 +7074,7 @@ code = ''' // create and delete two ids rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( @@ -7093,7 +7093,7 @@ code = ''' // create and delete two ids in the other order rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( @@ -7113,7 +7113,7 @@ code = ''' // create and delete three ids rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), LFSR_ATTR(REG, +1, BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; @@ -7134,7 +7134,7 @@ code = ''' // create and delete three ids in the other order rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), LFSR_ATTR(REG, +1, BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; @@ -7175,7 +7175,7 @@ code = ''' // create and delete one rid rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)))) => 0; lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( @@ -7193,7 +7193,7 @@ code = ''' // create and delete two ids rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), @@ -7214,7 +7214,7 @@ code = ''' // create and delete two ids in the other order rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), @@ -7236,7 +7236,7 @@ code = ''' // create and delete three ids rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), @@ -7260,7 +7260,7 @@ code = ''' // create and delete three ids in the other order rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xaa\xaa", 2)), LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), @@ -7325,7 +7325,7 @@ code = ''' lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; for (unsigned j = 0; j < N; j++) { - lfsr_rbyd_commit(&lfs, &rbyd, j-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, j, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[j % 6], 4)))) => 0; } assert(rbyd.weight == N); @@ -7388,7 +7388,7 @@ code = ''' => LFS_ERR_NOENT; // try resuming from all tags being removed - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa\xaa\xaa", 6)))) => 0; assert(rbyd.weight == 1); @@ -7470,7 +7470,7 @@ code = ''' lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; for (unsigned j = 0; j < N; j++) { - lfsr_rbyd_commit(&lfs, &rbyd, j-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, j, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[j % 6], 4)))) => 0; // note uattrs have a smaller size to help debugging for (unsigned u = 0; u < M; u++) { @@ -7538,7 +7538,7 @@ code = ''' => LFS_ERR_NOENT; // try resuming from all tags being removed - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa\xaa\xaa", 6)))) => 0; for (unsigned u = 0; u < M; u++) { @@ -7655,7 +7655,7 @@ code = ''' sim[rid] = alpha[i % 26]; count += 1; // update our rbyd - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(&alpha[i % 26], 1)))) => 0; } else { // update our sim @@ -7725,7 +7725,7 @@ code = ''' // make id0 with weight w1 rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)))) => 0; lfsr_rbyd_lookupnext(&lfs, &rbyd, 0, LFSR_TAG_REG, @@ -7744,7 +7744,7 @@ code = ''' assert(lfsr_data_size(&data_) == 4); // make id2 with weight w2 - lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(REG, +2, BUF("\xbb\xbb\xbb\xbb", 4)))) => 0; lfsr_rbyd_lookupnext(&lfs, &rbyd, 0, LFSR_TAG_REG, @@ -7775,7 +7775,7 @@ code = ''' assert(lfsr_data_size(&data_) == 4); // make id5 with weight w3 - lfsr_rbyd_commit(&lfs, &rbyd, 2, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 3, LFSR_ATTRS( LFSR_ATTR(REG, +3, BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; lfsr_rbyd_lookupnext(&lfs, &rbyd, 0, LFSR_TAG_REG, @@ -7818,7 +7818,7 @@ code = ''' assert(lfsr_data_size(&data_) == 4); // make id9 with weight w4 - lfsr_rbyd_commit(&lfs, &rbyd, 5, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 6, LFSR_ATTRS( LFSR_ATTR(REG, +4, BUF("\xdd\xdd\xdd\xdd", 4)))) => 0; lfsr_rbyd_lookupnext(&lfs, &rbyd, 0, LFSR_TAG_REG, @@ -7873,7 +7873,7 @@ code = ''' assert(lfsr_data_size(&data_) == 4); // make id14 with weight w5 - lfsr_rbyd_commit(&lfs, &rbyd, 9, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 10, LFSR_ATTRS( LFSR_ATTR(REG, +5, BUF("\xee\xee\xee\xee", 4)))) => 0; lfsr_rbyd_lookupnext(&lfs, &rbyd, 0, LFSR_TAG_REG, @@ -7961,7 +7961,7 @@ code = ''' rbyd = init_rbyd; lfs_bd_erase(&lfs, rbyd.blocks[0]) => 0; - lfsr_rbyd_commit(&lfs, &rbyd, -1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( // make id0 with weight w1 LFSR_ATTR(REG, +1, BUF("\xaa\xaa\xaa\xaa", 4)), // make id2 with weight w2 @@ -8108,7 +8108,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid*W-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid*W, LFSR_ATTRS( LFSR_ATTR(REG, +W, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -8195,7 +8195,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid*W-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid*W, LFSR_ATTRS( LFSR_ATTR(REG, +W, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -8302,7 +8302,7 @@ code = ''' assert(lfsr_data_size(&data_) == 2); // make id2 with weight w2 - lfsr_rbyd_commit(&lfs, &rbyd, 0, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 1, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xbb\xbb\xbb\xbb", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xbb\xbb", 2)), LFSR_ATTR(GROW, +1, NULL()), @@ -8396,7 +8396,7 @@ code = ''' assert(lfsr_data_size(&data_) == 2); // make id5 with weight w3 - lfsr_rbyd_commit(&lfs, &rbyd, 2, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 3, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xcc\xcc\xcc\xcc", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xcc\xcc", 2)), LFSR_ATTR(GROW, +2, NULL()), @@ -8526,7 +8526,7 @@ code = ''' assert(lfsr_data_size(&data_) == 2); // make id9 with weight w4 - lfsr_rbyd_commit(&lfs, &rbyd, 5, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 6, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xdd\xdd\xdd\xdd", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xdd\xdd", 2)), LFSR_ATTR(GROW, +3, NULL()), @@ -8692,7 +8692,7 @@ code = ''' assert(lfsr_data_size(&data_) == 2); // make id14 with weight w5 - lfsr_rbyd_commit(&lfs, &rbyd, 9, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, 10, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF("\xee\xee\xee\xee", 4)), LFSR_ATTR(UATTR(1), 0, BUF("\xee\xee", 2)), LFSR_ATTR(GROW, +4, NULL()), @@ -9212,7 +9212,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid*W-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid*W, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)), LFSR_ATTR(UATTR(1), 0, BUF(names[perm[j] % 6], 2)), LFSR_ATTR(GROW, +W-1, NULL()), @@ -9323,7 +9323,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid*W-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid*W, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)), LFSR_ATTR(UATTR(1), 0, BUF(names[perm[j] % 6], 2)), LFSR_ATTR(GROW, +W-1, NULL()), @@ -9441,7 +9441,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid*W-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid*W, LFSR_ATTRS( LFSR_ATTR(REG, +W, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -9570,7 +9570,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid*W-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid*W, LFSR_ATTRS( LFSR_ATTR(REG, +W, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -9708,7 +9708,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid*W-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid*W, LFSR_ATTRS( LFSR_ATTR(UATTR(2), +W, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -9858,7 +9858,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid*W-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid*W, LFSR_ATTRS( LFSR_ATTR(REG, +W, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -9987,7 +9987,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid*W-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid*W, LFSR_ATTRS( LFSR_ATTR(REG, +W, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -10125,7 +10125,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid*W-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid*W, LFSR_ATTRS( LFSR_ATTR(UATTR(2), +W, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -10274,7 +10274,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid*W-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid*W, LFSR_ATTRS( LFSR_ATTR(REG, +W, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -10331,7 +10331,7 @@ code = ''' // try recreating the rid to make sure things still work printf("--- create: %d ---\n", j); - lfsr_rbyd_commit(&lfs, &rbyd, j*W-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, j*W, LFSR_ATTRS( LFSR_ATTR(REG, +W, BUF(names[j % 6], 6)))) => 0; assert(rbyd.weight == N*W); @@ -10430,7 +10430,7 @@ code = ''' } } - lfsr_rbyd_commit(&lfs, &rbyd, rid*W-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid*W, LFSR_ATTRS( LFSR_ATTR(REG, +W, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -10623,7 +10623,7 @@ code = ''' sim[rid*(M+1)] = alpha[i % 26]; count += 1; // update our rbyd - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(&alpha[i % 26], 1)))) => 0; } else if (op == 1) { // update our sim @@ -10788,7 +10788,7 @@ code = ''' sim_weights[rid] = weight; count += 1; // update our rbyd - lfsr_rbyd_commit(&lfs, &rbyd, weighted_rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, weighted_rid, LFSR_ATTRS( LFSR_ATTR(REG, +weight, BUF(&alpha[i % 26], 1)))) => 0; } else if (op == 1) { // get the correct weight from the sim @@ -10950,7 +10950,7 @@ code = ''' } // give each attr a subtype based on its rid + SHIFT - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)), LFSR_ATTR(UATTR((perm[j] + SHIFT) & 0x7f), 0, BUF(names[perm[j] % 6], 2)))) => 0; @@ -11037,7 +11037,7 @@ code = ''' } // give each attr a subtype based on its rid + SHIFT - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)), LFSR_ATTR(UATTR((perm[j] + SHIFT) & 0x7f), 0, BUF(names[perm[j] % 6], 2)))) => 0; @@ -11176,7 +11176,7 @@ code = ''' } // give each attr a subtype based on its rid + SHIFT - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)), LFSR_ATTR(UATTR((perm[j] + SHIFT) & 0x7f), 0, BUF(names[perm[j] % 6], 2)))) => 0; @@ -11317,7 +11317,7 @@ code = ''' } // give each attr a subtype based on its rid + SHIFT - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)), LFSR_ATTR(UATTR((perm[j] + SHIFT) & 0x7f), 0, BUF(names[perm[j] % 6], 2)), @@ -11406,7 +11406,7 @@ code = ''' } // give each attr a subtype based on its rid + SHIFT - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)), LFSR_ATTR(UATTR((perm[j] + SHIFT) & 0x7f), 0, BUF(names[perm[j] % 6], 2)), @@ -11554,7 +11554,7 @@ code = ''' } // give each attr a subtype based on its rid + SHIFT - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)), LFSR_ATTR(UATTR((perm[j] + SHIFT) & 0x7f), 0, BUF(names[perm[j] % 6], 2)), @@ -11704,7 +11704,7 @@ code = ''' } // give each attr a subtype based on its rid + SHIFT - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(UATTR((perm[j] + SHIFT) & 0x7f), +1, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -11790,7 +11790,7 @@ code = ''' } // give each attr a subtype based on its rid + SHIFT - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(UATTR((perm[j] + SHIFT) & 0x7f), +1, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -11931,7 +11931,7 @@ code = ''' } // give each attr a subtype based on its rid + SHIFT - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(UATTR((perm[j] + SHIFT) & 0x7f), +1, BUF(names[perm[j] % 6], 4)))) => 0; } @@ -12065,7 +12065,7 @@ code = ''' } // give each attr a subtype based on its rid + SHIFT - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)), LFSR_ATTR(UATTR((perm[j] + SHIFT) & 0x7f), 0, BUF(names[perm[j] % 6], 2)))) => 0; @@ -12152,7 +12152,7 @@ code = ''' } // give each attr a subtype based on its rid + SHIFT - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)), LFSR_ATTR(UATTR((perm[j] + SHIFT) & 0x7f), 0, BUF(names[perm[j] % 6], 2)))) => 0; @@ -12291,7 +12291,7 @@ code = ''' } // give each attr a subtype based on its rid + SHIFT - lfsr_rbyd_commit(&lfs, &rbyd, rid-1, LFSR_ATTRS( + lfsr_rbyd_commit(&lfs, &rbyd, rid, LFSR_ATTRS( LFSR_ATTR(REG, +1, BUF(names[perm[j] % 6], 4)), LFSR_ATTR(UATTR((perm[j] + SHIFT) & 0x7f), 0, BUF(names[perm[j] % 6], 2)))) => 0;