xref: /illumos-gate/usr/src/uts/common/sys/mman.h (revision 1b3b16f3)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5bfe60e20Sdamico  * Common Development and Distribution License (the "License").
6bfe60e20Sdamico  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21019c3c43Sraf 
22*1b3b16f3STheo Schlossnagle /* Copyright 2013 OmniTI Computer Consulting, Inc. All rights reserved. */
237c478bd9Sstevel@tonic-gate /*
24019c3c43Sraf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
297c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
337c478bd9Sstevel@tonic-gate  * The Regents of the University of California
347c478bd9Sstevel@tonic-gate  * All Rights Reserved
357c478bd9Sstevel@tonic-gate  *
367c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
377c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
387c478bd9Sstevel@tonic-gate  * contributors.
397c478bd9Sstevel@tonic-gate  */
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #ifndef	_SYS_MMAN_H
427c478bd9Sstevel@tonic-gate #define	_SYS_MMAN_H
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
477c478bd9Sstevel@tonic-gate extern "C" {
487c478bd9Sstevel@tonic-gate #endif
497c478bd9Sstevel@tonic-gate 
5031c6c9d8SMichael Corcoran #if	!defined(_ASM) && !defined(_KERNEL)
5131c6c9d8SMichael Corcoran #include <sys/types.h>
5231c6c9d8SMichael Corcoran #endif	/* !_ASM && !_KERNEL */
5331c6c9d8SMichael Corcoran 
547c478bd9Sstevel@tonic-gate /*
557c478bd9Sstevel@tonic-gate  * Protections are chosen from these bits, or-ed together.
567c478bd9Sstevel@tonic-gate  * Note - not all implementations literally provide all possible
577c478bd9Sstevel@tonic-gate  * combinations.  PROT_WRITE is often implemented as (PROT_READ |
587c478bd9Sstevel@tonic-gate  * PROT_WRITE) and (PROT_EXECUTE as PROT_READ | PROT_EXECUTE).
597c478bd9Sstevel@tonic-gate  * However, no implementation will permit a write to succeed
607c478bd9Sstevel@tonic-gate  * where PROT_WRITE has not been set.  Also, no implementation will
617c478bd9Sstevel@tonic-gate  * allow any access to succeed where prot is specified as PROT_NONE.
627c478bd9Sstevel@tonic-gate  */
637c478bd9Sstevel@tonic-gate #define	PROT_READ	0x1		/* pages can be read */
647c478bd9Sstevel@tonic-gate #define	PROT_WRITE	0x2		/* pages can be written */
657c478bd9Sstevel@tonic-gate #define	PROT_EXEC	0x4		/* pages can be executed */
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
687c478bd9Sstevel@tonic-gate #define	PROT_USER	0x8		/* pages are user accessable */
697c478bd9Sstevel@tonic-gate #define	PROT_ZFOD	(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_USER)
707c478bd9Sstevel@tonic-gate #define	PROT_ALL	(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_USER)
717c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate #define	PROT_NONE	0x0		/* pages cannot be accessed */
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate /* sharing types:  must choose either SHARED or PRIVATE */
767c478bd9Sstevel@tonic-gate #define	MAP_SHARED	1		/* share changes */
777c478bd9Sstevel@tonic-gate #define	MAP_PRIVATE	2		/* changes are private */
787c478bd9Sstevel@tonic-gate #define	MAP_TYPE	0xf		/* mask for share type */
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /* other flags to mmap (or-ed in to MAP_SHARED or MAP_PRIVATE) */
817c478bd9Sstevel@tonic-gate #define	MAP_FIXED	0x10		/* user assigns address */
827c478bd9Sstevel@tonic-gate #define	MAP_NORESERVE	0x40		/* don't reserve needed swap area */
837c478bd9Sstevel@tonic-gate #define	MAP_ANON	0x100		/* map anonymous pages directly */
847c478bd9Sstevel@tonic-gate #define	MAP_ANONYMOUS	MAP_ANON	/* (source compatibility) */
857c478bd9Sstevel@tonic-gate #define	MAP_ALIGN	0x200		/* addr specifies alignment */
867c478bd9Sstevel@tonic-gate #define	MAP_TEXT	0x400		/* map code segment */
877c478bd9Sstevel@tonic-gate #define	MAP_INITDATA	0x800		/* map data segment */
887c478bd9Sstevel@tonic-gate 
892cb27123Saguzovsk #ifdef _KERNEL
902cb27123Saguzovsk #define	_MAP_TEXTREPL	0x1000
912cb27123Saguzovsk #endif /* _KERNEL */
922cb27123Saguzovsk 
937c478bd9Sstevel@tonic-gate /* these flags not yet implemented */
947c478bd9Sstevel@tonic-gate #define	MAP_RENAME	0x20		/* rename private pages to file */
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate #if	(_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2)
977c478bd9Sstevel@tonic-gate /* these flags are used by memcntl */
987c478bd9Sstevel@tonic-gate #define	PROC_TEXT	(PROT_EXEC | PROT_READ)
997c478bd9Sstevel@tonic-gate #define	PROC_DATA	(PROT_READ | PROT_WRITE | PROT_EXEC)
1007c478bd9Sstevel@tonic-gate #define	SHARED		0x10
1017c478bd9Sstevel@tonic-gate #define	PRIVATE		0x20
1027c478bd9Sstevel@tonic-gate #define	VALID_ATTR  (PROT_READ|PROT_WRITE|PROT_EXEC|SHARED|PRIVATE)
1037c478bd9Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) */
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate #if	(_POSIX_C_SOURCE <= 2) || defined(_XPG4_2)
1067c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
1077c478bd9Sstevel@tonic-gate #define	PROT_EXCL	0x20
1087c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
1097c478bd9Sstevel@tonic-gate 
110*1b3b16f3STheo Schlossnagle #define	_MAP_LOW32	0x80	/* force mapping in lower 4G of address space */
111*1b3b16f3STheo Schlossnagle #define	MAP_32BIT	_MAP_LOW32
112*1b3b16f3STheo Schlossnagle 
1137c478bd9Sstevel@tonic-gate /*
1147c478bd9Sstevel@tonic-gate  * For the sake of backward object compatibility, we use the _MAP_NEW flag.
1157c478bd9Sstevel@tonic-gate  * This flag will be automatically or'ed in by the C library for all
1167c478bd9Sstevel@tonic-gate  * new mmap calls.  Previous binaries with old mmap calls will continue
1177c478bd9Sstevel@tonic-gate  * to get 0 or -1 for return values.  New mmap calls will get the mapped
1187c478bd9Sstevel@tonic-gate  * address as the return value if successful and -1 on errors.  By default,
1197c478bd9Sstevel@tonic-gate  * new mmap calls automatically have the kernel assign the map address
1207c478bd9Sstevel@tonic-gate  * unless the MAP_FIXED flag is given.
1217c478bd9Sstevel@tonic-gate  */
1227c478bd9Sstevel@tonic-gate #define	_MAP_NEW	0x80000000	/* users should not need to use this */
1237c478bd9Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE <= 2) */
1247c478bd9Sstevel@tonic-gate 
1250616c1c3SMichael Corcoran 
12631c6c9d8SMichael Corcoran #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
1270616c1c3SMichael Corcoran /* External flags for mmapobj syscall (Exclusive of MAP_* flags above) */
1280616c1c3SMichael Corcoran #define	MMOBJ_PADDING		0x10000
1290616c1c3SMichael Corcoran #define	MMOBJ_INTERPRET		0x20000
1300616c1c3SMichael Corcoran 
1310616c1c3SMichael Corcoran #define	MMOBJ_ALL_FLAGS		(MMOBJ_PADDING | MMOBJ_INTERPRET)
1320616c1c3SMichael Corcoran 
1330616c1c3SMichael Corcoran /*
1340616c1c3SMichael Corcoran  * Values for mr_flags field of mmapobj_result_t below.
1350616c1c3SMichael Corcoran  * The bottom 16 bits are mutually exclusive and thus only one
1360616c1c3SMichael Corcoran  * of them can be set at a time.  Use MR_GET_TYPE below to check this value.
1370616c1c3SMichael Corcoran  * The top 16 bits are used for flags which are not mutually exclusive and
1380616c1c3SMichael Corcoran  * thus more than one of these flags can be set for a given mmapobj_result_t.
1390616c1c3SMichael Corcoran  *
1400616c1c3SMichael Corcoran  * MR_PADDING being set indicates that this memory range represents the user
1410616c1c3SMichael Corcoran  * requested padding.
1420616c1c3SMichael Corcoran  *
1430616c1c3SMichael Corcoran  * MR_HDR_ELF being set indicates that the ELF header of the mapped object
1440616c1c3SMichael Corcoran  * is mapped at mr_addr + mr_offset.
1450616c1c3SMichael Corcoran  *
1460616c1c3SMichael Corcoran  * MR_HDR_AOUT being set indicates that the AOUT (4.x) header of the mapped
1470616c1c3SMichael Corcoran  * object is mapped at mr_addr + mr_offset.
1480616c1c3SMichael Corcoran  */
1490616c1c3SMichael Corcoran 
1500616c1c3SMichael Corcoran /*
1510616c1c3SMichael Corcoran  * External flags for mr_flags field below.
1520616c1c3SMichael Corcoran  */
1530616c1c3SMichael Corcoran #define	MR_PADDING	0x1
1540616c1c3SMichael Corcoran #define	MR_HDR_ELF	0x2
1550616c1c3SMichael Corcoran #define	MR_HDR_AOUT	0x3
1560616c1c3SMichael Corcoran 
1570616c1c3SMichael Corcoran /*
1580616c1c3SMichael Corcoran  * Internal flags for mr_flags field below.
1590616c1c3SMichael Corcoran  */
1600616c1c3SMichael Corcoran #ifdef	_KERNEL
1610616c1c3SMichael Corcoran #define	MR_RESV	0x80000000	/* overmapped /dev/null */
1620616c1c3SMichael Corcoran #endif	/* _KERNEL */
1630616c1c3SMichael Corcoran 
1640616c1c3SMichael Corcoran #define	MR_TYPE_MASK 0x0000ffff
1650616c1c3SMichael Corcoran #define	MR_GET_TYPE(val)	((val) & MR_TYPE_MASK)
1660616c1c3SMichael Corcoran 
1670616c1c3SMichael Corcoran #if	!defined(_ASM)
1680616c1c3SMichael Corcoran typedef struct mmapobj_result {
1690616c1c3SMichael Corcoran 	caddr_t		mr_addr;	/* mapping address */
1700616c1c3SMichael Corcoran 	size_t		mr_msize;	/* mapping size */
1710616c1c3SMichael Corcoran 	size_t		mr_fsize;	/* file size */
1720616c1c3SMichael Corcoran 	size_t		mr_offset;	/* offset into file */
1730616c1c3SMichael Corcoran 	uint_t		mr_prot;	/* the protections provided */
1740616c1c3SMichael Corcoran 	uint_t		mr_flags;	/* info on the mapping */
1750616c1c3SMichael Corcoran } mmapobj_result_t;
1760616c1c3SMichael Corcoran 
1770616c1c3SMichael Corcoran #if defined(_KERNEL) || defined(_SYSCALL32)
1780616c1c3SMichael Corcoran typedef struct mmapobj_result32 {
1790616c1c3SMichael Corcoran 	caddr32_t	mr_addr;	/* mapping address */
1800616c1c3SMichael Corcoran 	size32_t	mr_msize;	/* mapping size */
1810616c1c3SMichael Corcoran 	size32_t	mr_fsize;	/* file size */
1820616c1c3SMichael Corcoran 	size32_t	mr_offset;	/* offset into file */
1830616c1c3SMichael Corcoran 	uint_t		mr_prot;	/* the protections provided */
1840616c1c3SMichael Corcoran 	uint_t		mr_flags;	/* info on the mapping */
1850616c1c3SMichael Corcoran } mmapobj_result32_t;
1860616c1c3SMichael Corcoran #endif	/* defined(_KERNEL) || defined(_SYSCALL32) */
1870616c1c3SMichael Corcoran #endif	/* !defined(_ASM) */
18831c6c9d8SMichael Corcoran #endif	/* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
1890616c1c3SMichael Corcoran 
1900616c1c3SMichael Corcoran #if	!defined(_ASM) && !defined(_KERNEL)
1917c478bd9Sstevel@tonic-gate /*
1927c478bd9Sstevel@tonic-gate  * large file compilation environment setup
1937c478bd9Sstevel@tonic-gate  *
1947c478bd9Sstevel@tonic-gate  * In the LP64 compilation environment, map large file interfaces
1957c478bd9Sstevel@tonic-gate  * back to native versions where possible.
1967c478bd9Sstevel@tonic-gate  */
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
1997c478bd9Sstevel@tonic-gate #ifdef	__PRAGMA_REDEFINE_EXTNAME
2007c478bd9Sstevel@tonic-gate #pragma redefine_extname	mmap	mmap64
2017c478bd9Sstevel@tonic-gate #else
2027c478bd9Sstevel@tonic-gate #define	mmap			mmap64
2037c478bd9Sstevel@tonic-gate #endif
2047c478bd9Sstevel@tonic-gate #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
2077c478bd9Sstevel@tonic-gate #ifdef	__PRAGMA_REDEFINE_EXTNAME
2087c478bd9Sstevel@tonic-gate #pragma	redefine_extname	mmap64	mmap
2097c478bd9Sstevel@tonic-gate #else
2107c478bd9Sstevel@tonic-gate #define	mmap64			mmap
2117c478bd9Sstevel@tonic-gate #endif
2127c478bd9Sstevel@tonic-gate #endif	/* _LP64 && _LARGEFILE64_SOURCE */
2137c478bd9Sstevel@tonic-gate 
21402bc52beSkchow #ifdef __PRAGMA_REDEFINE_EXTNAME
21502bc52beSkchow #pragma redefine_extname	getpagesizes	getpagesizes2
21602bc52beSkchow #else
21702bc52beSkchow #define	getpagesizes	getpagesizes2
21802bc52beSkchow #endif
21902bc52beSkchow 
2207c478bd9Sstevel@tonic-gate /*
2217c478bd9Sstevel@tonic-gate  * Except for old binaries mmap() will return the resultant
2227c478bd9Sstevel@tonic-gate  * address of mapping on success and (caddr_t)-1 on error.
2237c478bd9Sstevel@tonic-gate  */
2247c478bd9Sstevel@tonic-gate #ifdef	__STDC__
2257c478bd9Sstevel@tonic-gate #if (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
2267c478bd9Sstevel@tonic-gate extern void *mmap(void *, size_t, int, int, int, off_t);
2277c478bd9Sstevel@tonic-gate extern int munmap(void *, size_t);
2287c478bd9Sstevel@tonic-gate extern int mprotect(void *, size_t, int);
2297c478bd9Sstevel@tonic-gate extern int msync(void *, size_t, int);
2307c478bd9Sstevel@tonic-gate #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
2317c478bd9Sstevel@tonic-gate extern int mlock(const void *, size_t);
2327c478bd9Sstevel@tonic-gate extern int munlock(const void *, size_t);
2337c478bd9Sstevel@tonic-gate #endif	/* (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2))... */
2347c478bd9Sstevel@tonic-gate /* transitional large file interface version */
2357c478bd9Sstevel@tonic-gate #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
2367c478bd9Sstevel@tonic-gate 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
2377c478bd9Sstevel@tonic-gate extern void *mmap64(void *, size_t, int, int, int, off64_t);
2387c478bd9Sstevel@tonic-gate #endif	/* _LARGEFILE64_SOURCE... */
2397c478bd9Sstevel@tonic-gate #else	/* (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) */
2407c478bd9Sstevel@tonic-gate extern caddr_t mmap(caddr_t, size_t, int, int, int, off_t);
2417c478bd9Sstevel@tonic-gate extern int munmap(caddr_t, size_t);
2427c478bd9Sstevel@tonic-gate extern int mprotect(caddr_t, size_t, int);
2437c478bd9Sstevel@tonic-gate extern int msync(caddr_t, size_t, int);
2447c478bd9Sstevel@tonic-gate extern int mlock(caddr_t, size_t);
2457c478bd9Sstevel@tonic-gate extern int munlock(caddr_t, size_t);
2467c478bd9Sstevel@tonic-gate extern int mincore(caddr_t, size_t, char *);
2477c478bd9Sstevel@tonic-gate extern int memcntl(caddr_t, size_t, int, caddr_t, int, int);
2487c478bd9Sstevel@tonic-gate extern int madvise(caddr_t, size_t, int);
2497c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
2507c478bd9Sstevel@tonic-gate extern int getpagesizes(size_t *, int);
25102bc52beSkchow extern int getpagesizes2(size_t *, int);
25231c6c9d8SMichael Corcoran extern int mmapobj(int, uint_t, mmapobj_result_t *, uint_t *, void *);
2537c478bd9Sstevel@tonic-gate /* guard visibility of uint64_t */
2547c478bd9Sstevel@tonic-gate #if defined(_INT64_TYPE)
2557c478bd9Sstevel@tonic-gate extern int meminfo(const uint64_t *, int, const uint_t *, int, uint64_t *,
2567c478bd9Sstevel@tonic-gate 	uint_t *);
2577c478bd9Sstevel@tonic-gate #endif /* defined(_INT64_TYPE) */
2587c478bd9Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
2597c478bd9Sstevel@tonic-gate /* transitional large file interface version */
2607c478bd9Sstevel@tonic-gate #ifdef	_LARGEFILE64_SOURCE
2617c478bd9Sstevel@tonic-gate extern caddr_t mmap64(caddr_t, size_t, int, int, int, off64_t);
2627c478bd9Sstevel@tonic-gate #endif
2637c478bd9Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE > 2)  || defined(_XPG4_2) */
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
2667c478bd9Sstevel@tonic-gate extern int mlockall(int);
2677c478bd9Sstevel@tonic-gate extern int munlockall(void);
268bfe60e20Sdamico extern int shm_open(const char *, int, mode_t);
269bfe60e20Sdamico extern int shm_unlink(const char *);
2707c478bd9Sstevel@tonic-gate #endif
2717c478bd9Sstevel@tonic-gate 
272019c3c43Sraf #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
273019c3c43Sraf extern int posix_madvise(void *, size_t, int);
274019c3c43Sraf #endif
275019c3c43Sraf 
2767c478bd9Sstevel@tonic-gate /* mmap failure value */
2777c478bd9Sstevel@tonic-gate #define	MAP_FAILED	((void *) -1)
2787c478bd9Sstevel@tonic-gate 
2797c478bd9Sstevel@tonic-gate #else	/* __STDC__ */
2807c478bd9Sstevel@tonic-gate extern caddr_t mmap();
2817c478bd9Sstevel@tonic-gate extern int munmap();
2820616c1c3SMichael Corcoran extern int mmapobj();
2837c478bd9Sstevel@tonic-gate extern int mprotect();
2847c478bd9Sstevel@tonic-gate extern int mincore();
2857c478bd9Sstevel@tonic-gate extern int memcntl();
2867c478bd9Sstevel@tonic-gate extern int msync();
2877c478bd9Sstevel@tonic-gate extern int madvise();
288019c3c43Sraf extern int posix_madvise();
2897c478bd9Sstevel@tonic-gate extern int getpagesizes();
29002bc52beSkchow extern int getpagesizes2();
2917c478bd9Sstevel@tonic-gate extern int mlock();
2927c478bd9Sstevel@tonic-gate extern int mlockall();
2937c478bd9Sstevel@tonic-gate extern int munlock();
2947c478bd9Sstevel@tonic-gate extern int munlockall();
2957c478bd9Sstevel@tonic-gate extern int meminfo();
296bfe60e20Sdamico extern int shm_open();
297bfe60e20Sdamico extern int shm_unlink();
298bfe60e20Sdamico 
2997c478bd9Sstevel@tonic-gate /* transitional large file interface version */
3007c478bd9Sstevel@tonic-gate #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
3017c478bd9Sstevel@tonic-gate 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
3027c478bd9Sstevel@tonic-gate extern caddr_t mmap64();
3037c478bd9Sstevel@tonic-gate #endif	/* _LARGEFILE64_SOURCE... */
3047c478bd9Sstevel@tonic-gate #endif	/* __STDC__ */
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate #endif	/* !_ASM && !_KERNEL */
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
3107c478bd9Sstevel@tonic-gate #if !defined(_ASM)
3117c478bd9Sstevel@tonic-gate /*
3127c478bd9Sstevel@tonic-gate  * structure for memcntl hat advise operations.
3137c478bd9Sstevel@tonic-gate  */
3147c478bd9Sstevel@tonic-gate struct memcntl_mha {
3157c478bd9Sstevel@tonic-gate 	uint_t 		mha_cmd;	/* command(s) */
3167c478bd9Sstevel@tonic-gate 	uint_t		mha_flags;
3177c478bd9Sstevel@tonic-gate 	size_t		mha_pagesize;
3187c478bd9Sstevel@tonic-gate };
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
3217c478bd9Sstevel@tonic-gate struct memcntl_mha32 {
3227c478bd9Sstevel@tonic-gate 	uint_t 		mha_cmd;	/* command(s) */
3237c478bd9Sstevel@tonic-gate 	uint_t		mha_flags;
3247c478bd9Sstevel@tonic-gate 	size32_t	mha_pagesize;
3257c478bd9Sstevel@tonic-gate };
3267c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32 */
3277c478bd9Sstevel@tonic-gate #endif	/* !defined(_ASM) */
3287c478bd9Sstevel@tonic-gate #endif	/* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate #if	(_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) || defined(__EXTENSIONS__)
3317c478bd9Sstevel@tonic-gate /* advice to madvise */
3327c478bd9Sstevel@tonic-gate #define	MADV_NORMAL		0	/* no further special treatment */
3337c478bd9Sstevel@tonic-gate #define	MADV_RANDOM		1	/* expect random page references */
3347c478bd9Sstevel@tonic-gate #define	MADV_SEQUENTIAL		2	/* expect sequential page references */
3357c478bd9Sstevel@tonic-gate #define	MADV_WILLNEED		3	/* will need these pages */
3367c478bd9Sstevel@tonic-gate #define	MADV_DONTNEED		4	/* don't need these pages */
3377c478bd9Sstevel@tonic-gate #define	MADV_FREE		5	/* contents can be freed */
3387c478bd9Sstevel@tonic-gate #define	MADV_ACCESS_DEFAULT	6	/* default access */
3397c478bd9Sstevel@tonic-gate #define	MADV_ACCESS_LWP		7	/* next LWP to access heavily */
3407c478bd9Sstevel@tonic-gate #define	MADV_ACCESS_MANY	8	/* many processes to access heavily */
3417c478bd9Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) ...  */
3427c478bd9Sstevel@tonic-gate 
343019c3c43Sraf #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
344019c3c43Sraf /* advice to posix_madvise */
345019c3c43Sraf /* these values must be kept in sync with the MADV_* values, above */
346019c3c43Sraf #define	POSIX_MADV_NORMAL	0	/* MADV_NORMAL */
347019c3c43Sraf #define	POSIX_MADV_RANDOM	1	/* MADV_RANDOM */
348019c3c43Sraf #define	POSIX_MADV_SEQUENTIAL	2	/* MADV_SEQUENTIAL */
349019c3c43Sraf #define	POSIX_MADV_WILLNEED	3	/* MADV_WILLNEED */
350019c3c43Sraf #define	POSIX_MADV_DONTNEED	4	/* MADV_DONTNEED */
351019c3c43Sraf #endif
352019c3c43Sraf 
3537c478bd9Sstevel@tonic-gate /* flags to msync */
3547c478bd9Sstevel@tonic-gate #define	MS_OLDSYNC	0x0		/* old value of MS_SYNC */
3557c478bd9Sstevel@tonic-gate 					/* modified for UNIX98 compliance */
3567c478bd9Sstevel@tonic-gate #define	MS_SYNC		0x4		/* wait for msync */
3577c478bd9Sstevel@tonic-gate #define	MS_ASYNC	0x1		/* return immediately */
3587c478bd9Sstevel@tonic-gate #define	MS_INVALIDATE	0x2		/* invalidate caches */
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate #if	(_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) || defined(__EXTENSIONS__)
3617c478bd9Sstevel@tonic-gate /* functions to mctl */
3627c478bd9Sstevel@tonic-gate #define	MC_SYNC		1		/* sync with backing store */
3637c478bd9Sstevel@tonic-gate #define	MC_LOCK		2		/* lock pages in memory */
3647c478bd9Sstevel@tonic-gate #define	MC_UNLOCK	3		/* unlock pages from memory */
3657c478bd9Sstevel@tonic-gate #define	MC_ADVISE	4		/* give advice to management */
3667c478bd9Sstevel@tonic-gate #define	MC_LOCKAS	5		/* lock address space in memory */
3677c478bd9Sstevel@tonic-gate #define	MC_UNLOCKAS	6		/* unlock address space from memory */
3687c478bd9Sstevel@tonic-gate #define	MC_HAT_ADVISE	7		/* advise hat map size */
3697c478bd9Sstevel@tonic-gate 
3707c478bd9Sstevel@tonic-gate /* sub-commands for MC_HAT_ADVISE */
3717c478bd9Sstevel@tonic-gate #define	MHA_MAPSIZE_VA		0x1	/* set preferred page size */
3727c478bd9Sstevel@tonic-gate #define	MHA_MAPSIZE_BSSBRK	0x2	/* set preferred page size */
3737c478bd9Sstevel@tonic-gate 					/* for last bss adjacent to */
3747c478bd9Sstevel@tonic-gate 					/* brk area and brk area itself */
3757c478bd9Sstevel@tonic-gate #define	MHA_MAPSIZE_STACK	0x4	/* set preferred page size */
3767c478bd9Sstevel@tonic-gate 					/* processes main stack */
3777c478bd9Sstevel@tonic-gate 
3787c478bd9Sstevel@tonic-gate #endif	/* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) ... */
3797c478bd9Sstevel@tonic-gate 
3807c478bd9Sstevel@tonic-gate #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__)
3817c478bd9Sstevel@tonic-gate /* flags to mlockall */
3827c478bd9Sstevel@tonic-gate #define	MCL_CURRENT	0x1		/* lock current mappings */
3837c478bd9Sstevel@tonic-gate #define	MCL_FUTURE	0x2		/* lock future mappings */
3847c478bd9Sstevel@tonic-gate #endif /* (!defined(_XPG4_2) || (_POSIX_C_SOURCE)) || defined(__EXTENSIONS__) */
3857c478bd9Sstevel@tonic-gate 
3867c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
3877c478bd9Sstevel@tonic-gate 
3887c478bd9Sstevel@tonic-gate /* definitions for meminfosys syscall */
3897c478bd9Sstevel@tonic-gate #define	MISYS_MEMINFO		0x0
3907c478bd9Sstevel@tonic-gate 
3917c478bd9Sstevel@tonic-gate #if !defined(_ASM) && defined(__STDC__)
3927c478bd9Sstevel@tonic-gate 
3937c478bd9Sstevel@tonic-gate #if defined(_INT64_TYPE)
3947c478bd9Sstevel@tonic-gate /* private structure for meminfo */
3957c478bd9Sstevel@tonic-gate typedef struct meminfo {
3967c478bd9Sstevel@tonic-gate 	const uint64_t *mi_inaddr;	/* array of input addresses */
3977c478bd9Sstevel@tonic-gate 	const uint_t *mi_info_req;	/* array of types of info requested */
3987c478bd9Sstevel@tonic-gate 	uint64_t *mi_outdata;		/* array of results are placed */
3997c478bd9Sstevel@tonic-gate 	uint_t *mi_validity;		/* array of bitwise result codes */
4007c478bd9Sstevel@tonic-gate 	int mi_info_count;		/* number of pieces of info requested */
4017c478bd9Sstevel@tonic-gate } meminfo_t;
4027c478bd9Sstevel@tonic-gate #endif /* defined(_INT64_TYPE) */
4037c478bd9Sstevel@tonic-gate 
4047c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
4057c478bd9Sstevel@tonic-gate typedef struct meminfo32 {
4067c478bd9Sstevel@tonic-gate 	caddr32_t mi_inaddr;	/* array of input addresses */
4077c478bd9Sstevel@tonic-gate 	caddr32_t mi_info_req;	/* array of types of information requested */
4087c478bd9Sstevel@tonic-gate 	caddr32_t mi_outdata;	/* array of results are placed */
4097c478bd9Sstevel@tonic-gate 	caddr32_t mi_validity;	/* array of bitwise result codes */
4107c478bd9Sstevel@tonic-gate 	int32_t mi_info_count;	/* number of pieces of information requested */
4117c478bd9Sstevel@tonic-gate } meminfo32_t;
4127c478bd9Sstevel@tonic-gate #endif /* defined(_SYSCALL32) */
4137c478bd9Sstevel@tonic-gate 
4147c478bd9Sstevel@tonic-gate #endif /* !defined(_ASM) && defined(__STDC__) */
4157c478bd9Sstevel@tonic-gate 
4167c478bd9Sstevel@tonic-gate /*
4177c478bd9Sstevel@tonic-gate  * info_req request type definitions for meminfo
4187c478bd9Sstevel@tonic-gate  * request types starting with MEMINFO_V are used for Virtual addresses
4197c478bd9Sstevel@tonic-gate  * and should not be mixed with MEMINFO_PLGRP which is targeted for Physical
4207c478bd9Sstevel@tonic-gate  * addresses
4217c478bd9Sstevel@tonic-gate  */
4227c478bd9Sstevel@tonic-gate #define	MEMINFO_SHIFT		16
4237c478bd9Sstevel@tonic-gate #define	MEMINFO_MASK		(0xFF << MEMINFO_SHIFT)
4247c478bd9Sstevel@tonic-gate #define	MEMINFO_VPHYSICAL	(0x01 << MEMINFO_SHIFT)	/* get physical addr */
4257c478bd9Sstevel@tonic-gate #define	MEMINFO_VLGRP		(0x02 << MEMINFO_SHIFT) /* get lgroup */
4267c478bd9Sstevel@tonic-gate #define	MEMINFO_VPAGESIZE	(0x03 << MEMINFO_SHIFT) /* size of phys page */
4277c478bd9Sstevel@tonic-gate #define	MEMINFO_VREPLCNT	(0x04 << MEMINFO_SHIFT) /* no. of replica */
4287c478bd9Sstevel@tonic-gate #define	MEMINFO_VREPL		(0x05 << MEMINFO_SHIFT) /* physical replica */
4297c478bd9Sstevel@tonic-gate #define	MEMINFO_VREPL_LGRP	(0x06 << MEMINFO_SHIFT) /* lgrp of replica */
4307c478bd9Sstevel@tonic-gate #define	MEMINFO_PLGRP		(0x07 << MEMINFO_SHIFT) /* lgroup for paddr */
4317c478bd9Sstevel@tonic-gate 
4327c478bd9Sstevel@tonic-gate /* maximum number of addresses meminfo() can process at a time */
4337c478bd9Sstevel@tonic-gate #define	MAX_MEMINFO_CNT	256
4347c478bd9Sstevel@tonic-gate 
4357c478bd9Sstevel@tonic-gate /* maximum number of request types */
4367c478bd9Sstevel@tonic-gate #define	MAX_MEMINFO_REQ	31
4377c478bd9Sstevel@tonic-gate 
4387c478bd9Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
4397c478bd9Sstevel@tonic-gate 
4407c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4417c478bd9Sstevel@tonic-gate }
4427c478bd9Sstevel@tonic-gate #endif
4437c478bd9Sstevel@tonic-gate 
4447c478bd9Sstevel@tonic-gate #endif	/* _SYS_MMAN_H */
445