mman.h revision 8905f42caceb9f470ffaa19e5f6c9fb6184d12c0
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright 2013 OmniTI Computer Consulting, Inc. All rights reserved. */
/*
* Copyright 2014 Garrett D'Amore <garrett@damore.org>
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2015 Joyent, Inc. All rights reserved.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#ifndef _SYS_MMAN_H
#define _SYS_MMAN_H
#include <sys/feature_tests.h>
#ifdef __cplusplus
extern "C" {
#endif
#endif /* !_ASM && !_KERNEL */
/*
* Protections are chosen from these bits, or-ed together.
* Note - not all implementations literally provide all possible
* combinations. PROT_WRITE is often implemented as (PROT_READ |
* PROT_WRITE) and (PROT_EXECUTE as PROT_READ | PROT_EXECUTE).
* However, no implementation will permit a write to succeed
* where PROT_WRITE has not been set. Also, no implementation will
* allow any access to succeed where prot is specified as PROT_NONE.
*/
#ifdef _KERNEL
#endif /* _KERNEL */
/* sharing types: must choose either SHARED or PRIVATE */
/* other flags to mmap (or-ed in to MAP_SHARED or MAP_PRIVATE) */
#ifdef _KERNEL
#define _MAP_TEXTREPL 0x1000
#endif /* _KERNEL */
/* these flags not yet implemented */
/* these flags are used by memcntl */
#define SHARED 0x10
#define PRIVATE 0x20
#endif /* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) */
#ifdef _KERNEL
#define PROT_EXCL 0x20
#endif /* _KERNEL */
#define MAP_32BIT _MAP_LOW32
/*
* For the sake of backward object compatibility, we use the _MAP_NEW flag.
* This flag will be automatically or'ed in by the C library for all
* new mmap calls. Previous binaries with old mmap calls will continue
* to get 0 or -1 for return values. New mmap calls will get the mapped
* address as the return value if successful and -1 on errors. By default,
* new mmap calls automatically have the kernel assign the map address
* unless the MAP_FIXED flag is given.
*/
#endif /* (_POSIX_C_SOURCE <= 2) */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
/* External flags for mmapobj syscall (Exclusive of MAP_* flags above) */
#define MMOBJ_PADDING 0x10000
#define MMOBJ_INTERPRET 0x20000
/*
* Values for mr_flags field of mmapobj_result_t below.
* The bottom 16 bits are mutually exclusive and thus only one
* of them can be set at a time. Use MR_GET_TYPE below to check this value.
* The top 16 bits are used for flags which are not mutually exclusive and
* thus more than one of these flags can be set for a given mmapobj_result_t.
*
* MR_PADDING being set indicates that this memory range represents the user
* requested padding.
*
* MR_HDR_ELF being set indicates that the ELF header of the mapped object
* is mapped at mr_addr + mr_offset.
*
* MR_HDR_AOUT being set indicates that the AOUT (4.x) header of the mapped
* object is mapped at mr_addr + mr_offset.
*/
/*
* External flags for mr_flags field below.
*/
#define MR_PADDING 0x1
#define MR_HDR_ELF 0x2
#define MR_HDR_AOUT 0x3
/*
* Internal flags for mr_flags field below.
*/
#ifdef _KERNEL
#endif /* _KERNEL */
#define MR_TYPE_MASK 0x0000ffff
#if !defined(_ASM)
typedef struct mmapobj_result {
#if defined(_KERNEL) || defined(_SYSCALL32)
typedef struct mmapobj_result32 {
#endif /* defined(_KERNEL) || defined(_SYSCALL32) */
#endif /* !defined(_ASM) */
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
/*
* large file compilation environment setup
*
* In the LP64 compilation environment, map large file interfaces
* back to native versions where possible.
*/
#ifdef __PRAGMA_REDEFINE_EXTNAME
#else
#endif
#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
#if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
#ifdef __PRAGMA_REDEFINE_EXTNAME
#else
#endif
#endif /* _LP64 && _LARGEFILE64_SOURCE */
#ifdef __PRAGMA_REDEFINE_EXTNAME
#else
#define getpagesizes getpagesizes2
#endif
/*
* Except for old binaries mmap() will return the resultant
* address of mapping on success and (caddr_t)-1 on error.
*/
#endif /* (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2))... */
/* transitional large file interface version */
!defined(__PRAGMA_REDEFINE_EXTNAME))
#endif /* _LARGEFILE64_SOURCE... */
#else /* (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern int getpagesizes(size_t *, int);
extern int getpagesizes2(size_t *, int);
/* guard visibility of uint64_t */
#if defined(_INT64_TYPE)
uint_t *);
#endif /* defined(_INT64_TYPE) */
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
/* transitional large file interface version */
#ifdef _LARGEFILE64_SOURCE
#endif
#endif /* (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) */
extern int mlockall(int);
extern int munlockall(void);
extern int shm_unlink(const char *);
#endif
extern int posix_madvise(void *, size_t, int);
#endif
/* mmap failure value */
#define MAP_FAILED ((void *) -1)
#endif /* !_ASM && !_KERNEL */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
#if !defined(_ASM)
/*
* structure for memcntl hat advise operations.
*/
struct memcntl_mha {
};
#if defined(_SYSCALL32)
struct memcntl_mha32 {
};
#endif /* _SYSCALL32 */
#endif /* !defined(_ASM) */
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
/*
* advice to madvise
*
* Note, if more than 4 bits worth of advice (eg. 16) are specified then
* changes will be necessary to the struct vpage.
*/
#define MADV_NORMAL 0 /* no further special treatment */
#endif /* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) ... */
/* advice to posix_madvise */
/* these values must be kept in sync with the MADV_* values, above */
#define POSIX_MADV_NORMAL 0 /* MADV_NORMAL */
#endif
/* flags to msync */
/* modified for UNIX98 compliance */
/* functions to mctl */
/* sub-commands for MC_HAT_ADVISE */
/* for last bss adjacent to */
/* brk area and brk area itself */
/* processes main stack */
#endif /* (_POSIX_C_SOURCE <= 2) && !defined(_XPG4_2) ... */
/* flags to mlockall */
#endif /* (!defined(_XPG4_2) || (_POSIX_C_SOURCE)) || defined(__EXTENSIONS__) */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
/* definitions for meminfosys syscall */
#define MISYS_MEMINFO 0x0
#if !defined(_ASM)
#if defined(_INT64_TYPE)
/* private structure for meminfo */
typedef struct meminfo {
int mi_info_count; /* number of pieces of info requested */
} meminfo_t;
#endif /* defined(_INT64_TYPE) */
#if defined(_SYSCALL32)
typedef struct meminfo32 {
} meminfo32_t;
#endif /* defined(_SYSCALL32) */
#endif /* !defined(_ASM) */
/*
* info_req request type definitions for meminfo
* request types starting with MEMINFO_V are used for Virtual addresses
* and should not be mixed with MEMINFO_PLGRP which is targeted for Physical
* addresses
*/
#define MEMINFO_SHIFT 16
/* maximum number of addresses meminfo() can process at a time */
#define MAX_MEMINFO_CNT 256
/* maximum number of request types */
#define MAX_MEMINFO_REQ 31
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_MMAN_H */