mmap-util.h revision 139ad5fc705d9c09380f7130e557f691311b0e25
9b2bd54c98edb185a3985410367754ab33217362bnicholes#ifndef __MMAP_UTIL_H
9b2bd54c98edb185a3985410367754ab33217362bnicholes#define __MMAP_UTIL_H
9b2bd54c98edb185a3985410367754ab33217362bnicholes
9b2bd54c98edb185a3985410367754ab33217362bnicholes#include <unistd.h>
9b2bd54c98edb185a3985410367754ab33217362bnicholes
9b2bd54c98edb185a3985410367754ab33217362bnicholes#ifdef HAVE_LINUX_MREMAP
9b2bd54c98edb185a3985410367754ab33217362bnicholes# define __USE_GNU /* for MREMAP_MAYMOVE */
9b2bd54c98edb185a3985410367754ab33217362bnicholes#endif
9b2bd54c98edb185a3985410367754ab33217362bnicholes
9b2bd54c98edb185a3985410367754ab33217362bnicholes#include <sys/mman.h>
0662ed52e814f8f08ef0e09956413a792584eddffuankg#undef __USE_GNU
9b2bd54c98edb185a3985410367754ab33217362bnicholes
9b2bd54c98edb185a3985410367754ab33217362bnicholes#if !defined (MREMAP_MAYMOVE) && !defined (HAVE_LINUX_MREMAP)
9b2bd54c98edb185a3985410367754ab33217362bnicholes# define MREMAP_MAYMOVE 1
9b2bd54c98edb185a3985410367754ab33217362bnicholes#endif
9b2bd54c98edb185a3985410367754ab33217362bnicholes
9b2bd54c98edb185a3985410367754ab33217362bnicholes#ifndef HAVE_MADVISE
9b2bd54c98edb185a3985410367754ab33217362bnicholesint madvise(void *start, size_t length, int advice);
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes# ifndef MADV_NORMAL
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes# define MADV_NORMAL 0
16b55a35cff91315d261d1baa776138af465c4e4fuankg# define MADV_RANDOM 0
16b55a35cff91315d261d1baa776138af465c4e4fuankg# define MADV_SEQUENTIAL 0
16b55a35cff91315d261d1baa776138af465c4e4fuankg# define MADV_WILLNEED 0
9b2bd54c98edb185a3985410367754ab33217362bnicholes# define MADV_DONTNEED 0
9b2bd54c98edb185a3985410367754ab33217362bnicholes# endif
9b2bd54c98edb185a3985410367754ab33217362bnicholes#endif
9b2bd54c98edb185a3985410367754ab33217362bnicholes
9b2bd54c98edb185a3985410367754ab33217362bnicholesvoid *mmap_file(int fd, size_t *length, int prot);
9b2bd54c98edb185a3985410367754ab33217362bnicholesvoid *mmap_ro_file(int fd, size_t *length);
9b2bd54c98edb185a3985410367754ab33217362bnicholesvoid *mmap_rw_file(int fd, size_t *length);
9b2bd54c98edb185a3985410367754ab33217362bnicholes
9b2bd54c98edb185a3985410367754ab33217362bnicholes/* for allocating anonymous mmap()s, with portable mremap(). these must not
9b2bd54c98edb185a3985410367754ab33217362bnicholes be mixed with any standard mmap calls. */
9b2bd54c98edb185a3985410367754ab33217362bnicholesvoid *mmap_anon(size_t length);
9b2bd54c98edb185a3985410367754ab33217362bnicholesvoid *mremap_anon(void *old_address, size_t old_size, size_t new_size,
9b2bd54c98edb185a3985410367754ab33217362bnicholes unsigned long flags);
9b2bd54c98edb185a3985410367754ab33217362bnicholesint munmap_anon(void *start, size_t length);
9b2bd54c98edb185a3985410367754ab33217362bnicholes
9b2bd54c98edb185a3985410367754ab33217362bnicholes#endif
9b2bd54c98edb185a3985410367754ab33217362bnicholes