]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/shm_internal.h
xnu-1504.3.12.tar.gz
[apple/xnu.git] / bsd / sys / shm_internal.h
CommitLineData
91447636 1/*
5d5c5d0d
A
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
91447636 5 *
2d21ac55
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
8f6c56a5 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
91447636
A
27 */
28/* $NetBSD: shm.h,v 1.15 1994/06/29 06:45:17 cgd Exp $ */
29
30/*
31 * Copyright (c) 1994 Adam Glass
32 * All rights reserved.
33 *
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
36 * are met:
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 * 3. All advertising materials mentioning features or use of this software
43 * must display the following acknowledgement:
44 * This product includes software developed by Adam Glass.
45 * 4. The name of the author may not be used to endorse or promote products
46 * derived from this software without specific prior written permission
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
49 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
50 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
51 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
52 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
53 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
57 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58 */
2d21ac55
A
59/*
60 * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce
61 * support for mandatory and extensible security protections. This notice
62 * is included in support of clause 2.2 (b) of the Apple Public License,
63 * Version 2.0.
64 */
91447636
A
65
66/*
67 * As defined+described in "X/Open System Interfaces and Headers"
68 * Issue 4, p. XXX
69 */
70
71#ifndef _SYS_SHM_INTERNALH_
72#define _SYS_SHM_INTERNALH_
73
74#include <sys/shm.h>
75#include <sys/cdefs.h>
76
77#include <machine/types.h>
78
b0d623f7 79#pragma pack(4)
91447636
A
80
81struct user_shmid_ds {
82 struct ipc_perm shm_perm; /* operation permission structure */
83 user_size_t shm_segsz; /* size of segment in bytes */
84 pid_t shm_lpid; /* PID of last shared memory op */
85 pid_t shm_cpid; /* PID of creator */
86 short shm_nattch; /* number of current attaches */
b0d623f7
A
87 user_time_t shm_atime; /* time of last shmat() */
88 user_time_t shm_dtime; /* time of last shmdt() */
89 user_time_t shm_ctime; /* time of last change by shmctl() */
91447636
A
90 user_addr_t shm_internal; /* reserved for kernel use */
91};
92
b0d623f7
A
93struct user32_shmid_ds {
94 struct ipc_perm shm_perm; /* operation permission structure */
95 uint32_t shm_segsz; /* size of segment in bytes */
96 pid_t shm_lpid; /* PID of last shared memory op */
97 pid_t shm_cpid; /* PID of creator */
98 short shm_nattch; /* number of current attaches */
99 uint32_t shm_atime; /* time of last shmat() */
100 uint32_t shm_dtime; /* time of last shmdt() */
101 uint32_t shm_ctime; /* time of last change by shmctl() */
102 user32_addr_t shm_internal; /* reserved for kernel use */
103};
104
105#pragma pack()
91447636
A
106
107/*
108 * System 5 style catch-all structure for shared memory constants that
109 * might be of interest to user programs. Also part of the ipcs interface.
110 * Note: use of user_ssize_t intentional: permits 32 bit ipcs to provide
111 * information about 64 bit programs shared segments.
0c530ab8
A
112 * Note 2: user_ssize_t is not that useful if it's not 64-bit,
113 * so let's use int64_t explicitely...
91447636
A
114 */
115struct shminfo {
0c530ab8
A
116 int64_t shmmax; /* max shm segment size (bytes) */
117 int64_t shmmin; /* min shm segment size (bytes) */
118 int64_t shmmni; /* max number of shm identifiers */
119 int64_t shmseg; /* max shm segments per process */
120 int64_t shmall; /* max amount of shm (pages) */
91447636
A
121};
122
123#ifdef KERNEL
2d21ac55
A
124
125struct label;
126
127/*
128 * Add a kernel wrapper to the shmid_ds struct so that private info (like the
129 * MAC label) can be added to it, without changing the user interface.
130 */
131struct shmid_kernel {
132 struct user_shmid_ds u;
133 struct label *label; /* MAC label */
134};
135
91447636 136extern struct shminfo shminfo;
2d21ac55 137extern struct shmid_kernel *shmsegs;
91447636
A
138
139struct proc;
140
141__BEGIN_DECLS
142
143void shmexit(struct proc *);
144int shmfork(struct proc *, struct proc *);
145__private_extern__ void shmexec(struct proc *);
146
147__END_DECLS
148
149#endif /* kernel */
150
151#endif /* !_SYS_SHM_INTERNALH_ */