1 /* 2 * Copyright 2008-2012 Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _SYS_MMAN_H 6 #define _SYS_MMAN_H 7 8 9 #include <sys/cdefs.h> 10 #include <sys/types.h> 11 12 13 /* memory protection for mmap() and others; assignment compatible with 14 B_{READ,WRITE,EXECUTE}_AREA */ 15 #define PROT_READ 0x01 16 #define PROT_WRITE 0x02 17 #define PROT_EXEC 0x04 18 #define PROT_NONE 0x00 19 20 /* mmap() flags */ 21 #define MAP_SHARED 0x01 /* changes are seen by others */ 22 #define MAP_PRIVATE 0x02 /* changes are only seen by caller */ 23 #define MAP_FIXED 0x04 /* require mapping to specified addr */ 24 #define MAP_ANONYMOUS 0x08 /* no underlying object */ 25 #define MAP_ANON MAP_ANONYMOUS 26 #define MAP_NORESERVE 0x10 /* don't commit memory */ 27 28 /* mmap() error return code */ 29 #define MAP_FAILED ((void*)-1) 30 31 /* msync() flags */ 32 #define MS_ASYNC 0x01 33 #define MS_SYNC 0x02 34 #define MS_INVALIDATE 0x04 35 36 /* posix_madvise() values */ 37 #define POSIX_MADV_NORMAL 1 38 #define POSIX_MADV_SEQUENTIAL 2 39 #define POSIX_MADV_RANDOM 3 40 #define POSIX_MADV_WILLNEED 4 41 #define POSIX_MADV_DONTNEED 5 42 43 44 __BEGIN_DECLS 45 46 void* mmap(void* address, size_t length, int protection, int flags, 47 int fd, off_t offset); 48 int munmap(void* address, size_t length); 49 50 int mprotect(void* address, size_t length, int protection); 51 int msync(void* address, size_t length, int flags); 52 53 int posix_madvise(void* address, size_t length, int advice); 54 55 int shm_open(const char* name, int openMode, mode_t permissions); 56 int shm_unlink(const char* name); 57 58 __END_DECLS 59 60 61 #endif /* _SYS_MMAN_H */ 62