Simplified the internal xored-globals implementation

There wasn't much use (and inconsistent compiler support) for storing
small values next to the unaligned lfs_global_t struct. So instead, I've
rounded the struct up to the nearest word to try to take advantage of
the alignment in xor and memset operations.

I've also moved the global fetching into lfs_mount, since that was the
only use of the operation. This allows for some variable reuse in the
mount function.
This commit is contained in:
Christopher Haster
2018-08-03 19:01:27 -05:00
parent 35f68d28cc
commit 97f35c3e05
2 changed files with 69 additions and 105 deletions

9
lfs.h
View File

@@ -287,18 +287,23 @@ typedef struct lfs_cache {
} lfs_cache_t;
typedef union lfs_global {
uint16_t u16[5];
uint32_t u32[3];
struct {
lfs_block_t movepair[2];
uint16_t moveid;
bool deorphaned;
} s;
} lfs_global_t;
typedef struct lfs_mdir {
lfs_block_t pair[2];
lfs_block_t tail[2];
uint32_t rev;
uint32_t etag;
lfs_off_t off;
uint16_t count;
bool erased;
bool split;
lfs_block_t tail[2];
lfs_global_t locals;
} lfs_mdir_t;