diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
commit | f7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch) | |
tree | a3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /src/lib/mmap-util.h | |
parent | Initial commit. (diff) | |
download | dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.tar.xz dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.zip |
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/lib/mmap-util.h')
-rw-r--r-- | src/lib/mmap-util.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/lib/mmap-util.h b/src/lib/mmap-util.h new file mode 100644 index 0000000..0f4184e --- /dev/null +++ b/src/lib/mmap-util.h @@ -0,0 +1,42 @@ +#ifndef MMAP_UTIL_H +#define MMAP_UTIL_H + +#include <unistd.h> + +#ifdef HAVE_LINUX_MREMAP +# define __USE_GNU /* for MREMAP_MAYMOVE */ +#endif + +#include <sys/mman.h> +#undef __USE_GNU + +#if !defined (MREMAP_MAYMOVE) && !defined (HAVE_LINUX_MREMAP) +# define MREMAP_MAYMOVE 1 +#endif + +#define madvise my_madvise +int my_madvise(void *start, size_t length, int advice); +#ifndef HAVE_MADVISE +# ifndef MADV_NORMAL +# define MADV_NORMAL 0 +# define MADV_RANDOM 0 +# define MADV_SEQUENTIAL 0 +# define MADV_WILLNEED 0 +# define MADV_DONTNEED 0 +# endif +#endif + +void *mmap_file(int fd, size_t *length, int prot); +void *mmap_ro_file(int fd, size_t *length); +void *mmap_rw_file(int fd, size_t *length); + +/* for allocating anonymous mmap()s, with portable mremap(). these must not + be mixed with any standard mmap calls. */ +void *mmap_anon(size_t length); +void *mremap_anon(void *old_address, size_t old_size, size_t new_size, + unsigned long flags); +int munmap_anon(void *start, size_t length); + +size_t mmap_get_page_size(void) ATTR_CONST; + +#endif |