Restructured the major interfaces of the filesystem

This commit is contained in:
Christopher Haster
2017-03-25 16:20:31 -05:00
parent f566846223
commit 84a57642e5
8 changed files with 481 additions and 444 deletions

38
lfs_util.h Normal file
View File

@@ -0,0 +1,38 @@
/*
* lfs utility functions
*
* Copyright (c) 2017 Christopher Haster
* Distributed under the MIT license
*/
#ifndef LFS_UTIL_H
#define LFS_UTIL_H
#include "lfs_config.h"
// Builtin functions
static inline uint32_t lfs_max(uint32_t a, uint32_t b) {
return (a > b) ? a : b;
}
static inline uint32_t lfs_min(uint32_t a, uint32_t b) {
return (a < b) ? a : b;
}
static inline uint32_t lfs_ctz(uint32_t a) {
return __builtin_ctz(a);
}
static inline uint32_t lfs_npw2(uint32_t a) {
return 32 - __builtin_clz(a-1);
}
static inline int lfs_scmp(uint32_t a, uint32_t b) {
return (int)(unsigned)(a - b);
}
uint32_t lfs_crc(const void *buffer, lfs_size_t size, uint32_t crc);
#endif