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
+11 -14
View File
@@ -979,8 +979,7 @@ code = '''
// delete any bshrub/btree
lfsr_mdir_commit(&lfs, &file.b.o.mdir, LFSR_RATTRS(
LFSR_RATTR(
LFSR_TAG_RM | LFSR_TAG_SUB | LFSR_TAG_STRUCT, 0,
NULL, 0))) => 0;
LFSR_TAG_RM | LFSR_TAG_SUB | LFSR_TAG_STRUCT, 0))) => 0;
lfsr_file_close(&lfs, &file) => 0;
@@ -1095,27 +1094,25 @@ code = '''
// create an empty bshrub
lfsr_mdir_commit(&lfs, &file.b.o.mdir, LFSR_RATTRS(
LFSR_RATTR(
LFSR_TAG_SHRUBCOMMIT, 0,
LFSR_RATTR_SHRUBCOMMIT(
(&(lfsr_shrubcommit_t){
.bshrub=&file.b,
.rid=0,
.rattrs=((lfsr_rattr_t[]){
LFSR_RATTR_BUF(LFSR_TAG_DATA, +1, "?", 1)}),
.rattr_count=1}), 0))) => 0;
.rattr_count=1})))) => 0;
lfsr_mdir_commit(&lfs, &file.b.o.mdir, LFSR_RATTRS(
LFSR_RATTR(
LFSR_TAG_SHRUBCOMMIT, 0,
LFSR_RATTR_SHRUBCOMMIT(
(&(lfsr_shrubcommit_t){
.bshrub=&file.b,
.rid=0,
.rattrs=((lfsr_rattr_t[]){
LFSR_RATTR(LFSR_TAG_RM, -1, NULL, 0)}),
.rattr_count=1}), 0))) => 0;
LFSR_RATTR(LFSR_TAG_RM, -1)}),
.rattr_count=1})))) => 0;
lfsr_mdir_commit(&lfs, &file.b.o.mdir, LFSR_RATTRS(
LFSR_RATTR(
LFSR_RATTR_SHRUB(
LFSR_TAG_SUB | LFSR_TAG_BSHRUB, 0,
&file.b.shrub_, LFSR_SHRUB_DSIZE))) => 0;
&file.b.shrub_))) => 0;
lfsr_file_close(&lfs, &file) => 0;
@@ -1234,11 +1231,11 @@ code = '''
lfsr_rbyd_commit(&lfs, &file.b.shrub, 0, LFSR_RATTRS(
LFSR_RATTR_BUF(LFSR_TAG_DATA, +1, "?", 1))) => 0;
lfsr_rbyd_commit(&lfs, &file.b.shrub, 0, LFSR_RATTRS(
LFSR_RATTR(LFSR_TAG_RM, -1, NULL, 0))) => 0;
LFSR_RATTR(LFSR_TAG_RM, -1))) => 0;
lfsr_mdir_commit(&lfs, &file.b.o.mdir, LFSR_RATTRS(
LFSR_RATTR(
LFSR_RATTR_BTREE(
LFSR_TAG_SUB | LFSR_TAG_BTREE, 0,
&file.b.shrub, LFSR_BTREE_DSIZE))) => 0;
&file.b.shrub))) => 0;
lfsr_file_close(&lfs, &file) => 0;