xref: /haiku/headers/posix/sys/mman.h (revision a959262cd0318f46265a279f3e5057329616cec8)
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 /* madvise() values */
37 #define MADV_NORMAL			1
38 #define MADV_SEQUENTIAL		2
39 #define MADV_RANDOM			3
40 #define MADV_WILLNEED		4
41 #define MADV_DONTNEED		5
42 #define MADV_FREE			6
43 
44 /* posix_madvise() values */
45 #define POSIX_MADV_NORMAL		MADV_NORMAL
46 #define POSIX_MADV_SEQUENTIAL	MADV_SEQUENTIAL
47 #define POSIX_MADV_RANDOM		MADV_RANDOM
48 #define POSIX_MADV_WILLNEED		MADV_WILLNEED
49 #define POSIX_MADV_DONTNEED		MADV_DONTNEED
50 
51 
52 __BEGIN_DECLS
53 
54 void*	mmap(void* address, size_t length, int protection, int flags,
55 			int fd, off_t offset);
56 int		munmap(void* address, size_t length);
57 
58 int		mprotect(void* address, size_t length, int protection);
59 int		msync(void* address, size_t length, int flags);
60 
61 int		madvise(void* address, size_t length, int advice);
62 int		posix_madvise(void* address, size_t length, int advice);
63 
64 int		mlock(const void* address, size_t length);
65 int		munlock(const void* address, size_t length);
66 
67 int		shm_open(const char* name, int openMode, mode_t permissions);
68 int		shm_unlink(const char* name);
69 
70 __END_DECLS
71 
72 
73 #endif	/* _SYS_MMAN_H */
74