mman.h revision 34319
178189Sbrian/*- 278189Sbrian * Copyright (c) 1982, 1986, 1993 378189Sbrian * The Regents of the University of California. All rights reserved. 478189Sbrian * 578189Sbrian * Redistribution and use in source and binary forms, with or without 66059Samurai * modification, are permitted provided that the following conditions 778189Sbrian * are met: 878189Sbrian * 1. Redistributions of source code must retain the above copyright 978189Sbrian * notice, this list of conditions and the following disclaimer. 1078189Sbrian * 2. Redistributions in binary form must reproduce the above copyright 1178189Sbrian * notice, this list of conditions and the following disclaimer in the 1278189Sbrian * documentation and/or other materials provided with the distribution. 1378189Sbrian * 3. All advertising materials mentioning features or use of this software 1478189Sbrian * must display the following acknowledgement: 156059Samurai * This product includes software developed by the University of 1678189Sbrian * California, Berkeley and its contributors. 1778189Sbrian * 4. Neither the name of the University nor the names of its contributors 1878189Sbrian * may be used to endorse or promote products derived from this software 1978189Sbrian * without specific prior written permission. 2078189Sbrian * 2178189Sbrian * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2278189Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2378189Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2478189Sbrian * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2578189Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2678189Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 276059Samurai * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2850479Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 296059Samurai * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 306059Samurai * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 316059Samurai * SUCH DAMAGE. 326059Samurai * 336059Samurai * @(#)mman.h 8.2 (Berkeley) 1/9/95 346059Samurai * $Id: mman.h,v 1.21 1998/03/04 10:26:35 dufault Exp $ 356059Samurai */ 366059Samurai 376059Samurai#ifndef _SYS_MMAN_H_ 386059Samurai#define _SYS_MMAN_H_ 396059Samurai 4067910Sbrian#include <sys/_posix.h> 416059Samurai 426059Samurai/* 436059Samurai * Protections are chosen from these bits, or-ed together 4431518Sbrian */ 4531518Sbrian#define PROT_NONE 0x00 /* no permissions */ 466059Samurai#define PROT_READ 0x01 /* pages can be read */ 4736285Sbrian#define PROT_WRITE 0x02 /* pages can be written */ 4836285Sbrian#define PROT_EXEC 0x04 /* pages can be executed */ 4936285Sbrian 5067910Sbrian/* 5167910Sbrian * Flags contain sharing type and options. 5267910Sbrian * Sharing types; choose one. 5367910Sbrian */ 5436285Sbrian#define MAP_SHARED 0x0001 /* share changes */ 5567910Sbrian#define MAP_PRIVATE 0x0002 /* changes are private */ 5636285Sbrian#define MAP_COPY MAP_PRIVATE /* Obsolete */ 5736285Sbrian 5836285Sbrian/* 5936285Sbrian * Other flags 6036285Sbrian */ 6136285Sbrian#define MAP_FIXED 0x0010 /* map addr must be exactly as requested */ 6236285Sbrian#define MAP_RENAME 0x0020 /* Sun: rename private pages to file */ 6336285Sbrian#define MAP_NORESERVE 0x0040 /* Sun: don't reserve needed swap area */ 6436285Sbrian#define MAP_INHERIT 0x0080 /* region is retained after exec */ 6536285Sbrian#define MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change file size */ 6667910Sbrian#define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */ 6767910Sbrian 6867910Sbrian#ifdef _POSIX4_VISIBLE 6967910Sbrian/* 7067910Sbrian * Process memory locking 7144305Sbrian */ 7236285Sbrian#define MCL_CURRENT 0x0001 /* Lock only current memory */ 7336285Sbrian#define MCL_FUTURE 0x0002 /* Lock all future memory as well */ 7436285Sbrian 7536285Sbrian#endif /* _POSIX4_VISIBLE */ 7636285Sbrian 7736285Sbrian/* 7836285Sbrian * Error return from mmap() 7936285Sbrian */ 8036285Sbrian#define MAP_FAILED ((void *)-1) 8136285Sbrian 8236285Sbrian/* 8336285Sbrian * msync() flags 8432439Sbrian */ 8532439Sbrian#define MS_SYNC 0x0000 /* msync synchronously */ 866059Samurai#define MS_ASYNC 0x0001 /* return immediately */ 8732381Sbrian#define MS_INVALIDATE 0x0002 /* invalidate all cached data */ 8832381Sbrian 8932381Sbrian 9036285Sbrian/* 9136285Sbrian * Mapping type 9236285Sbrian */ 9368423Sbrian#define MAP_FILE 0x0000 /* map from file (default) */ 9436285Sbrian#define MAP_ANON 0x1000 /* allocated from memory, swap space */ 9536285Sbrian 9636285Sbrian/* 9736285Sbrian * Advice to madvise 9836285Sbrian */ 9968423Sbrian#define MADV_NORMAL 0 /* no further special treatment */ 10036285Sbrian#define MADV_RANDOM 1 /* expect random page references */ 10136285Sbrian#define MADV_SEQUENTIAL 2 /* expect sequential page references */ 10232439Sbrian#define MADV_WILLNEED 3 /* will need these pages */ 10332439Sbrian#define MADV_DONTNEED 4 /* dont need these pages */ 1046059Samurai#define MADV_FREE 5 /* dont need these pages, and junk contents */ 10537210Sbrian 10637210Sbrian/* 10736285Sbrian * Return bits from mincore 10836285Sbrian */ 1096059Samurai#define MINCORE_INCORE 0x1 /* Page is incore */ 1106059Samurai#define MINCORE_REFERENCED 0x2 /* Page has been referenced by us */ 11136285Sbrian#define MINCORE_MODIFIED 0x4 /* Page has been modified by us */ 11231514Sbrian#define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */ 11331514Sbrian#define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */ 11431514Sbrian 11537010Sbrian#ifndef KERNEL 11637010Sbrian 11772025Sbrian#include <sys/cdefs.h> 11831514Sbrian 11936285Sbrian__BEGIN_DECLS 12036285Sbrian#ifdef _POSIX4_VISIBLE 12136285Sbrianint mlockall __P((int)); 12236285Sbrianint munlockall __P((void)); 12336285Sbrianint shm_open __P((const char *, int, mode_t)); 12436285Sbrianint shm_unlink __P((const char *)); 12531514Sbrian#endif /* _POSIX4_VISIBLE */ 12631514Sbrianint mlock __P((const void *, size_t)); 12736285Sbrian#ifndef _MMAP_DECLARED 12831514Sbrian#define _MMAP_DECLARED 12936285Sbrianvoid * mmap __P((void *, size_t, int, int, int, off_t)); 13036285Sbrian#endif 13136285Sbrianint mprotect __P((const void *, size_t, int)); 13246686Sbrianint msync __P((void *, size_t, int)); 13346686Sbrianint munlock __P((const void *, size_t)); 13431514Sbrianint munmap __P((void *, size_t)); 13531514Sbrian#ifndef _POSIX_SOURCE 13631514Sbrianint madvise __P((void *, size_t, int)); 13736285Sbrianint mincore __P((const void *, size_t, char *)); 13836285Sbrianint minherit __P((void *, size_t, int)); 13936285Sbrian#endif 1406059Samurai__END_DECLS 14136285Sbrian 14246686Sbrian#endif /* !KERNEL */ 14336285Sbrian 14436285Sbrian#endif 14536285Sbrian