Replaced rattr.u.etc with rattr relevant types

This does a couple things:

- Makes attr-lists a bit more self-documenting.

- Adds a bit more type-safety. The LFSR_RATTR_* macros should be able to
  reject types that don't match the expected encoding.

- Makes it easier to adjust dsize estimates at one location.

  Specifically, this makes it harder to forget bptr's LFSR_BPTR_DSIZE.

---

Surprisingly this did have a small impact on code size. I'm not entirely
sure why, but considering how much of the codebase this touches I'm just
going to chalk this up to compiler noise:

           code          stack          ctx
  before: 35488           2440          636
  after:  35536 (+0.1%)   2440 (+0.0%)  636 (+0.0%)

lfsr_file_carve seems the hardest hit:

  function (0 added, 0 removed)      osize    nsize    dsize
  lfsr_file_open                        16       20       +4 (+25.0%)
  lfsr_file_carve                     1316     1356      +40 (+3.0%)
  lfsr_remove                          408      412       +4 (+1.0%)
  TOTAL                              35488    35536      +48 (+0.1%)
This commit is contained in:
Christopher Haster
2025-02-12 13:49:38 -06:00
parent d806e7e323
commit 91341a4c48
6 changed files with 317 additions and 313 deletions
+13 -13
View File
@@ -687,7 +687,7 @@ code = '''
lfsr_mtree_namelookup(&lfs, 0, (const char*)buffer+1, SIZE-1,
&mdir, NULL, NULL) => 0;
lfsr_mdir_commit(&lfs, &mdir, LFSR_RATTRS(
LFSR_RATTR(LFSR_TAG_RM, -1, NULL, 0))) => 0;
LFSR_RATTR(LFSR_TAG_RM, -1))) => 0;
assert(mdir.rbyd.weight == 0);
// assert mdir was dropped
@@ -779,7 +779,7 @@ code = '''
// force mdir to compact while we're removing
mdir.rbyd.eoff = -1;
lfsr_mdir_commit(&lfs, &mdir, LFSR_RATTRS(
LFSR_RATTR(LFSR_TAG_RM, -1, NULL, 0))) => 0;
LFSR_RATTR(LFSR_TAG_RM, -1))) => 0;
assert(mdir.rbyd.weight == 0);
// assert mdir was dropped
@@ -862,7 +862,7 @@ code = '''
lfs.mroot.rbyd.eoff = -1;
mdir.rbyd.eoff = -1;
lfsr_mdir_commit(&lfs, &mdir, LFSR_RATTRS(
LFSR_RATTR(LFSR_TAG_RM, -1, NULL, 0))) => 0;
LFSR_RATTR(LFSR_TAG_RM, -1))) => 0;
assert(mdir.rbyd.weight == 2);
// assert split/drop worked out
@@ -956,7 +956,7 @@ code = '''
// force mdir to compact while we're removing
mdir.rbyd.eoff = -1;
lfsr_mdir_commit(&lfs, &mdir, LFSR_RATTRS(
LFSR_RATTR(LFSR_TAG_RM, -1, NULL, 0))) => 0;
LFSR_RATTR(LFSR_TAG_RM, -1))) => 0;
assert(mdir.rbyd.weight == 1);
// assert split/drop worked out
@@ -1070,7 +1070,7 @@ code = '''
// force mdir to compact while we're removing
mdir.rbyd.eoff = -1;
lfsr_mdir_commit(&lfs, &mdir, LFSR_RATTRS(
LFSR_RATTR(LFSR_TAG_RM, -1, NULL, 0))) => 0;
LFSR_RATTR(LFSR_TAG_RM, -1))) => 0;
assert(mdir.rbyd.weight == 1);
// assert split/drop worked out
@@ -1198,7 +1198,7 @@ code = '''
mdir.rbyd.eoff = -1;
}
lfsr_mdir_commit(&lfs, &mdir, LFSR_RATTRS(
LFSR_RATTR(LFSR_TAG_RM, -1, NULL, 0))) => 0;
LFSR_RATTR(LFSR_TAG_RM, -1))) => 0;
}
}
@@ -2276,7 +2276,7 @@ code = '''
// force mdir to compact while we're removing
mdir.rbyd.eoff = -1;
lfsr_mdir_commit(&lfs, &mdir, LFSR_RATTRS(
LFSR_RATTR(LFSR_TAG_RM, -1, NULL, 0))) => 0;
LFSR_RATTR(LFSR_TAG_RM, -1))) => 0;
assert(mdir.rbyd.weight == 0);
// assert mroot relocated
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
@@ -2609,7 +2609,7 @@ code = '''
mdir.rbyd.eoff = -1;
}
lfsr_mdir_commit(&lfs, &mdir, LFSR_RATTRS(
LFSR_RATTR(LFSR_TAG_RM, -1, NULL, 0))) => 0;
LFSR_RATTR(LFSR_TAG_RM, -1))) => 0;
}
}
@@ -2755,7 +2755,7 @@ code = '''
lfsr_mtree_namelookup(&lfs, 0, "a", 1,
&mdir, NULL, NULL) => 0;
lfsr_mdir_commit(&lfs, &mdir, LFSR_RATTRS(
LFSR_RATTR(LFSR_TAG_RM, -1, NULL, 0))) => 0;
LFSR_RATTR(LFSR_TAG_RM, -1))) => 0;
assert(mdir.rbyd.weight == 2);
// assert neighbor was removed
@@ -2805,7 +2805,7 @@ code = '''
lfsr_mtree_namelookup(&lfs, 0, "b", 1,
&mdir, NULL, NULL) => 0;
lfsr_mdir_commit(&lfs, &mdir, LFSR_RATTRS(
LFSR_RATTR(LFSR_TAG_RM, -1, NULL, 0))) => 0;
LFSR_RATTR(LFSR_TAG_RM, -1))) => 0;
assert(mdir.rbyd.weight == 2);
// assert neighbor was removed
@@ -3427,7 +3427,7 @@ code = '''
// now remove the middle entry, forcing a drop
lfsr_mdir_commit(&lfs, &mdir, LFSR_RATTRS(
LFSR_RATTR(LFSR_TAG_RM, -1, NULL, 0))) => 0;
LFSR_RATTR(LFSR_TAG_RM, -1))) => 0;
assert(mdir.rbyd.weight == 0);
// assert mdir was dropped correctly
@@ -4458,9 +4458,9 @@ code = '''
lfs_alloc_ckpoint(&lfs);
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_RATTRS(
LFSR_RATTR(
LFSR_RATTR_MPTR(
LFSR_TAG_MROOT, 0,
LFSR_MPTR_MROOTANCHOR(), LFSR_MPTR_DSIZE))) => 0;
LFSR_MPTR_MROOTANCHOR()))) => 0;
// technically, cycle detection only needs to work when we're validating
lfsr_traversal_t t;