Added mount-time LFS_M_FLUSH/SYNC
These simply imply LFS_O_FLUSH/SYNC on all open writable files.
LFS_M_SYNC is equivalent to MS_SYNCHRONOUS in Linux/etc, while
LFS_M_FLUSH is just provided for consistency.
As pure conveniences, these may seem a bit out of scope for littlefs,
except they are _very_ cheap:
code stack
before: 36356 2664
after: 36356 (+0.0%) 2664 (+0.0%)
Ok, they're not _completely_ free! It just turns out they cost 8 bytes,
and a bit of simplification around flag checking in lfsr_mount saved
8 bytes:
code stack
before: 36356 2664
m_flush/sync: 36364 (+0.0%) 2664 (+0.0%)
mount-no-mask: 36356 (+0.0%) 2664 (+0.0%)
This commit is contained in:
@@ -14,12 +14,16 @@ code = '''
|
||||
[cases.test_mount_flags]
|
||||
defines.RDONLY = [false, true]
|
||||
defines.CKPROGS = [false, true]
|
||||
defines.FLUSH = [false, true]
|
||||
defines.SYNC = [false, true]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
((RDONLY) ? LFS_M_RDONLY : LFS_M_RDWR)
|
||||
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
|
||||
| ((CKPROGS) ? LFS_M_CKPROGS : 0)
|
||||
| ((FLUSH) ? LFS_M_FLUSH : 0)
|
||||
| ((SYNC) ? LFS_M_SYNC : 0),
|
||||
CFG) => 0;
|
||||
|
||||
struct lfs_fsinfo fsinfo;
|
||||
@@ -27,6 +31,8 @@ code = '''
|
||||
assert(fsinfo.flags == (
|
||||
((RDONLY) ? LFS_I_RDONLY : 0)
|
||||
| ((CKPROGS) ? LFS_I_CKPROGS : 0)
|
||||
| ((FLUSH) ? LFS_I_FLUSH : 0)
|
||||
| ((SYNC) ? LFS_I_SYNC : 0)
|
||||
| LFS_I_CANLOOKAHEAD
|
||||
| LFS_I_UNCOMPACTED));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user