mman.h revision 103304
1114402Sru/*-
2151497Sru * Copyright (c) 1982, 1986, 1993
3114402Sru *	The Regents of the University of California.  All rights reserved.
4114402Sru *
5114402Sru * Redistribution and use in source and binary forms, with or without
6114402Sru * modification, are permitted provided that the following conditions
7114402Sru * are met:
8114402Sru * 1. Redistributions of source code must retain the above copyright
9114402Sru *    notice, this list of conditions and the following disclaimer.
10114402Sru * 2. Redistributions in binary form must reproduce the above copyright
11114402Sru *    notice, this list of conditions and the following disclaimer in the
12114402Sru *    documentation and/or other materials provided with the distribution.
13114402Sru * 3. All advertising materials mentioning features or use of this software
14114402Sru *    must display the following acknowledgement:
15114402Sru *	This product includes software developed by the University of
16114402Sru *	California, Berkeley and its contributors.
17114402Sru * 4. Neither the name of the University nor the names of its contributors
18114402Sru *    may be used to endorse or promote products derived from this software
19114402Sru *    without specific prior written permission.
20151497Sru *
21114402Sru * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22114402Sru * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23114402Sru * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24114402Sru * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25114402Sru * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26114402Sru * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27114402Sru * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28151497Sru * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29151497Sru * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30114402Sru * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31114402Sru * SUCH DAMAGE.
32114402Sru *
33114402Sru *	@(#)mman.h	8.2 (Berkeley) 1/9/95
34114402Sru * $FreeBSD: head/sys/sys/mman.h 103304 2002-09-13 18:29:15Z mike $
35114402Sru */
36114402Sru
37151497Sru#ifndef _SYS_MMAN_H_
38151497Sru#define _SYS_MMAN_H_
39114402Sru
40114402Sru#include <sys/cdefs.h>
41114402Sru#include <sys/_types.h>
42114402Sru
43114402Sru#if __BSD_VISIBLE
44114402Sru/*
45114402Sru * Inheritance for minherit()
46114402Sru */
47114402Sru#define INHERIT_SHARE	0
48114402Sru#define INHERIT_COPY	1
49114402Sru#define INHERIT_NONE	2
50114402Sru#endif
51114402Sru
52114402Sru/*
53114402Sru * Protections are chosen from these bits, or-ed together
54114402Sru */
55114402Sru#define	PROT_NONE	0x00	/* no permissions */
56151497Sru#define	PROT_READ	0x01	/* pages can be read */
57151497Sru#define	PROT_WRITE	0x02	/* pages can be written */
58151497Sru#define	PROT_EXEC	0x04	/* pages can be executed */
59114402Sru
60114402Sru/*
61114402Sru * Flags contain sharing type and options.
62114402Sru * Sharing types; choose one.
63114402Sru */
64114402Sru#define	MAP_SHARED	0x0001		/* share changes */
65114402Sru#define	MAP_PRIVATE	0x0002		/* changes are private */
66114402Sru#define	MAP_COPY	MAP_PRIVATE	/* Obsolete */
67114402Sru
68114402Sru#if __BSD_VISIBLE
69114402Sru/*
70114402Sru * Other flags
71114402Sru */
72114402Sru#define	MAP_FIXED	 0x0010	/* map addr must be exactly as requested */
73114402Sru#define	MAP_RENAME	 0x0020	/* Sun: rename private pages to file */
74114402Sru#define	MAP_NORESERVE	 0x0040	/* Sun: don't reserve needed swap area */
75114402Sru#define	MAP_RESERVED0080 0x0080	/* previously misimplemented MAP_INHERIT */
76114402Sru#define	MAP_RESERVED0100 0x0100	/* previously unimplemented MAP_NOEXTEND */
77114402Sru#define	MAP_HASSEMAPHORE 0x0200	/* region may contain semaphores */
78114402Sru#define	MAP_STACK	 0x0400	/* region grows down, like a stack */
79114402Sru#define	MAP_NOSYNC	 0x0800 /* page to but do not sync underlying file */
80114402Sru
81114402Sru/*
82114402Sru * Mapping type
83114402Sru */
84114402Sru#define	MAP_FILE	 0x0000	/* map from file (default) */
85114402Sru#define	MAP_ANON	 0x1000	/* allocated from memory, swap space */
86114402Sru
87114402Sru/*
88114402Sru * Extended flags
89114402Sru */
90114402Sru#define	MAP_NOCORE	 0x00020000 /* dont include these pages in a coredump */
91114402Sru#endif /* __BSD_VISIBLE */
92114402Sru
93114402Sru#if __POSIX_VISIBLE >= 199309
94114402Sru/*
95114402Sru * Process memory locking
96114402Sru */
97114402Sru#define MCL_CURRENT	0x0001	/* Lock only current memory */
98114402Sru#define MCL_FUTURE	0x0002	/* Lock all future memory as well */
99114402Sru#endif
100114402Sru
101114402Sru/*
102114402Sru * Error return from mmap()
103114402Sru */
104151497Sru#define MAP_FAILED	((void *)-1)
105151497Sru
106151497Sru/*
107151497Sru * msync() flags
108114402Sru */
109114402Sru#define	MS_SYNC		0x0000	/* msync synchronously */
110114402Sru#define MS_ASYNC	0x0001	/* return immediately */
111114402Sru#define MS_INVALIDATE	0x0002	/* invalidate all cached data */
112114402Sru
113114402Sru#if __BSD_VISIBLE
114114402Sru/*
115114402Sru * Advice to madvise
116114402Sru */
117114402Sru#define	MADV_NORMAL	0	/* no further special treatment */
118114402Sru#define	MADV_RANDOM	1	/* expect random page references */
119114402Sru#define	MADV_SEQUENTIAL	2	/* expect sequential page references */
120114402Sru#define	MADV_WILLNEED	3	/* will need these pages */
121114402Sru#define	MADV_DONTNEED	4	/* dont need these pages */
122114402Sru#define	MADV_FREE	5	/* dont need these pages, and junk contents */
123114402Sru#define	MADV_NOSYNC	6	/* try to avoid flushes to physical media */
124114402Sru#define	MADV_AUTOSYNC	7	/* revert to default flushing strategy */
125114402Sru#define	MADV_NOCORE	8	/* do not include these pages in a core file */
126114402Sru#define	MADV_CORE	9	/* revert to including pages in a core file */
127151497Sru
128151497Sru/*
129151497Sru * Return bits from mincore
130151497Sru */
131151497Sru#define	MINCORE_INCORE	 	 0x1 /* Page is incore */
132151497Sru#define	MINCORE_REFERENCED	 0x2 /* Page has been referenced by us */
133151497Sru#define	MINCORE_MODIFIED	 0x4 /* Page has been modified by us */
134114402Sru#define	MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */
135114402Sru#define	MINCORE_MODIFIED_OTHER	0x10 /* Page has been modified */
136114402Sru#endif /* __BSD_VISIBLE */
137114402Sru
138114402Sru/*
139114402Sru * XXX missing POSIX_MADV_* macros, POSIX_TYPED_MEM_* macros, and
140114402Sru * posix_typed_mem_info structure.
141114402Sru */
142114402Sru
143114402Sru#ifndef _MODE_T_DECLARED
144114402Srutypedef	__mode_t	mode_t;
145114402Sru#define	_MODE_T_DECLARED
146114402Sru#endif
147114402Sru
148114402Sru#ifndef _OFF_T_DECLARED
149114402Srutypedef	__off_t		off_t;
150114402Sru#define	_OFF_T_DECLARED
151114402Sru#endif
152114402Sru
153114402Sru#ifndef _SIZE_T_DECLARED
154114402Srutypedef	__size_t	size_t;
155114402Sru#define	_SIZE_T_DECLARED
156114402Sru#endif
157114402Sru
158114402Sru#ifndef _KERNEL
159114402Sru
160114402Sru__BEGIN_DECLS
161114402Sru/*
162114402Sru * XXX not yet implemented: mlockall(), munlockall(), posix_madvise(),
163114402Sru * posix_mem_offset(), posix_typed_mem_get_info(), posix_typed_mem_open().
164114402Sru */
165114402Sru#if __BSD_VISIBLE
166114402Sruint	madvise(void *, size_t, int);
167114402Sruint	mincore(const void *, size_t, char *);
168114402Sruint	minherit(void *, size_t, int);
169114402Sru#endif
170114402Sruint	mlock(const void *, size_t);
171114402Sru#ifndef _MMAP_DECLARED
172114402Sru#define	_MMAP_DECLARED
173114402Sruvoid *	mmap(void *, size_t, int, int, int, off_t);
174114402Sru#endif
175114402Sruint	mprotect(const void *, size_t, int);
176114402Sruint	msync(void *, size_t, int);
177114402Sruint	munlock(const void *, size_t);
178114402Sruint	munmap(void *, size_t);
179114402Sru#if __POSIX_VISIBLE >= 199309
180114402Sruint	shm_open(const char *, int, mode_t);
181114402Sruint	shm_unlink(const char *);
182114402Sru#endif
183114402Sru__END_DECLS
184114402Sru
185114402Sru#endif /* !_KERNEL */
186114402Sru
187114402Sru#endif /* !_SYS_MMAN_H_ */
188114402Sru