10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 53383Sdamico * Common Development and Distribution License (the "License"). 63383Sdamico * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 217088Sraf 220Sstevel@tonic-gate /* 237088Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 280Sstevel@tonic-gate /* All Rights Reserved */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate /* 310Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 320Sstevel@tonic-gate * The Regents of the University of California 330Sstevel@tonic-gate * All Rights Reserved 340Sstevel@tonic-gate * 350Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 360Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 370Sstevel@tonic-gate * contributors. 380Sstevel@tonic-gate */ 390Sstevel@tonic-gate 400Sstevel@tonic-gate #ifndef _SYS_MMAN_H 410Sstevel@tonic-gate #define _SYS_MMAN_H 420Sstevel@tonic-gate 430Sstevel@tonic-gate #include <sys/feature_tests.h> 440Sstevel@tonic-gate 450Sstevel@tonic-gate #ifdef __cplusplus 460Sstevel@tonic-gate extern "C" { 470Sstevel@tonic-gate #endif 480Sstevel@tonic-gate 49*8363SMichael.Corcoran@Sun.COM #if !defined(_ASM) && !defined(_KERNEL) 50*8363SMichael.Corcoran@Sun.COM #include <sys/types.h> 51*8363SMichael.Corcoran@Sun.COM #endif /* !_ASM && !_KERNEL */ 52*8363SMichael.Corcoran@Sun.COM 530Sstevel@tonic-gate /* 540Sstevel@tonic-gate * Protections are chosen from these bits, or-ed together. 550Sstevel@tonic-gate * Note - not all implementations literally provide all possible 560Sstevel@tonic-gate * combinations. PROT_WRITE is often implemented as (PROT_READ | 570Sstevel@tonic-gate * PROT_WRITE) and (PROT_EXECUTE as PROT_READ | PROT_EXECUTE). 580Sstevel@tonic-gate * However, no implementation will permit a write to succeed 590Sstevel@tonic-gate * where PROT_WRITE has not been set. Also, no implementation will 600Sstevel@tonic-gate * allow any access to succeed where prot is specified as PROT_NONE. 610Sstevel@tonic-gate */ 620Sstevel@tonic-gate #define PROT_READ 0x1 /* pages can be read */ 630Sstevel@tonic-gate #define PROT_WRITE 0x2 /* pages can be written */ 640Sstevel@tonic-gate #define PROT_EXEC 0x4 /* pages can be executed */ 650Sstevel@tonic-gate 660Sstevel@tonic-gate #ifdef _KERNEL 670Sstevel@tonic-gate #define PROT_USER 0x8 /* pages are user accessable */ 680Sstevel@tonic-gate #define PROT_ZFOD (PROT_READ | PROT_WRITE | PROT_EXEC | PROT_USER) 690Sstevel@tonic-gate #define PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC | PROT_USER) 700Sstevel@tonic-gate #endif /* _KERNEL */ 710Sstevel@tonic-gate 720Sstevel@tonic-gate #define PROT_NONE 0x0 /* pages cannot be accessed */ 730Sstevel@tonic-gate 740Sstevel@tonic-gate /* sharing types: must choose either SHARED or PRIVATE */ 750Sstevel@tonic-gate #define MAP_SHARED 1 /* share changes */ 760Sstevel@tonic-gate #define MAP_PRIVATE 2 /* changes are private */ 770Sstevel@tonic-gate #define MAP_TYPE 0xf /* mask for share type */ 780Sstevel@tonic-gate 790Sstevel@tonic-gate /* other flags to mmap (or-ed in to MAP_SHARED or MAP_PRIVATE) */ 800Sstevel@tonic-gate #define MAP_FIXED 0x10 /* user assigns address */ 810Sstevel@tonic-gate #define MAP_NORESERVE 0x40 /* don't reserve needed swap area */ 820Sstevel@tonic-gate #define MAP_ANON 0x100 /* map anonymous pages directly */ 830Sstevel@tonic-gate #define MAP_ANONYMOUS MAP_ANON /* (source compatibility) */ 840Sstevel@tonic-gate #define MAP_ALIGN 0x200 /* addr specifies alignment */ 850Sstevel@tonic-gate #define MAP_TEXT 0x400 /* map code segment */ 860Sstevel@tonic-gate #define MAP_INITDATA 0x800 /* map data segment */ 870Sstevel@tonic-gate 884426Saguzovsk #ifdef _KERNEL 894426Saguzovsk #define _MAP_TEXTREPL 0x1000 904426Saguzovsk #endif /* _KERNEL */ 914426Saguzovsk 920Sstevel@tonic-gate /* these flags not yet implemented */ 930Sstevel@tonic-gate #define MAP_RENAME 0x20 /* rename private pages to file */ 940Sstevel@tonic-gate 950Sstevel@tonic-gate #if (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) 960Sstevel@tonic-gate /* these flags are used by memcntl */ 970Sstevel@tonic-gate #define PROC_TEXT (PROT_EXEC | PROT_READ) 980Sstevel@tonic-gate #define PROC_DATA (PROT_READ | PROT_WRITE | PROT_EXEC) 990Sstevel@tonic-gate #define SHARED 0x10 1000Sstevel@tonic-gate #define PRIVATE 0x20 1010Sstevel@tonic-gate #define VALID_ATTR (PROT_READ|PROT_WRITE|PROT_EXEC|SHARED|PRIVATE) 1020Sstevel@tonic-gate #endif /* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) */ 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate #if (_POSIX_C_SOURCE <= 2) || defined(_XPG4_2) 1050Sstevel@tonic-gate #ifdef _KERNEL 1060Sstevel@tonic-gate #define PROT_EXCL 0x20 1070Sstevel@tonic-gate #define _MAP_LOW32 0x80 /* force mapping in lower 4G of address space */ 1080Sstevel@tonic-gate #endif /* _KERNEL */ 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate /* 1110Sstevel@tonic-gate * For the sake of backward object compatibility, we use the _MAP_NEW flag. 1120Sstevel@tonic-gate * This flag will be automatically or'ed in by the C library for all 1130Sstevel@tonic-gate * new mmap calls. Previous binaries with old mmap calls will continue 1140Sstevel@tonic-gate * to get 0 or -1 for return values. New mmap calls will get the mapped 1150Sstevel@tonic-gate * address as the return value if successful and -1 on errors. By default, 1160Sstevel@tonic-gate * new mmap calls automatically have the kernel assign the map address 1170Sstevel@tonic-gate * unless the MAP_FIXED flag is given. 1180Sstevel@tonic-gate */ 1190Sstevel@tonic-gate #define _MAP_NEW 0x80000000 /* users should not need to use this */ 1200Sstevel@tonic-gate #endif /* (_POSIX_C_SOURCE <= 2) */ 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate 123*8363SMichael.Corcoran@Sun.COM #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 1248212SMichael.Corcoran@Sun.COM /* External flags for mmapobj syscall (Exclusive of MAP_* flags above) */ 1258212SMichael.Corcoran@Sun.COM #define MMOBJ_PADDING 0x10000 1268212SMichael.Corcoran@Sun.COM #define MMOBJ_INTERPRET 0x20000 1278212SMichael.Corcoran@Sun.COM 1288212SMichael.Corcoran@Sun.COM #define MMOBJ_ALL_FLAGS (MMOBJ_PADDING | MMOBJ_INTERPRET) 1298212SMichael.Corcoran@Sun.COM 1308212SMichael.Corcoran@Sun.COM /* 1318212SMichael.Corcoran@Sun.COM * Values for mr_flags field of mmapobj_result_t below. 1328212SMichael.Corcoran@Sun.COM * The bottom 16 bits are mutually exclusive and thus only one 1338212SMichael.Corcoran@Sun.COM * of them can be set at a time. Use MR_GET_TYPE below to check this value. 1348212SMichael.Corcoran@Sun.COM * The top 16 bits are used for flags which are not mutually exclusive and 1358212SMichael.Corcoran@Sun.COM * thus more than one of these flags can be set for a given mmapobj_result_t. 1368212SMichael.Corcoran@Sun.COM * 1378212SMichael.Corcoran@Sun.COM * MR_PADDING being set indicates that this memory range represents the user 1388212SMichael.Corcoran@Sun.COM * requested padding. 1398212SMichael.Corcoran@Sun.COM * 1408212SMichael.Corcoran@Sun.COM * MR_HDR_ELF being set indicates that the ELF header of the mapped object 1418212SMichael.Corcoran@Sun.COM * is mapped at mr_addr + mr_offset. 1428212SMichael.Corcoran@Sun.COM * 1438212SMichael.Corcoran@Sun.COM * MR_HDR_AOUT being set indicates that the AOUT (4.x) header of the mapped 1448212SMichael.Corcoran@Sun.COM * object is mapped at mr_addr + mr_offset. 1458212SMichael.Corcoran@Sun.COM */ 1468212SMichael.Corcoran@Sun.COM 1478212SMichael.Corcoran@Sun.COM /* 1488212SMichael.Corcoran@Sun.COM * External flags for mr_flags field below. 1498212SMichael.Corcoran@Sun.COM */ 1508212SMichael.Corcoran@Sun.COM #define MR_PADDING 0x1 1518212SMichael.Corcoran@Sun.COM #define MR_HDR_ELF 0x2 1528212SMichael.Corcoran@Sun.COM #define MR_HDR_AOUT 0x3 1538212SMichael.Corcoran@Sun.COM 1548212SMichael.Corcoran@Sun.COM /* 1558212SMichael.Corcoran@Sun.COM * Internal flags for mr_flags field below. 1568212SMichael.Corcoran@Sun.COM */ 1578212SMichael.Corcoran@Sun.COM #ifdef _KERNEL 1588212SMichael.Corcoran@Sun.COM #define MR_RESV 0x80000000 /* overmapped /dev/null */ 1598212SMichael.Corcoran@Sun.COM #endif /* _KERNEL */ 1608212SMichael.Corcoran@Sun.COM 1618212SMichael.Corcoran@Sun.COM #define MR_TYPE_MASK 0x0000ffff 1628212SMichael.Corcoran@Sun.COM #define MR_GET_TYPE(val) ((val) & MR_TYPE_MASK) 1638212SMichael.Corcoran@Sun.COM 1648212SMichael.Corcoran@Sun.COM #if !defined(_ASM) 1658212SMichael.Corcoran@Sun.COM typedef struct mmapobj_result { 1668212SMichael.Corcoran@Sun.COM caddr_t mr_addr; /* mapping address */ 1678212SMichael.Corcoran@Sun.COM size_t mr_msize; /* mapping size */ 1688212SMichael.Corcoran@Sun.COM size_t mr_fsize; /* file size */ 1698212SMichael.Corcoran@Sun.COM size_t mr_offset; /* offset into file */ 1708212SMichael.Corcoran@Sun.COM uint_t mr_prot; /* the protections provided */ 1718212SMichael.Corcoran@Sun.COM uint_t mr_flags; /* info on the mapping */ 1728212SMichael.Corcoran@Sun.COM } mmapobj_result_t; 1738212SMichael.Corcoran@Sun.COM 1748212SMichael.Corcoran@Sun.COM #if defined(_KERNEL) || defined(_SYSCALL32) 1758212SMichael.Corcoran@Sun.COM typedef struct mmapobj_result32 { 1768212SMichael.Corcoran@Sun.COM caddr32_t mr_addr; /* mapping address */ 1778212SMichael.Corcoran@Sun.COM size32_t mr_msize; /* mapping size */ 1788212SMichael.Corcoran@Sun.COM size32_t mr_fsize; /* file size */ 1798212SMichael.Corcoran@Sun.COM size32_t mr_offset; /* offset into file */ 1808212SMichael.Corcoran@Sun.COM uint_t mr_prot; /* the protections provided */ 1818212SMichael.Corcoran@Sun.COM uint_t mr_flags; /* info on the mapping */ 1828212SMichael.Corcoran@Sun.COM } mmapobj_result32_t; 1838212SMichael.Corcoran@Sun.COM #endif /* defined(_KERNEL) || defined(_SYSCALL32) */ 1848212SMichael.Corcoran@Sun.COM #endif /* !defined(_ASM) */ 185*8363SMichael.Corcoran@Sun.COM #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 1868212SMichael.Corcoran@Sun.COM 1878212SMichael.Corcoran@Sun.COM #if !defined(_ASM) && !defined(_KERNEL) 1880Sstevel@tonic-gate /* 1890Sstevel@tonic-gate * large file compilation environment setup 1900Sstevel@tonic-gate * 1910Sstevel@tonic-gate * In the LP64 compilation environment, map large file interfaces 1920Sstevel@tonic-gate * back to native versions where possible. 1930Sstevel@tonic-gate */ 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate #if !defined(_LP64) && _FILE_OFFSET_BITS == 64 1960Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 1970Sstevel@tonic-gate #pragma redefine_extname mmap mmap64 1980Sstevel@tonic-gate #else 1990Sstevel@tonic-gate #define mmap mmap64 2000Sstevel@tonic-gate #endif 2010Sstevel@tonic-gate #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate #if defined(_LP64) && defined(_LARGEFILE64_SOURCE) 2040Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 2050Sstevel@tonic-gate #pragma redefine_extname mmap64 mmap 2060Sstevel@tonic-gate #else 2070Sstevel@tonic-gate #define mmap64 mmap 2080Sstevel@tonic-gate #endif 2090Sstevel@tonic-gate #endif /* _LP64 && _LARGEFILE64_SOURCE */ 2100Sstevel@tonic-gate 2115349Skchow #ifdef __PRAGMA_REDEFINE_EXTNAME 2125349Skchow #pragma redefine_extname getpagesizes getpagesizes2 2135349Skchow #else 2145349Skchow #define getpagesizes getpagesizes2 2155349Skchow #endif 2165349Skchow 2170Sstevel@tonic-gate /* 2180Sstevel@tonic-gate * Except for old binaries mmap() will return the resultant 2190Sstevel@tonic-gate * address of mapping on success and (caddr_t)-1 on error. 2200Sstevel@tonic-gate */ 2210Sstevel@tonic-gate #ifdef __STDC__ 2220Sstevel@tonic-gate #if (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) 2230Sstevel@tonic-gate extern void *mmap(void *, size_t, int, int, int, off_t); 2240Sstevel@tonic-gate extern int munmap(void *, size_t); 2250Sstevel@tonic-gate extern int mprotect(void *, size_t, int); 2260Sstevel@tonic-gate extern int msync(void *, size_t, int); 2270Sstevel@tonic-gate #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__) 2280Sstevel@tonic-gate extern int mlock(const void *, size_t); 2290Sstevel@tonic-gate extern int munlock(const void *, size_t); 2300Sstevel@tonic-gate #endif /* (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2))... */ 2310Sstevel@tonic-gate /* transitional large file interface version */ 2320Sstevel@tonic-gate #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ 2330Sstevel@tonic-gate !defined(__PRAGMA_REDEFINE_EXTNAME)) 2340Sstevel@tonic-gate extern void *mmap64(void *, size_t, int, int, int, off64_t); 2350Sstevel@tonic-gate #endif /* _LARGEFILE64_SOURCE... */ 2360Sstevel@tonic-gate #else /* (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) */ 2370Sstevel@tonic-gate extern caddr_t mmap(caddr_t, size_t, int, int, int, off_t); 2380Sstevel@tonic-gate extern int munmap(caddr_t, size_t); 2390Sstevel@tonic-gate extern int mprotect(caddr_t, size_t, int); 2400Sstevel@tonic-gate extern int msync(caddr_t, size_t, int); 2410Sstevel@tonic-gate extern int mlock(caddr_t, size_t); 2420Sstevel@tonic-gate extern int munlock(caddr_t, size_t); 2430Sstevel@tonic-gate extern int mincore(caddr_t, size_t, char *); 2440Sstevel@tonic-gate extern int memcntl(caddr_t, size_t, int, caddr_t, int, int); 2450Sstevel@tonic-gate extern int madvise(caddr_t, size_t, int); 2460Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 2470Sstevel@tonic-gate extern int getpagesizes(size_t *, int); 2485349Skchow extern int getpagesizes2(size_t *, int); 249*8363SMichael.Corcoran@Sun.COM extern int mmapobj(int, uint_t, mmapobj_result_t *, uint_t *, void *); 2500Sstevel@tonic-gate /* guard visibility of uint64_t */ 2510Sstevel@tonic-gate #if defined(_INT64_TYPE) 2520Sstevel@tonic-gate extern int meminfo(const uint64_t *, int, const uint_t *, int, uint64_t *, 2530Sstevel@tonic-gate uint_t *); 2540Sstevel@tonic-gate #endif /* defined(_INT64_TYPE) */ 2550Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 2560Sstevel@tonic-gate /* transitional large file interface version */ 2570Sstevel@tonic-gate #ifdef _LARGEFILE64_SOURCE 2580Sstevel@tonic-gate extern caddr_t mmap64(caddr_t, size_t, int, int, int, off64_t); 2590Sstevel@tonic-gate #endif 2600Sstevel@tonic-gate #endif /* (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) */ 2610Sstevel@tonic-gate 2620Sstevel@tonic-gate #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__) 2630Sstevel@tonic-gate extern int mlockall(int); 2640Sstevel@tonic-gate extern int munlockall(void); 2653383Sdamico extern int shm_open(const char *, int, mode_t); 2663383Sdamico extern int shm_unlink(const char *); 2670Sstevel@tonic-gate #endif 2680Sstevel@tonic-gate 2697088Sraf #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) 2707088Sraf extern int posix_madvise(void *, size_t, int); 2717088Sraf #endif 2727088Sraf 2730Sstevel@tonic-gate /* mmap failure value */ 2740Sstevel@tonic-gate #define MAP_FAILED ((void *) -1) 2750Sstevel@tonic-gate 2760Sstevel@tonic-gate #else /* __STDC__ */ 2770Sstevel@tonic-gate extern caddr_t mmap(); 2780Sstevel@tonic-gate extern int munmap(); 2798212SMichael.Corcoran@Sun.COM extern int mmapobj(); 2800Sstevel@tonic-gate extern int mprotect(); 2810Sstevel@tonic-gate extern int mincore(); 2820Sstevel@tonic-gate extern int memcntl(); 2830Sstevel@tonic-gate extern int msync(); 2840Sstevel@tonic-gate extern int madvise(); 2857088Sraf extern int posix_madvise(); 2860Sstevel@tonic-gate extern int getpagesizes(); 2875349Skchow extern int getpagesizes2(); 2880Sstevel@tonic-gate extern int mlock(); 2890Sstevel@tonic-gate extern int mlockall(); 2900Sstevel@tonic-gate extern int munlock(); 2910Sstevel@tonic-gate extern int munlockall(); 2920Sstevel@tonic-gate extern int meminfo(); 2933383Sdamico extern int shm_open(); 2943383Sdamico extern int shm_unlink(); 2953383Sdamico 2960Sstevel@tonic-gate /* transitional large file interface version */ 2970Sstevel@tonic-gate #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ 2980Sstevel@tonic-gate !defined(__PRAGMA_REDEFINE_EXTNAME)) 2990Sstevel@tonic-gate extern caddr_t mmap64(); 3000Sstevel@tonic-gate #endif /* _LARGEFILE64_SOURCE... */ 3010Sstevel@tonic-gate #endif /* __STDC__ */ 3020Sstevel@tonic-gate 3030Sstevel@tonic-gate 3040Sstevel@tonic-gate #endif /* !_ASM && !_KERNEL */ 3050Sstevel@tonic-gate 3060Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 3070Sstevel@tonic-gate #if !defined(_ASM) 3080Sstevel@tonic-gate /* 3090Sstevel@tonic-gate * structure for memcntl hat advise operations. 3100Sstevel@tonic-gate */ 3110Sstevel@tonic-gate struct memcntl_mha { 3120Sstevel@tonic-gate uint_t mha_cmd; /* command(s) */ 3130Sstevel@tonic-gate uint_t mha_flags; 3140Sstevel@tonic-gate size_t mha_pagesize; 3150Sstevel@tonic-gate }; 3160Sstevel@tonic-gate 3170Sstevel@tonic-gate #if defined(_SYSCALL32) 3180Sstevel@tonic-gate struct memcntl_mha32 { 3190Sstevel@tonic-gate uint_t mha_cmd; /* command(s) */ 3200Sstevel@tonic-gate uint_t mha_flags; 3210Sstevel@tonic-gate size32_t mha_pagesize; 3220Sstevel@tonic-gate }; 3230Sstevel@tonic-gate #endif /* _SYSCALL32 */ 3240Sstevel@tonic-gate #endif /* !defined(_ASM) */ 3250Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 3260Sstevel@tonic-gate 3270Sstevel@tonic-gate #if (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) || defined(__EXTENSIONS__) 3280Sstevel@tonic-gate /* advice to madvise */ 3290Sstevel@tonic-gate #define MADV_NORMAL 0 /* no further special treatment */ 3300Sstevel@tonic-gate #define MADV_RANDOM 1 /* expect random page references */ 3310Sstevel@tonic-gate #define MADV_SEQUENTIAL 2 /* expect sequential page references */ 3320Sstevel@tonic-gate #define MADV_WILLNEED 3 /* will need these pages */ 3330Sstevel@tonic-gate #define MADV_DONTNEED 4 /* don't need these pages */ 3340Sstevel@tonic-gate #define MADV_FREE 5 /* contents can be freed */ 3350Sstevel@tonic-gate #define MADV_ACCESS_DEFAULT 6 /* default access */ 3360Sstevel@tonic-gate #define MADV_ACCESS_LWP 7 /* next LWP to access heavily */ 3370Sstevel@tonic-gate #define MADV_ACCESS_MANY 8 /* many processes to access heavily */ 3380Sstevel@tonic-gate #endif /* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) ... */ 3390Sstevel@tonic-gate 3407088Sraf #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) 3417088Sraf /* advice to posix_madvise */ 3427088Sraf /* these values must be kept in sync with the MADV_* values, above */ 3437088Sraf #define POSIX_MADV_NORMAL 0 /* MADV_NORMAL */ 3447088Sraf #define POSIX_MADV_RANDOM 1 /* MADV_RANDOM */ 3457088Sraf #define POSIX_MADV_SEQUENTIAL 2 /* MADV_SEQUENTIAL */ 3467088Sraf #define POSIX_MADV_WILLNEED 3 /* MADV_WILLNEED */ 3477088Sraf #define POSIX_MADV_DONTNEED 4 /* MADV_DONTNEED */ 3487088Sraf #endif 3497088Sraf 3500Sstevel@tonic-gate /* flags to msync */ 3510Sstevel@tonic-gate #define MS_OLDSYNC 0x0 /* old value of MS_SYNC */ 3520Sstevel@tonic-gate /* modified for UNIX98 compliance */ 3530Sstevel@tonic-gate #define MS_SYNC 0x4 /* wait for msync */ 3540Sstevel@tonic-gate #define MS_ASYNC 0x1 /* return immediately */ 3550Sstevel@tonic-gate #define MS_INVALIDATE 0x2 /* invalidate caches */ 3560Sstevel@tonic-gate 3570Sstevel@tonic-gate #if (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) || defined(__EXTENSIONS__) 3580Sstevel@tonic-gate /* functions to mctl */ 3590Sstevel@tonic-gate #define MC_SYNC 1 /* sync with backing store */ 3600Sstevel@tonic-gate #define MC_LOCK 2 /* lock pages in memory */ 3610Sstevel@tonic-gate #define MC_UNLOCK 3 /* unlock pages from memory */ 3620Sstevel@tonic-gate #define MC_ADVISE 4 /* give advice to management */ 3630Sstevel@tonic-gate #define MC_LOCKAS 5 /* lock address space in memory */ 3640Sstevel@tonic-gate #define MC_UNLOCKAS 6 /* unlock address space from memory */ 3650Sstevel@tonic-gate #define MC_HAT_ADVISE 7 /* advise hat map size */ 3660Sstevel@tonic-gate 3670Sstevel@tonic-gate /* sub-commands for MC_HAT_ADVISE */ 3680Sstevel@tonic-gate #define MHA_MAPSIZE_VA 0x1 /* set preferred page size */ 3690Sstevel@tonic-gate #define MHA_MAPSIZE_BSSBRK 0x2 /* set preferred page size */ 3700Sstevel@tonic-gate /* for last bss adjacent to */ 3710Sstevel@tonic-gate /* brk area and brk area itself */ 3720Sstevel@tonic-gate #define MHA_MAPSIZE_STACK 0x4 /* set preferred page size */ 3730Sstevel@tonic-gate /* processes main stack */ 3740Sstevel@tonic-gate 3750Sstevel@tonic-gate #endif /* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) ... */ 3760Sstevel@tonic-gate 3770Sstevel@tonic-gate #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__) 3780Sstevel@tonic-gate /* flags to mlockall */ 3790Sstevel@tonic-gate #define MCL_CURRENT 0x1 /* lock current mappings */ 3800Sstevel@tonic-gate #define MCL_FUTURE 0x2 /* lock future mappings */ 3810Sstevel@tonic-gate #endif /* (!defined(_XPG4_2) || (_POSIX_C_SOURCE)) || defined(__EXTENSIONS__) */ 3820Sstevel@tonic-gate 3830Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 3840Sstevel@tonic-gate 3850Sstevel@tonic-gate /* definitions for meminfosys syscall */ 3860Sstevel@tonic-gate #define MISYS_MEMINFO 0x0 3870Sstevel@tonic-gate 3880Sstevel@tonic-gate #if !defined(_ASM) && defined(__STDC__) 3890Sstevel@tonic-gate 3900Sstevel@tonic-gate #if defined(_INT64_TYPE) 3910Sstevel@tonic-gate /* private structure for meminfo */ 3920Sstevel@tonic-gate typedef struct meminfo { 3930Sstevel@tonic-gate const uint64_t *mi_inaddr; /* array of input addresses */ 3940Sstevel@tonic-gate const uint_t *mi_info_req; /* array of types of info requested */ 3950Sstevel@tonic-gate uint64_t *mi_outdata; /* array of results are placed */ 3960Sstevel@tonic-gate uint_t *mi_validity; /* array of bitwise result codes */ 3970Sstevel@tonic-gate int mi_info_count; /* number of pieces of info requested */ 3980Sstevel@tonic-gate } meminfo_t; 3990Sstevel@tonic-gate #endif /* defined(_INT64_TYPE) */ 4000Sstevel@tonic-gate 4010Sstevel@tonic-gate #if defined(_SYSCALL32) 4020Sstevel@tonic-gate typedef struct meminfo32 { 4030Sstevel@tonic-gate caddr32_t mi_inaddr; /* array of input addresses */ 4040Sstevel@tonic-gate caddr32_t mi_info_req; /* array of types of information requested */ 4050Sstevel@tonic-gate caddr32_t mi_outdata; /* array of results are placed */ 4060Sstevel@tonic-gate caddr32_t mi_validity; /* array of bitwise result codes */ 4070Sstevel@tonic-gate int32_t mi_info_count; /* number of pieces of information requested */ 4080Sstevel@tonic-gate } meminfo32_t; 4090Sstevel@tonic-gate #endif /* defined(_SYSCALL32) */ 4100Sstevel@tonic-gate 4110Sstevel@tonic-gate #endif /* !defined(_ASM) && defined(__STDC__) */ 4120Sstevel@tonic-gate 4130Sstevel@tonic-gate /* 4140Sstevel@tonic-gate * info_req request type definitions for meminfo 4150Sstevel@tonic-gate * request types starting with MEMINFO_V are used for Virtual addresses 4160Sstevel@tonic-gate * and should not be mixed with MEMINFO_PLGRP which is targeted for Physical 4170Sstevel@tonic-gate * addresses 4180Sstevel@tonic-gate */ 4190Sstevel@tonic-gate #define MEMINFO_SHIFT 16 4200Sstevel@tonic-gate #define MEMINFO_MASK (0xFF << MEMINFO_SHIFT) 4210Sstevel@tonic-gate #define MEMINFO_VPHYSICAL (0x01 << MEMINFO_SHIFT) /* get physical addr */ 4220Sstevel@tonic-gate #define MEMINFO_VLGRP (0x02 << MEMINFO_SHIFT) /* get lgroup */ 4230Sstevel@tonic-gate #define MEMINFO_VPAGESIZE (0x03 << MEMINFO_SHIFT) /* size of phys page */ 4240Sstevel@tonic-gate #define MEMINFO_VREPLCNT (0x04 << MEMINFO_SHIFT) /* no. of replica */ 4250Sstevel@tonic-gate #define MEMINFO_VREPL (0x05 << MEMINFO_SHIFT) /* physical replica */ 4260Sstevel@tonic-gate #define MEMINFO_VREPL_LGRP (0x06 << MEMINFO_SHIFT) /* lgrp of replica */ 4270Sstevel@tonic-gate #define MEMINFO_PLGRP (0x07 << MEMINFO_SHIFT) /* lgroup for paddr */ 4280Sstevel@tonic-gate 4290Sstevel@tonic-gate /* maximum number of addresses meminfo() can process at a time */ 4300Sstevel@tonic-gate #define MAX_MEMINFO_CNT 256 4310Sstevel@tonic-gate 4320Sstevel@tonic-gate /* maximum number of request types */ 4330Sstevel@tonic-gate #define MAX_MEMINFO_REQ 31 4340Sstevel@tonic-gate 4350Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 4360Sstevel@tonic-gate 4370Sstevel@tonic-gate #ifdef __cplusplus 4380Sstevel@tonic-gate } 4390Sstevel@tonic-gate #endif 4400Sstevel@tonic-gate 4410Sstevel@tonic-gate #endif /* _SYS_MMAN_H */ 442