mirror of
https://github.com/littlefs-project/littlefs.git
synced 2025-11-16 12:34:34 +00:00
Restructured the major interfaces of the filesystem
This commit is contained in:
38
lfs_util.h
Normal file
38
lfs_util.h
Normal 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
|
||||
Reference in New Issue
Block a user