1 /** $MirOS: src/sys/sys/mman.h,v 1.4 2014/07/13 12:54:15 tg Exp $ */ 2 /* $OpenBSD: mman.h,v 1.18 2003/07/21 22:52:19 tedu Exp $ */ 3 /* $NetBSD: mman.h,v 1.11 1995/03/26 20:24:23 jtc Exp $ */ 4 5 /*- 6 * Copyright (c) 1982, 1986, 1993 7 * The Regents of the University of California. All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)mman.h 8.1 (Berkeley) 6/2/93 34 */ 35 36 #ifndef _SYS_MMAN_H 37 #define _SYS_MMAN_H 38 39 /* 40 * I believe this is fundamentally wrong, but OpenBSD has relaxed 41 * the requirement to include <sys/types.h> before <sys/mman.h> so 42 * everyone else is going to follow. --mirabilos 43 * 44 * We can do nicer than this in MirMinze, but this suffices for now: 45 */ 46 #ifndef _SYS_TYPES_H_ 47 #include <sys/types.h> 48 #endif 49 50 /* 51 * Protections are chosen from these bits, or-ed together 52 */ 53 #define PROT_NONE 0x00 /* no permissions */ 54 #define PROT_READ 0x01 /* pages can be read */ 55 #define PROT_WRITE 0x02 /* pages can be written */ 56 #define PROT_EXEC 0x04 /* pages can be executed */ 57 58 /* 59 * Flags contain sharing type and options. 60 * Sharing types; choose one. 61 */ 62 #define MAP_SHARED 0x0001 /* share changes */ 63 #define MAP_PRIVATE 0x0002 /* changes are private */ 64 #define MAP_COPY 0x0004 /* "copy" region at mmap time */ 65 66 /* 67 * Other flags 68 */ 69 #define MAP_FIXED 0x0010 /* map addr must be exactly as requested */ 70 #define MAP_RENAME 0x0020 /* Sun: rename private pages to file */ 71 #define MAP_NORESERVE 0x0040 /* Sun: don't reserve needed swap area */ 72 #define MAP_INHERIT 0x0080 /* region is retained after exec */ 73 #define MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change file size */ 74 #define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */ 75 #define MAP_TRYFIXED 0x0400 /* attempt hint address, even within heap */ 76 77 #define __MAP_NOREPLACE 0x0800 /* fail if address not available */ 78 79 /* 80 * Error return from mmap() 81 */ 82 #define MAP_FAILED ((void *)-1) 83 84 /* 85 * Mapping type 86 */ 87 #define MAP_FILE 0x0000 /* map from file (default) */ 88 #define MAP_ANON 0x1000 /* allocated from memory, swap space */ 89 #define MAP_ANONYMOUS MAP_ANON /* alternate POSIX spelling */ 90 91 #define MAP_FLAGMASK 0x1ff7 92 93 /* 94 * Advice to madvise 95 */ 96 #define MADV_NORMAL 0 /* no further special treatment */ 97 #define MADV_RANDOM 1 /* expect random page references */ 98 #define MADV_SEQUENTIAL 2 /* expect sequential page references */ 99 #define MADV_WILLNEED 3 /* will need these pages */ 100 #define MADV_DONTNEED 4 /* dont need these pages */ 101 #define MADV_SPACEAVAIL 5 /* insure that resources are reserved */ 102 #define MADV_FREE 6 /* pages are empty, free them */ 103 104 /* 105 * Flags to minherit 106 */ 107 #define MAP_INHERIT_SHARE 0 /* share with child */ 108 #define MAP_INHERIT_COPY 1 /* copy into child */ 109 #define MAP_INHERIT_NONE 2 /* absent from child */ 110 #define MAP_INHERIT_ZERO 3 /* zero in child */ 111 112 /* 113 * Flags to msync 114 */ 115 #define MS_ASYNC 0x01 /* perform asynchronous writes */ 116 #define MS_SYNC 0x02 /* perform synchronous writes */ 117 #define MS_INVALIDATE 0x04 /* invalidate cached data */ 118 119 /* 120 * Flags to mlockall 121 */ 122 #define MCL_CURRENT 0x01 /* lock all pages currently mapped */ 123 #define MCL_FUTURE 0x02 /* lock all pages mapped in the future */ 124 125 #ifndef _KERNEL 126 127 #include <sys/cdefs.h> 128 129 __BEGIN_DECLS 130 void * mmap(void *, size_t, int, int, int, off_t); 131 int mprotect(void *, size_t, int); 132 int munmap(void *, size_t); 133 int msync(void *, size_t, int); 134 int mlock(const void *, size_t); 135 int munlock(const void *, size_t); 136 int mlockall(int); 137 int munlockall(void); 138 int madvise(void *, size_t, int); 139 int mincore(void *, size_t, char *); 140 int minherit(void *, size_t, int); 141 void * mquery(void *, size_t, int, int, int, off_t); 142 __END_DECLS 143 144 #endif /* !_KERNEL */ 145 146 #endif /* notdef _SYS_MMAN_H */ 147