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 27 /* mmap() error return code */ 28 #define MAP_FAILED ((void*)-1) 29 30 /* msync() flags */ 31 #define MS_ASYNC 0x01 32 #define MS_SYNC 0x02 33 #define MS_INVALIDATE 0x04 34 35 /* posix_madvise() values */ 36 #define POSIX_MADV_NORMAL 1 37 #define POSIX_MADV_SEQUENTIAL 2 38 #define POSIX_MADV_RANDOM 3 39 #define POSIX_MADV_WILLNEED 4 40 #define POSIX_MADV_DONTNEED 5 41 42 43 __BEGIN_DECLS 44 45 void* mmap(void* address, size_t length, int protection, int flags, 46 int fd, off_t offset); 47 int munmap(void* address, size_t length); 48 49 int mprotect(void* address, size_t length, int protection); 50 int msync(void* address, size_t length, int flags); 51 52 int posix_madvise(void* address, size_t length, int advice); 53 54 int shm_open(const char* name, int openMode, mode_t permissions); 55 int shm_unlink(const char* name); 56 57 __END_DECLS 58 59 60 #endif /* _SYS_MMAN_H */ 61