diff options
| author | Patrick Steinhardt <ps@pks.im> | 2026-04-02 09:31:18 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-04-02 10:45:44 -0700 |
| commit | 87e4eee3f94ec261a92a76d06261b227b00de461 (patch) | |
| tree | 4e2baee0836ac16f4813ba107630a785683b3d55 /reftable/system.h | |
| parent | cb0882de1979522b2fc3dc4c3064b0ad21d50b06 (diff) | |
| download | git-87e4eee3f94ec261a92a76d06261b227b00de461.tar.xz | |
reftable/system: add abstraction to mmap files
In our codebase we have a couple of wrappers around mmap(3p) that allow
us to reimplement the syscall on platforms that don't have it natively,
like for example Windows. Other projects that embed the reftable library
may have a different infra though to hook up mmap wrappers, but these
are currently hard to integrate.
Provide the infrastructure to let projects easily define the mmap
interface with a custom struct and custom functions.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/system.h')
| -rw-r--r-- | reftable/system.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/reftable/system.h b/reftable/system.h index 071bfa3d58..c0e2cbe0ff 100644 --- a/reftable/system.h +++ b/reftable/system.h @@ -114,4 +114,22 @@ int flock_commit(struct reftable_flock *l); /* Report the time in milliseconds. */ uint64_t reftable_time_ms(void); +struct reftable_mmap { + void *data; + size_t size; + void *priv; +}; + +/* + * Map the file into memory. Returns 0 on success, a reftable error code on + * error. + */ +int reftable_mmap(struct reftable_mmap *out, int fd, size_t len); + +/* + * Unmap the file from memory. Returns 0 on success, a reftable error code on + * error. + */ +int reftable_munmap(struct reftable_mmap *mmap); + #endif |
