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