diff options
author | Christopher Haster <geky@geky.net> | 2023-12-19 23:12:10 +0300 |
---|---|---|
committer | Christopher Haster <geky@geky.net> | 2023-12-19 23:12:10 +0300 |
commit | 9a620c730c097a4ddccebca983e35625c1f4fb2e (patch) | |
tree | 6f8bc8251a20ec480edb079c33b2f4ded1081d33 | |
parent | a0c6c54345921cb98a4feb39651939122f99fa19 (diff) |
Added LFS_CRC, easier override for lfs_crceasy-util-defines
Now you can override littlefs's CRC implementation with some simple
defines:
-DLFS_CRC=lfs_crc
The motivation for this is the same for LFS_MALLOC/LFS_FREE. I think
these are the main "system-level" utils that users want to override.
Don't override with this something that's not CRC32! Your filesystem
will no longer be compatible with other tools! This is only intended for
provided hardware acceleration!
-rw-r--r-- | lfs_util.c | 3 | ||||
-rw-r--r-- | lfs_util.h | 6 |
2 files changed, 9 insertions, 0 deletions
@@ -11,6 +11,8 @@ #ifndef LFS_CONFIG +// If user provides their own CRC impl we don't need this +#ifndef LFS_CRC // Software CRC implementation with small lookup table uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) { static const uint32_t rtable[16] = { @@ -29,6 +31,7 @@ uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) { return crc; } +#endif #endif @@ -212,7 +212,13 @@ static inline uint32_t lfs_tobe32(uint32_t a) { } // Calculate CRC-32 with polynomial = 0x04c11db7 +#ifdef LFS_CRC +uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) { + return LFS_CRC(crc, buffer, size) +} +#else uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size); +#endif // Allocate memory, only used if buffers are not provided to littlefs // Note, memory must be 64-bit aligned |