2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2012-08-14 22:02:24 +02:00
|
|
|
#pragma once
|
|
|
|
|
2012-09-21 20:52:23 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <sys/stat.h>
|
2012-08-14 22:02:24 +02:00
|
|
|
|
2014-12-30 20:57:53 +01:00
|
|
|
/* One context per object type, plus one of the header, plus one "additional" one */
|
|
|
|
#define MMAP_CACHE_MAX_CONTEXTS 9
|
2014-12-03 18:25:44 +01:00
|
|
|
|
2012-08-14 22:02:24 +02:00
|
|
|
typedef struct MMapCache MMapCache;
|
2017-07-11 01:24:56 +02:00
|
|
|
typedef struct MMapFileDescriptor MMapFileDescriptor;
|
2012-08-14 22:02:24 +02:00
|
|
|
|
2012-08-18 01:46:20 +02:00
|
|
|
MMapCache* mmap_cache_new(void);
|
2012-08-14 22:02:24 +02:00
|
|
|
MMapCache* mmap_cache_ref(MMapCache *m);
|
|
|
|
MMapCache* mmap_cache_unref(MMapCache *m);
|
|
|
|
|
2013-12-29 01:33:23 +01:00
|
|
|
int mmap_cache_get(
|
|
|
|
MMapCache *m,
|
2017-07-11 01:24:56 +02:00
|
|
|
MMapFileDescriptor *f,
|
2013-12-29 01:33:23 +01:00
|
|
|
unsigned context,
|
|
|
|
bool keep_always,
|
|
|
|
uint64_t offset,
|
|
|
|
size_t size,
|
|
|
|
struct stat *st,
|
2017-07-13 07:08:58 +02:00
|
|
|
void **ret,
|
|
|
|
size_t *ret_size);
|
2020-12-03 07:11:23 +01:00
|
|
|
MMapFileDescriptor * mmap_cache_add_fd(MMapCache *m, int fd, int prot);
|
2017-07-11 01:24:56 +02:00
|
|
|
void mmap_cache_free_fd(MMapCache *m, MMapFileDescriptor *f);
|
2013-11-26 18:58:44 +01:00
|
|
|
|
2020-12-01 08:00:34 +01:00
|
|
|
void mmap_cache_stats_log_debug(MMapCache *m);
|
2014-12-30 20:57:53 +01:00
|
|
|
|
2017-07-11 01:24:56 +02:00
|
|
|
bool mmap_cache_got_sigbus(MMapCache *m, MMapFileDescriptor *f);
|