]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/shm.h
xnu-344.tar.gz
[apple/xnu.git] / bsd / sys / shm.h
1 /*
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /* $NetBSD: shm.h,v 1.15 1994/06/29 06:45:17 cgd Exp $ */
23
24 /*
25 * Copyright (c) 1994 Adam Glass
26 * All rights reserved.
27 *
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
30 * are met:
31 * 1. Redistributions of source code must retain the above copyright
32 * notice, this list of conditions and the following disclaimer.
33 * 2. Redistributions in binary form must reproduce the above copyright
34 * notice, this list of conditions and the following disclaimer in the
35 * documentation and/or other materials provided with the distribution.
36 * 3. All advertising materials mentioning features or use of this software
37 * must display the following acknowledgement:
38 * This product includes software developed by Adam Glass.
39 * 4. The name of the author may not be used to endorse or promote products
40 * derived from this software without specific prior written permission
41 *
42 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
43 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
44 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
45 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
46 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
48 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
49 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
51 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 */
53
54 /*
55 * As defined+described in "X/Open System Interfaces and Headers"
56 * Issue 4, p. XXX
57 */
58
59 #ifndef _SYS_SHM_H_
60 #define _SYS_SHM_H_
61
62 #include <sys/appleapiopts.h>
63 #include <sys/param.h>
64 #include <sys/ipc.h>
65
66 #define SHM_RDONLY 010000 /* Attach read-only (else read-write) */
67 #define SHM_RND 020000 /* Round attach address to SHMLBA */
68 #define SHMLBA NBPG /* Segment low boundary address multiple */
69
70 /* "official" access mode definitions; somewhat braindead since you have
71 to specify (SHM_* >> 3) for group and (SHM_* >> 6) for world permissions */
72 #define SHM_R (IPC_R)
73 #define SHM_W (IPC_W)
74
75
76 struct shmid_ds {
77 struct ipc_perm shm_perm; /* operation permission structure */
78 int shm_segsz; /* size of segment in bytes */
79 pid_t shm_lpid; /* process ID of last shared memory op */
80 pid_t shm_cpid; /* process ID of creator */
81 short shm_nattch; /* number of current attaches */
82 time_t shm_atime; /* time of last shmat() */
83 time_t shm_dtime; /* time of last shmdt() */
84 time_t shm_ctime; /* time of last change by shmctl() */
85 void *shm_internal; /* sysv stupidity */
86 };
87
88 #ifdef KERNEL
89 #ifdef __APPLE_API_PRIVATE
90 /*
91 * System 5 style catch-all structure for shared memory constants that
92 * might be of interest to user programs. Do we really want/need this?
93 */
94 struct shminfo {
95 int shmmax, /* max shared memory segment size (bytes) */
96 shmmin, /* min shared memory segment size (bytes) */
97 shmmni, /* max number of shared memory identifiers */
98 shmseg, /* max shared memory segments per process */
99 shmall; /* max amount of shared memory (pages) */
100 };
101 extern struct shminfo shminfo;
102 extern struct shmid_ds *shmsegs;
103
104 struct proc;
105
106 void shmexit __P((struct proc *));
107 void shmfork __P((struct proc *, struct proc *));
108 #endif /* __APPLE_API_PRIVATE */
109 #else /* !KERNEL */
110
111 #include <sys/cdefs.h>
112
113 __BEGIN_DECLS
114 int shmsys __P((int, ...));
115 void *shmat __P((int, void *, int));
116 int shmget __P((key_t, int, int));
117 int shmctl __P((int, int, struct shmid_ds *));
118 int shmdt __P((void *));
119 __END_DECLS
120
121 #endif /* !KERNEL */
122
123 #endif /* !_SYS_SHM_H_ */