kernel: some boottime sanitychecks
[minix.git] / include / sys / shm.h
blob2003c72af157c368898839a217e8c15e385b0db2
1 /* $NetBSD: shm.h,v 1.48 2009/01/19 19:39:41 christos Exp $ */
3 /*-
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
34 * Copyright (c) 1994 Adam Glass
35 * All rights reserved.
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
39 * are met:
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by Adam Glass.
48 * 4. The name of the author may not be used to endorse or promote products
49 * derived from this software without specific prior written permission
51 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
52 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
53 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
54 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
55 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
56 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
60 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 * As defined+described in "X/Open System Interfaces and Headers"
65 * Issue 4, p. XXX
68 #ifndef _SYS_SHM_H_
69 #define _SYS_SHM_H_
71 #include <sys/cdefs.h>
72 #include <sys/featuretest.h>
74 #include <sys/ipc.h>
76 #define SHM_RDONLY 010000 /* Attach read-only (else read-write) */
77 #define SHM_RND 020000 /* Round attach address to SHMLBA */
79 /* Segment low boundry address multiple */
80 #define SHMLBA getpagesize()
81 #define SHMMNI 4096
82 #define SHMSEG 32 /* max shared segs per process */
84 typedef unsigned int shmatt_t;
86 struct shmid_ds {
87 struct ipc_perm shm_perm; /* operation permission structure */
88 size_t shm_segsz; /* size of segment in bytes */
89 time_t shm_atime; /* time of last shmat() */
90 time_t shm_dtime; /* time of last shmdt() */
91 time_t shm_ctime; /* time of last change by shmctl() */
92 pid_t shm_cpid; /* process ID of creator */
93 pid_t shm_lpid; /* process ID of last shm operation */
94 shmatt_t shm_nattch; /* number of current attaches */
98 /* shm_mode upper byte flags */
99 #define SHM_DEST 01000 /* segment will be destroyed on last detach */
100 #define SHM_LOCKED 02000 /* segment will not be swapped */
102 /* ipcs ctl commands */
103 #define SHM_STAT 13
104 #define SHM_INFO 14
107 #if defined(_NETBSD_SOURCE) || defined(__minix)
109 * Permission definitions used in shmflag arguments to shmat(2) and shmget(2).
110 * Provided for source compatibility only; do not use in new code!
112 #define SHM_R 0400
113 #define SHM_W 0200
116 * System 5 style catch-all structure for shared memory constants that
117 * might be of interest to user programs. Do we really want/need this?
119 struct shminfo {
120 unsigned long int shmmax; /* max shared memory segment size (bytes) */
121 unsigned long int shmmin; /* min shared memory segment size (bytes) */
122 unsigned long int shmmni; /* max number of shared memory identifiers */
123 unsigned long int shmseg; /* max shared memory segments per process */
124 unsigned long int shmall; /* max amount of shared memory (pages) */
127 #ifdef __minix
128 struct shm_info
130 int used_ids;
131 unsigned long int shm_tot; /* total allocated shm */
132 unsigned long int shm_rss; /* total resident shm */
133 unsigned long int shm_swp; /* total swapped shm */
134 unsigned long int swap_attempts;
135 unsigned long int swap_successes;
137 #endif /* __minix */
139 #endif /* _NETBSD_SOURCE */
141 __BEGIN_DECLS
142 void *shmat(int, const void *, int);
143 int shmctl(int, int, struct shmid_ds *) __RENAME(__shmctl50);
144 int shmdt(const void *);
145 int shmget(key_t, size_t, int);
146 __END_DECLS
148 #endif /* !_SYS_SHM_H_ */