1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include "sd-bus.h"
5 
6 #define MEMFD_CACHE_MAX 32
7 
8 /* When we cache a memfd block for reuse, we will truncate blocks
9  * longer than this in order not to keep too much data around. */
10 #define MEMFD_CACHE_ITEM_SIZE_MAX (128*1024)
11 
12 /* This determines at which minimum size we prefer sending memfds over
13  * sending vectors */
14 #define MEMFD_MIN_SIZE (512*1024)
15 
16 struct memfd_cache {
17         int fd;
18         void *address;
19         size_t mapped;
20         size_t allocated;
21 };
22 
23 void close_and_munmap(int fd, void *address, size_t size);
24 void bus_flush_memfd(sd_bus *bus);
25