2 /* $NetBSD: shm.h,v 1.15 1994/06/29 06:45:17 cgd Exp $ */
5 * Copyright (c) 1994 Adam Glass
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Adam Glass.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 * As defined+described in "X/Open System Interfaces and Headers"
42 #include <sys/cdefs.h>
43 #ifdef _WANT_SYSVSHM_INTERNALS
44 #define _WANT_SYSVIPC_INTERNALS
47 #include <sys/_types.h>
49 #include <machine/param.h>
51 #define SHM_RDONLY 010000 /* Attach read-only (else read-write) */
52 #define SHM_RND 020000 /* Round attach address to SHMLBA */
53 #define SHM_REMAP 030000 /* Unmap before mapping */
54 #define SHMLBA PAGE_SIZE /* Segment low boundary address multiple */
56 /* "official" access mode definitions; somewhat braindead since you have
57 to specify (SHM_* >> 3) for group and (SHM_* >> 6) for world permissions */
61 /* predefine tbd *LOCK shmctl commands */
65 /* ipcs shmctl commands for Linux compatibility */
69 #ifndef _PID_T_DECLARED
70 typedef __pid_t pid_t;
71 #define _PID_T_DECLARED
74 #ifndef _TIME_T_DECLARED
75 typedef __time_t time_t;
76 #define _TIME_T_DECLARED
79 #ifndef _SIZE_T_DECLARED
80 typedef __size_t size_t;
81 #define _SIZE_T_DECLARED
84 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
85 defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
87 struct ipc_perm_old shm_perm; /* operation permission structure */
88 int shm_segsz; /* size of segment in bytes */
89 pid_t shm_lpid; /* process ID of last shared memory op */
90 pid_t shm_cpid; /* process ID of creator */
91 short shm_nattch; /* number of current attaches */
92 time_t shm_atime; /* time of last shmat() */
93 time_t shm_dtime; /* time of last shmdt() */
94 time_t shm_ctime; /* time of last change by shmctl() */
95 void *shm_internal; /* sysv stupidity */
100 struct ipc_perm shm_perm; /* operation permission structure */
101 size_t shm_segsz; /* size of segment in bytes */
102 pid_t shm_lpid; /* process ID of last shared memory op */
103 pid_t shm_cpid; /* process ID of creator */
104 int shm_nattch; /* number of current attaches */
105 time_t shm_atime; /* time of last shmat() */
106 time_t shm_dtime; /* time of last shmdt() */
107 time_t shm_ctime; /* time of last change by shmctl() */
110 #if defined(_KERNEL) || defined(_WANT_SYSVSHM_INTERNALS)
112 * System 5 style catch-all structure for shared memory constants that
113 * might be of interest to user programs. Do we really want/need this?
116 u_long shmmax; /* max shared memory segment size (bytes) */
117 u_long shmmin; /* max shared memory segment size (bytes) */
118 u_long shmmni; /* max number of shared memory identifiers */
119 u_long shmseg; /* max shared memory segments per process */
120 u_long shmall; /* max amount of shared memory (pages) */
126 * Add a kernel wrapper to the shmid_ds struct so that private info (like the
127 * MAC label) can be added to it, without changing the user interface.
129 struct shmid_kernel {
131 struct vm_object *object;
132 struct label *label; /* MAC label */
133 struct ucred *cred; /* creator's credendials */
139 unsigned long shm_tot;
140 unsigned long shm_rss;
141 unsigned long shm_swp;
142 unsigned long swap_attempts;
143 unsigned long swap_successes;
150 extern struct shminfo shminfo;
152 void shmexit(struct vmspace *);
153 void shmfork(struct proc *, struct proc *);
157 #include <sys/cdefs.h>
159 #ifndef _SIZE_T_DECLARED
160 typedef __size_t size_t;
161 #define _SIZE_T_DECLARED
166 int shmsys(int, ...);
168 void *shmat(int, const void *, int);
169 int shmget(key_t, size_t, int);
170 int shmctl(int, int, struct shmid_ds *);
171 int shmdt(const void *);
176 #endif /* !_SYS_SHM_H_ */