mman.h revision 54467
11541Srgrimes/*-
21541Srgrimes * Copyright (c) 1982, 1986, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes * 3. All advertising materials mentioning features or use of this software
141541Srgrimes *    must display the following acknowledgement:
151541Srgrimes *	This product includes software developed by the University of
161541Srgrimes *	California, Berkeley and its contributors.
171541Srgrimes * 4. Neither the name of the University nor the names of its contributors
181541Srgrimes *    may be used to endorse or promote products derived from this software
191541Srgrimes *    without specific prior written permission.
201541Srgrimes *
211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311541Srgrimes * SUCH DAMAGE.
321541Srgrimes *
3314482Shsu *	@(#)mman.h	8.2 (Berkeley) 1/9/95
3450477Speter * $FreeBSD: head/sys/sys/mman.h 54467 1999-12-12 03:19:33Z dillon $
351541Srgrimes */
361541Srgrimes
372165Spaul#ifndef _SYS_MMAN_H_
382165Spaul#define _SYS_MMAN_H_
392165Spaul
4034319Sdufault#include <sys/_posix.h>
4134319Sdufault
421541Srgrimes/*
431541Srgrimes * Protections are chosen from these bits, or-ed together
441541Srgrimes */
4514482Shsu#define	PROT_NONE	0x00	/* no permissions */
461541Srgrimes#define	PROT_READ	0x01	/* pages can be read */
471541Srgrimes#define	PROT_WRITE	0x02	/* pages can be written */
481541Srgrimes#define	PROT_EXEC	0x04	/* pages can be executed */
491541Srgrimes
501541Srgrimes/*
511541Srgrimes * Flags contain sharing type and options.
521541Srgrimes * Sharing types; choose one.
531541Srgrimes */
549507Sdg#define	MAP_SHARED	0x0001		/* share changes */
559507Sdg#define	MAP_PRIVATE	0x0002		/* changes are private */
569507Sdg#define	MAP_COPY	MAP_PRIVATE	/* Obsolete */
571541Srgrimes
581541Srgrimes/*
591541Srgrimes * Other flags
601541Srgrimes */
611541Srgrimes#define	MAP_FIXED	 0x0010	/* map addr must be exactly as requested */
621541Srgrimes#define	MAP_RENAME	 0x0020	/* Sun: rename private pages to file */
631541Srgrimes#define	MAP_NORESERVE	 0x0040	/* Sun: don't reserve needed swap area */
641541Srgrimes#define	MAP_INHERIT	 0x0080	/* region is retained after exec */
651541Srgrimes#define	MAP_NOEXTEND	 0x0100	/* for MAP_FILE, don't change file size */
661541Srgrimes#define	MAP_HASSEMAPHORE 0x0200	/* region may contain semaphores */
6742360Sjulian#define	MAP_STACK	 0x0400	/* region grows down, like a stack */
6854467Sdillon#define MAP_NOSYNC	 0x0800 /* page to but do not sync underlying file */
691541Srgrimes
7034925Sdufault#ifdef _P1003_1B_VISIBLE
711541Srgrimes/*
7234030Sdufault * Process memory locking
7334030Sdufault */
7434030Sdufault#define MCL_CURRENT	0x0001	/* Lock only current memory */
7534030Sdufault#define MCL_FUTURE	0x0002	/* Lock all future memory as well */
7634030Sdufault
7734925Sdufault#endif /* _P1003_1B_VISIBLE */
7834030Sdufault
7934030Sdufault/*
8020346Salex * Error return from mmap()
8120346Salex */
8232131Salex#define MAP_FAILED	((void *)-1)
8320346Salex
8420346Salex/*
857358Sdg * msync() flags
867358Sdg */
8731497Sdyson#define	MS_SYNC		0x0000	/* msync synchronously */
887358Sdg#define MS_ASYNC	0x0001	/* return immediately */
897358Sdg#define MS_INVALIDATE	0x0002	/* invalidate all cached data */
907358Sdg
9134030Sdufault
927358Sdg/*
9314482Shsu * Mapping type
941541Srgrimes */
9514482Shsu#define	MAP_FILE	0x0000	/* map from file (default) */
961541Srgrimes#define	MAP_ANON	0x1000	/* allocated from memory, swap space */
971541Srgrimes
981541Srgrimes/*
991541Srgrimes * Advice to madvise
1001541Srgrimes */
1011541Srgrimes#define	MADV_NORMAL	0	/* no further special treatment */
1021541Srgrimes#define	MADV_RANDOM	1	/* expect random page references */
1031541Srgrimes#define	MADV_SEQUENTIAL	2	/* expect sequential page references */
1041541Srgrimes#define	MADV_WILLNEED	3	/* will need these pages */
1051541Srgrimes#define	MADV_DONTNEED	4	/* dont need these pages */
10615873Sdyson#define	MADV_FREE	5	/* dont need these pages, and junk contents */
10754467Sdillon#define	MADV_NOSYNC	6	/* try to avoid flushes to physical media */
10854467Sdillon#define	MADV_AUTOSYNC	7	/* revert to default flushing strategy */
1091541Srgrimes
11015819Sdyson/*
11115819Sdyson * Return bits from mincore
11215819Sdyson */
11315819Sdyson#define	MINCORE_INCORE	 	 0x1 /* Page is incore */
11415819Sdyson#define	MINCORE_REFERENCED	 0x2 /* Page has been referenced by us */
11515819Sdyson#define	MINCORE_MODIFIED	 0x4 /* Page has been modified by us */
11615819Sdyson#define	MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */
11715819Sdyson#define	MINCORE_MODIFIED_OTHER	0x10 /* Page has been modified */
11815819Sdyson
1191541Srgrimes#ifndef KERNEL
1201541Srgrimes
1211541Srgrimes#include <sys/cdefs.h>
1221541Srgrimes
1231541Srgrimes__BEGIN_DECLS
12434925Sdufault#ifdef _P1003_1B_VISIBLE
12534030Sdufaultint	mlockall __P((int));
12634030Sdufaultint	munlockall __P((void));
12734030Sdufaultint	shm_open __P((const char *, int, mode_t));
12834030Sdufaultint	shm_unlink __P((const char *));
12934925Sdufault#endif /* _P1003_1B_VISIBLE */
13032131Salexint	mlock __P((const void *, size_t));
13124896Sbde#ifndef _MMAP_DECLARED
13224896Sbde#define	_MMAP_DECLARED
13332131Salexvoid *	mmap __P((void *, size_t, int, int, int, off_t));
13424896Sbde#endif
13532131Salexint	mprotect __P((const void *, size_t, int));
13632131Salexint	msync __P((void *, size_t, int));
13732131Salexint	munlock __P((const void *, size_t));
13832131Salexint	munmap __P((void *, size_t));
13934030Sdufault#ifndef _POSIX_SOURCE
14034030Sdufaultint	madvise __P((void *, size_t, int));
14134030Sdufaultint	mincore __P((const void *, size_t, char *));
14234030Sdufaultint	minherit __P((void *, size_t, int));
14334030Sdufault#endif
1441541Srgrimes__END_DECLS
1451541Srgrimes
1461541Srgrimes#endif /* !KERNEL */
1472165Spaul
1482165Spaul#endif
149