Added lfsr_rid/bid/mid/did_t types, tried using types more consistently

Adopted lfsr_rid/bid/mid/did_t where appropriate. This includes using
lfsr_rid_t for tag/rbyd weights. Although I am using lfsr_srid_t for
rbyd weights now, since it both captures the use of the sign bit and
reduces the number of casts a bit in the code.

I learned recently Zig has any-bit integers (e.g. uint31_t), and I'm
realizing how nice it would be to have those in this codebase.

Also tried to use lfs_size_t/lfs_off_t more correctly. In Linux/BSD,
only off_t is used for file-size-related operations and is usually much
larger than size_t. These were used interchangably in littlefs and their
original meaning kind of fell by the wayside. Getting their use right
will be important if littlefs ever supports different integer widths.
This commit is contained in:
Christopher Haster
2023-09-13 17:43:47 -05:00
parent b5c9b8eb49
commit 7aa9280897
4 changed files with 341 additions and 332 deletions
+2 -4
View File
@@ -1485,8 +1485,7 @@ code = '''
mdir.mid = (mdir.mid & lfsr_mbidmask(&lfs))
| (mdir.mid % (mdir.u.m.weight+1));
// choose to create or delete
uint8_t op = ((lfs_size_t)(mdir.mid & lfsr_mridmask(&lfs))
== mdir.u.m.weight
uint8_t op = ((mdir.mid & lfsr_mridmask(&lfs)) == mdir.u.m.weight
? 0
: TEST_PRNG(&prng) % 2);
@@ -2569,8 +2568,7 @@ code = '''
mdir.mid = (mdir.mid & lfsr_mbidmask(&lfs))
| (mdir.mid % (mdir.u.m.weight+1));
// choose to create or delete
uint8_t op = ((lfs_size_t)(mdir.mid & lfsr_mridmask(&lfs))
== mdir.u.m.weight
uint8_t op = ((mdir.mid & lfsr_mridmask(&lfs)) == mdir.u.m.weight
? 0
: TEST_PRNG(&prng) % 3);