Renamed SUB/SUPWIDE -> SUB/SUPMASK

This name makes more sense to me given what these bits are doing. Though
that may just be from the embedded engineer side.
This commit is contained in:
Christopher Haster
2024-01-22 08:03:20 -06:00
parent 3c13afd5c2
commit e04748dadd
3 changed files with 32 additions and 32 deletions
+21 -21
View File
@@ -662,8 +662,8 @@ enum lfsr_tag {
// some in-device only tag modifiers // some in-device only tag modifiers
LFSR_TAG_RM = 0x8000, LFSR_TAG_RM = 0x8000,
LFSR_TAG_GROW = 0x4000, LFSR_TAG_GROW = 0x4000,
LFSR_TAG_SUPWIDE = 0x2000, LFSR_TAG_SUPMASK = 0x2000,
LFSR_TAG_SUBWIDE = 0x1000, LFSR_TAG_SUBMASK = 0x1000,
// lfsr_rbyd_appendattr specific flags, also in-device only // lfsr_rbyd_appendattr specific flags, also in-device only
LFSR_TAG_DIVERGED = 0x4000, LFSR_TAG_DIVERGED = 0x4000,
@@ -679,8 +679,8 @@ enum lfsr_tag {
#define LFSR_TAG_SHRUB(tag) (LFSR_TAG_SHRUB | LFSR_TAG_##tag) #define LFSR_TAG_SHRUB(tag) (LFSR_TAG_SHRUB | LFSR_TAG_##tag)
#define LFSR_TAG_RM(tag) (LFSR_TAG_RM | LFSR_TAG_##tag) #define LFSR_TAG_RM(tag) (LFSR_TAG_RM | LFSR_TAG_##tag)
#define LFSR_TAG_GROW(tag) (LFSR_TAG_GROW | LFSR_TAG_##tag) #define LFSR_TAG_GROW(tag) (LFSR_TAG_GROW | LFSR_TAG_##tag)
#define LFSR_TAG_SUPWIDE(tag) (LFSR_TAG_SUPWIDE | LFSR_TAG_##tag) #define LFSR_TAG_SUPMASK(tag) (LFSR_TAG_SUPMASK | LFSR_TAG_##tag)
#define LFSR_TAG_SUBWIDE(tag) (LFSR_TAG_SUBWIDE | LFSR_TAG_##tag) #define LFSR_TAG_SUBMASK(tag) (LFSR_TAG_SUBMASK | LFSR_TAG_##tag)
// some other tag encodings with their own subfields // some other tag encodings with their own subfields
#define LFSR_TAG_ALT(d, c, key) \ #define LFSR_TAG_ALT(d, c, key) \
@@ -749,11 +749,11 @@ static inline bool lfsr_tag_isgrow(lfsr_tag_t tag) {
} }
static inline bool lfsr_tag_issupwide(lfsr_tag_t tag) { static inline bool lfsr_tag_issupwide(lfsr_tag_t tag) {
return tag & LFSR_TAG_SUPWIDE; return tag & LFSR_TAG_SUPMASK;
} }
static inline bool lfsr_tag_issubwide(lfsr_tag_t tag) { static inline bool lfsr_tag_issubwide(lfsr_tag_t tag) {
return tag & LFSR_TAG_SUBWIDE; return tag & LFSR_TAG_SUBMASK;
} }
// lfsr_rbyd_appendattr diverged specific flags // lfsr_rbyd_appendattr diverged specific flags
@@ -6276,7 +6276,7 @@ static int lfsr_mroot_commit_(lfs_t *lfs,
uint8_t mrootchild_buf[LFSR_MPTR_DSIZE]; uint8_t mrootchild_buf[LFSR_MPTR_DSIZE];
err = lfsr_mdir_commit__(lfs, &mrootanchor_, -1, -1, LFSR_ATTRS( err = lfsr_mdir_commit__(lfs, &mrootanchor_, -1, -1, LFSR_ATTRS(
LFSR_ATTR(-1, LFSR_ATTR(-1,
SUBWIDE(MROOT), 0, SUBMASK(MROOT), 0,
FROMMPTR(lfsr_mdir_mptr(&mrootchild_), mrootchild_buf)))); FROMMPTR(lfsr_mdir_mptr(&mrootchild_), mrootchild_buf))));
if (err) { if (err) {
LFS_ASSERT(err != LFS_ERR_RANGE); LFS_ASSERT(err != LFS_ERR_RANGE);
@@ -6347,7 +6347,7 @@ static int lfsr_mtree_commit_(lfs_t *lfs,
uint8_t mtree_buf[LFSR_BTREE_DSIZE]; uint8_t mtree_buf[LFSR_BTREE_DSIZE];
err = lfsr_mroot_commit_(lfs, -1, 0, NULL, LFSR_ATTRS( err = lfsr_mroot_commit_(lfs, -1, 0, NULL, LFSR_ATTRS(
LFSR_ATTR(-1, LFSR_ATTR(-1,
SUBWIDE(MTREE), 0, FROMBTREE(&mtree_, mtree_buf)))); SUBMASK(MTREE), 0, FROMBTREE(&mtree_, mtree_buf))));
if (err) { if (err) {
LFS_ASSERT(err != LFS_ERR_RANGE); LFS_ASSERT(err != LFS_ERR_RANGE);
return err; return err;
@@ -6713,7 +6713,7 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir,
uint8_t mdir_buf[LFSR_MPTR_DSIZE]; uint8_t mdir_buf[LFSR_MPTR_DSIZE];
err = lfsr_mroot_commit_(lfs, -1, 0, NULL, LFSR_ATTRS( err = lfsr_mroot_commit_(lfs, -1, 0, NULL, LFSR_ATTRS(
LFSR_ATTR(-1, LFSR_ATTR(-1,
SUBWIDE(MDIR), 0, SUBMASK(MDIR), 0,
FROMMPTR(lfsr_mdir_mptr(&mdir_), mdir_buf)))); FROMMPTR(lfsr_mdir_mptr(&mdir_), mdir_buf))));
if (err) { if (err) {
return err; return err;
@@ -8551,7 +8551,7 @@ int lfsr_mkdir(lfs_t *lfs, const char *path) {
// process // process
err = lfsr_mdir_commit(lfs, &mdir, LFSR_ATTRS( err = lfsr_mdir_commit(lfs, &mdir, LFSR_ATTRS(
LFSR_ATTR(mdir.mid, LFSR_ATTR(mdir.mid,
SUPWIDE(DIR), (!exists) ? +1 : 0, CAT( SUPMASK(DIR), (!exists) ? +1 : 0, CAT(
LFSR_DATA_LEB128(did), LFSR_DATA_LEB128(did),
LFSR_DATA_BUF(name, name_size))), LFSR_DATA_BUF(name, name_size))),
LFSR_ATTR(mdir.mid, LFSR_ATTR(mdir.mid,
@@ -8655,7 +8655,7 @@ int lfsr_remove(lfs_t *lfs, const char *path) {
// we use a create+delete here to also clear any attrs // we use a create+delete here to also clear any attrs
// and trim the entry size // and trim the entry size
(zombie) (zombie)
? LFSR_ATTR(mdir.mid, SUPWIDE(ORPHAN), 0, CAT( ? LFSR_ATTR(mdir.mid, SUPMASK(ORPHAN), 0, CAT(
LFSR_DATA_LEB128(did), LFSR_DATA_LEB128(did),
LFSR_DATA_BUF(name, name_size))) LFSR_DATA_BUF(name, name_size)))
: LFSR_ATTR(mdir.mid, RM, -1, NULL()), : LFSR_ATTR(mdir.mid, RM, -1, NULL()),
@@ -8807,7 +8807,7 @@ int lfsr_rename(lfs_t *lfs, const char *old_path, const char *new_path) {
// new rid, while also marking the old rid for removal // new rid, while also marking the old rid for removal
err = lfsr_mdir_commit(lfs, &new_mdir, LFSR_ATTRS( err = lfsr_mdir_commit(lfs, &new_mdir, LFSR_ATTRS(
LFSR_ATTR(new_mdir.mid, LFSR_ATTR(new_mdir.mid,
SUPWIDE(TAG(old_tag)), (!exists) ? +1 : 0, CAT( SUPMASK(TAG(old_tag)), (!exists) ? +1 : 0, CAT(
LFSR_DATA_LEB128(new_did), LFSR_DATA_LEB128(new_did),
LFSR_DATA_BUF(new_name, new_name_size))), LFSR_DATA_BUF(new_name, new_name_size))),
LFSR_ATTR(new_mdir.mid, LFSR_ATTR(new_mdir.mid,
@@ -9995,7 +9995,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file,
err = lfsr_bshrub_commit(lfs, file, LFSR_ATTRS( err = lfsr_bshrub_commit(lfs, file, LFSR_ATTRS(
LFSR_ATTR(bid_, LFSR_ATTR(bid_,
GROW(SUBWIDE(DATA)), GROW(SUBMASK(DATA)),
-(weight_ - lfs->cfg->fragment_size), -(weight_ - lfs->cfg->fragment_size),
DATA(lfsr_data_truncate(left_slice_, DATA(lfsr_data_truncate(left_slice_,
lfs->cfg->fragment_size))), lfs->cfg->fragment_size))),
@@ -10022,7 +10022,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file,
err = lfsr_bshrub_commit(lfs, file, LFSR_ATTRS( err = lfsr_bshrub_commit(lfs, file, LFSR_ATTRS(
LFSR_ATTR(bid_, LFSR_ATTR(bid_,
GROW(SUBWIDE(BLOCK)), GROW(SUBMASK(BLOCK)),
-(weight_ - lfsr_data_size(&bptr_.data)), -(weight_ - lfsr_data_size(&bptr_.data)),
FROMBPTR(&bptr_, buf)), FROMBPTR(&bptr_, buf)),
LFSR_ATTR(bid_ LFSR_ATTR(bid_
@@ -10056,14 +10056,14 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file,
.cksum = bptr_.cksum, .cksum = bptr_.cksum,
}; };
attrs[attr_count++] = LFSR_ATTR(bid_, attrs[attr_count++] = LFSR_ATTR(bid_,
GROW(SUBWIDE(BLOCK)), -(bid_+1 - pos), GROW(SUBMASK(BLOCK)), -(bid_+1 - pos),
FROMBPTR(&bptr__, &buf[buf_size])); FROMBPTR(&bptr__, &buf[buf_size]));
buf_size += LFSR_BPTR_DSIZE; buf_size += LFSR_BPTR_DSIZE;
// carve fragment? // carve fragment?
} else { } else {
attrs[attr_count++] = LFSR_ATTR(bid_, attrs[attr_count++] = LFSR_ATTR(bid_,
GROW(SUBWIDE(DATA)), -(bid_+1 - pos), GROW(SUBMASK(DATA)), -(bid_+1 - pos),
DATA(left_slice_)); DATA(left_slice_));
} }
@@ -11060,7 +11060,7 @@ int lfsr_file_sync(lfs_t *lfs, lfsr_file_t *file) {
} }
attrs[attr_count++] = LFSR_ATTR(file->m.mdir.mid, attrs[attr_count++] = LFSR_ATTR(file->m.mdir.mid,
SUBWIDE(REG), 0, DATA(data)); SUBMASK(REG), 0, DATA(data));
} }
// commit the file state // commit the file state
@@ -11068,22 +11068,22 @@ int lfsr_file_sync(lfs_t *lfs, lfsr_file_t *file) {
// null? no attr? // null? no attr?
if (lfsr_f_isunflush(file->m.flags) && file->buffer_size == 0) { if (lfsr_f_isunflush(file->m.flags) && file->buffer_size == 0) {
attrs[attr_count++] = LFSR_ATTR(file->m.mdir.mid, attrs[attr_count++] = LFSR_ATTR(file->m.mdir.mid,
SUBWIDE(RM(STRUCT)), 0, SUBMASK(RM(STRUCT)), 0,
NULL()); NULL());
// small file inlined in mdir? // small file inlined in mdir?
} else if (lfsr_f_isunflush(file->m.flags)) { } else if (lfsr_f_isunflush(file->m.flags)) {
attrs[attr_count++] = LFSR_ATTR(file->m.mdir.mid, attrs[attr_count++] = LFSR_ATTR(file->m.mdir.mid,
SUBWIDE(DATA), 0, SUBMASK(DATA), 0,
BUF(file->buffer, file->buffer_size)); BUF(file->buffer, file->buffer_size));
// bshrub? // bshrub?
} else if (lfsr_bshrub_isbshrub(&file->m.mdir, &file->bshrub)) { } else if (lfsr_bshrub_isbshrub(&file->m.mdir, &file->bshrub)) {
attrs[attr_count++] = LFSR_ATTR(file->m.mdir.mid, attrs[attr_count++] = LFSR_ATTR(file->m.mdir.mid,
SUBWIDE(SHRUBTRUNK), 0, SUBMASK(SHRUBTRUNK), 0,
SHRUBTRUNK(&file->bshrub_.u.bshrub)); SHRUBTRUNK(&file->bshrub_.u.bshrub));
// btree? // btree?
} else if (lfsr_bshrub_isbtree(&file->m.mdir, &file->bshrub)) { } else if (lfsr_bshrub_isbtree(&file->m.mdir, &file->bshrub)) {
attrs[attr_count++] = LFSR_ATTR(file->m.mdir.mid, attrs[attr_count++] = LFSR_ATTR(file->m.mdir.mid,
SUBWIDE(BTREE), 0, SUBMASK(BTREE), 0,
FROMBTREE(&file->bshrub.u.btree, &buf[buf_size])); FROMBTREE(&file->bshrub.u.btree, &buf[buf_size]));
buf_size += LFSR_BTREE_DSIZE; buf_size += LFSR_BTREE_DSIZE;
} else { } else {
+1 -1
View File
@@ -50,7 +50,7 @@ code = '''
// name attributes, the name attribute holds the weight not // name attributes, the name attribute holds the weight not
// the struct tag // the struct tag
return lfsr_btree_commit(lfs, btree, LFSR_ATTRS( return lfsr_btree_commit(lfs, btree, LFSR_ATTRS(
LFSR_ATTR(bid, SUBWIDE(TAG(tag)), 0, DATA(data)), LFSR_ATTR(bid, SUBMASK(TAG(tag)), 0, DATA(data)),
LFSR_ATTR(bid, GROW, weight - weight_, NULL()))); LFSR_ATTR(bid, GROW, weight - weight_, NULL())));
} }
+10 -10
View File
@@ -11762,7 +11762,7 @@ code = '''
// remove with a wide tag // remove with a wide tag
lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS( lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS(
LFSR_ATTR(j, RM(SUBWIDE(UATTR)), 0, NULL()))) => 0; LFSR_ATTR(j, RM(SUBMASK(UATTR)), 0, NULL()))) => 0;
// try traversing over the tags // try traversing over the tags
lfsr_rbyd_fetch(&lfs, &rbyd, rbyd.blocks[0], CFG->block_size) => 0; lfsr_rbyd_fetch(&lfs, &rbyd, rbyd.blocks[0], CFG->block_size) => 0;
@@ -11901,7 +11901,7 @@ code = '''
// replace with bitwise inverse // replace with bitwise inverse
lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS( lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS(
LFSR_ATTR(j, SUBWIDE(UATTR(~(j + SHIFT) & 0x7f)), 0, LFSR_ATTR(j, SUBMASK(UATTR(~(j + SHIFT) & 0x7f)), 0,
BUF(names[j % 6], 3)))) => 0; BUF(names[j % 6], 3)))) => 0;
// try traversing over the tags // try traversing over the tags
@@ -12133,7 +12133,7 @@ code = '''
// remove with a wide tag // remove with a wide tag
lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS( lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS(
LFSR_ATTR(j, RM(SUBWIDE(UATTR)), 0, NULL()))) => 0; LFSR_ATTR(j, RM(SUBMASK(UATTR)), 0, NULL()))) => 0;
// try traversing over the tags // try traversing over the tags
lfsr_rbyd_fetch(&lfs, &rbyd, rbyd.blocks[0], CFG->block_size) => 0; lfsr_rbyd_fetch(&lfs, &rbyd, rbyd.blocks[0], CFG->block_size) => 0;
@@ -12281,7 +12281,7 @@ code = '''
// replace with bitwise inverse // replace with bitwise inverse
lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS( lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS(
LFSR_ATTR(j, SUBWIDE(UATTR(~(j + SHIFT) & 0x7f)), 0, LFSR_ATTR(j, SUBMASK(UATTR(~(j + SHIFT) & 0x7f)), 0,
BUF(names[j % 6], 3)))) => 0; BUF(names[j % 6], 3)))) => 0;
// try traversing over the tags // try traversing over the tags
@@ -12514,7 +12514,7 @@ code = '''
// remove with a wide tag // remove with a wide tag
lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS( lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS(
LFSR_ATTR(j, RM(SUBWIDE(UATTR)), 0, NULL()))) => 0; LFSR_ATTR(j, RM(SUBMASK(UATTR)), 0, NULL()))) => 0;
// try traversing over the tags // try traversing over the tags
lfsr_rbyd_fetch(&lfs, &rbyd, rbyd.blocks[0], CFG->block_size) => 0; lfsr_rbyd_fetch(&lfs, &rbyd, rbyd.blocks[0], CFG->block_size) => 0;
@@ -12655,7 +12655,7 @@ code = '''
// replace with bitwise inverse // replace with bitwise inverse
lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS( lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS(
LFSR_ATTR(j, SUBWIDE(UATTR(~(j + SHIFT) & 0x7f)), 0, LFSR_ATTR(j, SUBMASK(UATTR(~(j + SHIFT) & 0x7f)), 0,
BUF(names[j % 6], 6)))) => 0; BUF(names[j % 6], 6)))) => 0;
// try traversing over the tags // try traversing over the tags
@@ -12877,7 +12877,7 @@ code = '''
// remove with a wide tag // remove with a wide tag
lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS( lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS(
LFSR_ATTR(j, RM(SUPWIDE(UATTR)), 0, NULL()))) => 0; LFSR_ATTR(j, RM(SUPMASK(UATTR)), 0, NULL()))) => 0;
// try traversing over the tags // try traversing over the tags
lfsr_rbyd_fetch(&lfs, &rbyd, rbyd.blocks[0], CFG->block_size) => 0; lfsr_rbyd_fetch(&lfs, &rbyd, rbyd.blocks[0], CFG->block_size) => 0;
@@ -13016,7 +13016,7 @@ code = '''
// replace with bitwise inverse // replace with bitwise inverse
lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS( lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS(
LFSR_ATTR(j, SUPWIDE(UATTR(~(j + SHIFT) & 0x7f)), 0, LFSR_ATTR(j, SUPMASK(UATTR(~(j + SHIFT) & 0x7f)), 0,
BUF(names[j % 6], 3)))) => 0; BUF(names[j % 6], 3)))) => 0;
// try traversing over the tags // try traversing over the tags
@@ -13243,7 +13243,7 @@ code = '''
// subwide replace a neighbor to the hole // subwide replace a neighbor to the hole
lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS( lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS(
LFSR_ATTR(-1, LFSR_ATTR(-1,
SUBWIDE(UATTR(2)), 0, SUBMASK(UATTR(2)), 0,
BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; BUF("\xcc\xcc\xcc\xcc", 4)))) => 0;
assert(rbyd.weight == 0); assert(rbyd.weight == 0);
@@ -13302,7 +13302,7 @@ code = '''
// supwide replace a neighbor to the hole // supwide replace a neighbor to the hole
lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS( lfsr_rbyd_commit(&lfs, &rbyd, LFSR_ATTRS(
LFSR_ATTR(-1, LFSR_ATTR(-1,
SUPWIDE(UATTR(2)), 0, SUPMASK(UATTR(2)), 0,
BUF("\xcc\xcc\xcc\xcc", 4)))) => 0; BUF("\xcc\xcc\xcc\xcc", 4)))) => 0;
assert(rbyd.weight == 1); assert(rbyd.weight == 1);