31#ifndef PROTOCORE_WAL_STORE_H
32#define PROTOCORE_WAL_STORE_H
36#if PROTOCORE_ENABLE_WAL
42#define WAL_SUPER_MAGIC 0x31425357u
45#define WAL_SUPER_SIZE 64
48#define WAL_DATA_OFFSET (2u * (uint32_t)WAL_SUPER_SIZE)
60 size_t (*read)(
void *ctx, uint64_t off, uint8_t *buf,
size_t len);
61 size_t (*write)(
void *ctx, uint64_t off,
const uint8_t *buf,
size_t len);
84proto_bool protocore_wal_store_format(WalStore *s,
const WalDev *dev);
91proto_bool protocore_wal_store_mount(WalStore *s,
const WalDev *dev);
98proto_bool protocore_wal_store_append(WalStore *s,
const uint8_t *payload, uint32_t len);
104proto_bool protocore_wal_store_checkpoint(WalStore *s);
108typedef void (*WalStoreRecordCb)(uint64_t seq, uint64_t data_off,
const uint8_t *payload, uint32_t len,
void *ctx);
117size_t protocore_wal_store_scan(WalStore *s, WalStoreRecordCb cb,
void *ctx, uint8_t *scratch,
size_t scratch_len);
123proto_bool protocore_wal_store_pread(WalStore *s, uint64_t off, uint8_t *buf,
size_t len);
126static inline uint64_t protocore_wal_store_used(
const WalStore *s)
131static inline uint64_t protocore_wal_store_committed(
const WalStore *s)
136static inline uint64_t protocore_wal_store_capacity(
const WalStore *s)
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS
Write-ahead journal for atomic buffer-to-flash storage (PROTOCORE_ENABLE_WAL).