]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/mmap-cache.h
tree-wide: drop 'This file is part of systemd' blurb
[thirdparty/systemd.git] / src / journal / mmap-cache.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 Copyright 2012 Lennart Poettering
6 ***/
7
8 #include <stdbool.h>
9 #include <sys/stat.h>
10
11 /* One context per object type, plus one of the header, plus one "additional" one */
12 #define MMAP_CACHE_MAX_CONTEXTS 9
13
14 typedef struct MMapCache MMapCache;
15 typedef struct MMapFileDescriptor MMapFileDescriptor;
16
17 MMapCache* mmap_cache_new(void);
18 MMapCache* mmap_cache_ref(MMapCache *m);
19 MMapCache* mmap_cache_unref(MMapCache *m);
20
21 int mmap_cache_get(
22 MMapCache *m,
23 MMapFileDescriptor *f,
24 int prot,
25 unsigned context,
26 bool keep_always,
27 uint64_t offset,
28 size_t size,
29 struct stat *st,
30 void **ret,
31 size_t *ret_size);
32 MMapFileDescriptor * mmap_cache_add_fd(MMapCache *m, int fd);
33 void mmap_cache_free_fd(MMapCache *m, MMapFileDescriptor *f);
34
35 unsigned mmap_cache_get_hit(MMapCache *m);
36 unsigned mmap_cache_get_missed(MMapCache *m);
37
38 bool mmap_cache_got_sigbus(MMapCache *m, MMapFileDescriptor *f);