update fptrgroup

This commit is contained in:
Steven Dan
2026-03-30 20:07:01 +08:00
parent 898ef085c0
commit fe0028bba4
3 changed files with 21 additions and 16 deletions

View File

@@ -161,24 +161,24 @@ struct lfs_config {
// Read a region in a block. Negative error codes are propagated // Read a region in a block. Negative error codes are propagated
// to the user. // to the user.
int (*read)(const struct lfs_config *c, lfs_block_t block, int (* __attribute__((fptrgroup("local_block_device_read_fptr_grp"))) read)(const struct lfs_config *c, lfs_block_t block,
lfs_off_t off, void *buffer, lfs_size_t size); lfs_off_t off, void *buffer, lfs_size_t size);
// Program a region in a block. The block must have previously // Program a region in a block. The block must have previously
// been erased. Negative error codes are propagated to the user. // been erased. Negative error codes are propagated to the user.
// May return LFS_ERR_CORRUPT if the block should be considered bad. // May return LFS_ERR_CORRUPT if the block should be considered bad.
int (*prog)(const struct lfs_config *c, lfs_block_t block, int (* __attribute__((fptrgroup("local_block_device_prog_fptr_grp"))) prog)(const struct lfs_config *c, lfs_block_t block,
lfs_off_t off, const void *buffer, lfs_size_t size); lfs_off_t off, const void *buffer, lfs_size_t size);
// Erase a block. A block must be erased before being programmed. // Erase a block. A block must be erased before being programmed.
// The state of an erased block is undefined. Negative error codes // The state of an erased block is undefined. Negative error codes
// are propagated to the user. // are propagated to the user.
// May return LFS_ERR_CORRUPT if the block should be considered bad. // May return LFS_ERR_CORRUPT if the block should be considered bad.
int (*erase)(const struct lfs_config *c, lfs_block_t block); int (* __attribute__((fptrgroup("local_block_device_erase_fptr_grp"))) erase)(const struct lfs_config *c, lfs_block_t block);
// Sync the state of the underlying block device. Negative error codes // Sync the state of the underlying block device. Negative error codes
// are propagated to the user. // are propagated to the user.
int (*sync)(const struct lfs_config *c); int (* __attribute__((fptrgroup("local_block_device_sync_fptr_grp"))) sync)(const struct lfs_config *c);
#ifdef LFS_THREADSAFE #ifdef LFS_THREADSAFE
// Lock the underlying block device. Negative error codes // Lock the underlying block device. Negative error codes
@@ -730,7 +730,7 @@ lfs_ssize_t lfs_fs_size(lfs_t *lfs);
// blocks are in use or how much of the storage is available. // blocks are in use or how much of the storage is available.
// //
// Returns a negative error code on failure. // Returns a negative error code on failure.
int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data); int lfs_fs_traverse(lfs_t *lfs, int (* __attribute__((fptrgroup("lfs_cb_block_fptr_grp"))) cb)(void*, lfs_block_t), void *data);
#ifndef LFS_READONLY #ifndef LFS_READONLY
// Attempt to make the filesystem consistent and ready for writing // Attempt to make the filesystem consistent and ready for writing

View File

@@ -607,7 +607,7 @@ static lfs_soff_t lfs_file_size_(lfs_t *lfs, lfs_file_t *file);
static lfs_ssize_t lfs_fs_size_(lfs_t *lfs); static lfs_ssize_t lfs_fs_size_(lfs_t *lfs);
static int lfs_fs_traverse_(lfs_t *lfs, static int lfs_fs_traverse_(lfs_t *lfs,
int (*cb)(void *data, lfs_block_t block), void *data, int (* __attribute__((fptrgroup("lfs_cb_block_fptr_grp"))) cb)(void *data, lfs_block_t block), void *data,
bool includeorphans); bool includeorphans);
static int lfs_deinit(lfs_t *lfs); static int lfs_deinit(lfs_t *lfs);
@@ -633,6 +633,7 @@ static void lfs_alloc_drop(lfs_t *lfs) {
} }
#ifndef LFS_READONLY #ifndef LFS_READONLY
__attribute__((fptrgroup("lfs_cb_block_fptr_grp")))
static int lfs_alloc_lookahead(void *p, lfs_block_t block) { static int lfs_alloc_lookahead(void *p, lfs_block_t block) {
lfs_t *lfs = (lfs_t*)p; lfs_t *lfs = (lfs_t*)p;
lfs_block_t off = ((block - lfs->lookahead.start) lfs_block_t off = ((block - lfs->lookahead.start)
@@ -912,7 +913,7 @@ struct lfs_dir_traverse {
uint16_t end; uint16_t end;
int16_t diff; int16_t diff;
int (*cb)(void *data, lfs_tag_t tag, const void *buffer); int (* __attribute__((fptrgroup("lfs_cb_tag_fptr_grp"))) cb)(void *data, lfs_tag_t tag, const void *buffer);
void *data; void *data;
lfs_tag_t tag; lfs_tag_t tag;
@@ -926,7 +927,7 @@ static int lfs_dir_traverse(lfs_t *lfs,
const struct lfs_mattr *attrs, int attrcount, const struct lfs_mattr *attrs, int attrcount,
lfs_tag_t tmask, lfs_tag_t ttag, lfs_tag_t tmask, lfs_tag_t ttag,
uint16_t begin, uint16_t end, int16_t diff, uint16_t begin, uint16_t end, int16_t diff,
int (*cb)(void *data, lfs_tag_t tag, const void *buffer), void *data) { int (* __attribute__((fptrgroup("lfs_cb_tag_fptr_grp"))) cb)(void *data, lfs_tag_t tag, const void *buffer), void *data) {
// This function in inherently recursive, but bounded. To allow tool-based // This function in inherently recursive, but bounded. To allow tool-based
// analysis without unnecessary code-cost we use an explicit stack // analysis without unnecessary code-cost we use an explicit stack
struct lfs_dir_traverse stack[LFS_DIR_TRAVERSE_DEPTH-1]; struct lfs_dir_traverse stack[LFS_DIR_TRAVERSE_DEPTH-1];
@@ -1120,7 +1121,7 @@ popped:
static lfs_stag_t lfs_dir_fetchmatch(lfs_t *lfs, static lfs_stag_t lfs_dir_fetchmatch(lfs_t *lfs,
lfs_mdir_t *dir, const lfs_block_t pair[2], lfs_mdir_t *dir, const lfs_block_t pair[2],
lfs_tag_t fmask, lfs_tag_t ftag, uint16_t *id, lfs_tag_t fmask, lfs_tag_t ftag, uint16_t *id,
int (*cb)(void *data, lfs_tag_t tag, const void *buffer), void *data) { int (* __attribute__((fptrgroup("lfs_cb_tag_fptr_grp"))) cb)(void *data, lfs_tag_t tag, const void *buffer), void *data) {
// we can find tag very efficiently during a fetch, since we're already // we can find tag very efficiently during a fetch, since we're already
// scanning the entire directory // scanning the entire directory
lfs_stag_t besttag = -1; lfs_stag_t besttag = -1;
@@ -1462,6 +1463,7 @@ struct lfs_dir_find_match {
lfs_size_t size; lfs_size_t size;
}; };
__attribute__((fptrgroup("lfs_cb_tag_fptr_grp")))
static int lfs_dir_find_match(void *data, static int lfs_dir_find_match(void *data,
lfs_tag_t tag, const void *buffer) { lfs_tag_t tag, const void *buffer) {
struct lfs_dir_find_match *name = data; struct lfs_dir_find_match *name = data;
@@ -1924,6 +1926,7 @@ static int lfs_dir_split(lfs_t *lfs,
#endif #endif
#ifndef LFS_READONLY #ifndef LFS_READONLY
__attribute__((fptrgroup("lfs_cb_tag_fptr_grp")))
static int lfs_dir_commit_size(void *p, lfs_tag_t tag, const void *buffer) { static int lfs_dir_commit_size(void *p, lfs_tag_t tag, const void *buffer) {
lfs_size_t *size = p; lfs_size_t *size = p;
(void)buffer; (void)buffer;
@@ -1942,6 +1945,7 @@ struct lfs_dir_commit_commit {
#ifndef LFS_READONLY #ifndef LFS_READONLY
#pragma stackfunction 100 #pragma stackfunction 100
__attribute__((fptrgroup("lfs_cb_tag_fptr_grp")))
static int lfs_dir_commit_commit(void *p, lfs_tag_t tag, const void *buffer) { static int lfs_dir_commit_commit(void *p, lfs_tag_t tag, const void *buffer) {
struct lfs_dir_commit_commit *commit = p; struct lfs_dir_commit_commit *commit = p;
return lfs_dir_commitattr(commit->lfs, commit->commit, tag, buffer); return lfs_dir_commitattr(commit->lfs, commit->commit, tag, buffer);
@@ -3042,7 +3046,7 @@ relocate:
static int lfs_ctz_traverse(lfs_t *lfs, static int lfs_ctz_traverse(lfs_t *lfs,
const lfs_cache_t *pcache, lfs_cache_t *rcache, const lfs_cache_t *pcache, lfs_cache_t *rcache,
lfs_block_t head, lfs_size_t size, lfs_block_t head, lfs_size_t size,
int (*cb)(void*, lfs_block_t), void *data) { int (* __attribute__((fptrgroup("lfs_cb_block_fptr_grp"))) cb)(void*, lfs_block_t), void *data) {
if (size == 0) { if (size == 0) {
return 0; return 0;
} }
@@ -4722,7 +4726,7 @@ static int lfs_fs_stat_(lfs_t *lfs, struct lfs_fsinfo *fsinfo) {
#pragma stackfunction 100 #pragma stackfunction 100
int lfs_fs_traverse_(lfs_t *lfs, int lfs_fs_traverse_(lfs_t *lfs,
int (*cb)(void *data, lfs_block_t block), void *data, int (* __attribute__((fptrgroup("lfs_cb_block_fptr_grp"))) cb)(void *data, lfs_block_t block), void *data,
bool includeorphans) { bool includeorphans) {
// iterate over metadata pairs // iterate over metadata pairs
lfs_mdir_t dir = {.tail = {0, 1}}; lfs_mdir_t dir = {.tail = {0, 1}};
@@ -5200,6 +5204,7 @@ static int lfs_fs_mkconsistent_(lfs_t *lfs) {
} }
#endif #endif
__attribute__((fptrgroup("lfs_cb_block_fptr_grp")))
static int lfs_fs_size_count(void *p, lfs_block_t block) { static int lfs_fs_size_count(void *p, lfs_block_t block) {
(void)block; (void)block;
lfs_size_t *size = p; lfs_size_t *size = p;
@@ -6459,7 +6464,7 @@ lfs_ssize_t lfs_fs_size(lfs_t *lfs) {
return res; return res;
} }
int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void *, lfs_block_t), void *data) { int lfs_fs_traverse(lfs_t *lfs, int (* __attribute__((fptrgroup("lfs_cb_block_fptr_grp"))) cb)(void *, lfs_block_t), void *data) {
int err = LFS_LOCK(lfs->cfg); int err = LFS_LOCK(lfs->cfg);
if (err) { if (err) {
return err; return err;

View File

@@ -18,7 +18,7 @@ static rtos_qspi_flash_t qspi_flash_ctx_s;
#define SECTOR_SIZE 4096 #define SECTOR_SIZE 4096
rtos_qspi_flash_t *qspi_flash_ctx = &qspi_flash_ctx_s; rtos_qspi_flash_t *qspi_flash_ctx = &qspi_flash_ctx_s;
__attribute__((fptrgroup(" local_block_device_read_fptr_grp"))) __attribute__((fptrgroup("local_block_device_read_fptr_grp")))
int local_block_device_read(const struct lfs_config *c, lfs_block_t block, int local_block_device_read(const struct lfs_config *c, lfs_block_t block,
lfs_off_t off, void *buffer, lfs_size_t size) lfs_off_t off, void *buffer, lfs_size_t size)
{ {
@@ -27,7 +27,7 @@ int local_block_device_read(const struct lfs_config *c, lfs_block_t block,
return 0; return 0;
} }
__attribute__((fptrgroup(" local_block_device_prog_fptr_grp"))) __attribute__((fptrgroup("local_block_device_prog_fptr_grp")))
int local_block_device_prog(const struct lfs_config *c, lfs_block_t block, int local_block_device_prog(const struct lfs_config *c, lfs_block_t block,
lfs_off_t off, const void *buffer, lfs_size_t size) lfs_off_t off, const void *buffer, lfs_size_t size)
{ {
@@ -36,7 +36,7 @@ int local_block_device_prog(const struct lfs_config *c, lfs_block_t block,
return 0; return 0;
} }
__attribute__((fptrgroup(" local_block_device_erase_fptr_grp"))) __attribute__((fptrgroup("local_block_device_erase_fptr_grp")))
int local_block_device_erase(const struct lfs_config *c, lfs_block_t block) int local_block_device_erase(const struct lfs_config *c, lfs_block_t block)
{ {
unsigned address = (FS_BASE_ADDR + block * SECTOR_SIZE); unsigned address = (FS_BASE_ADDR + block * SECTOR_SIZE);
@@ -44,7 +44,7 @@ int local_block_device_erase(const struct lfs_config *c, lfs_block_t block)
return 0; return 0;
} }
__attribute__((fptrgroup(" local_block_device_sync_fptr_grp"))) __attribute__((fptrgroup("local_block_device_sync_fptr_grp")))
int local_block_device_sync(const struct lfs_config *c) int local_block_device_sync(const struct lfs_config *c)
{ {
return 0; return 0;