1 /* $FreeBSD: src/sys/sys/shm.h,v 1.23 2005/04/02 12:33:36 das Exp $ */
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 * 4. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * Portions Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
34 * As defined+described in "X/Open System Interfaces and Headers"
41 #include <sys/cdefs.h>
43 #include <sys/_types.h>
45 #define SHM_RDONLY 010000 /* Attach read-only (else read-write) */
46 #define SHM_RND 020000 /* Round attach address to SHMLBA */
47 #define SHMLBA PAGE_SIZE /* Segment low boundary address multiple */
49 /* "official" access mode definitions; somewhat braindead since you have
50 to specify (SHM_* >> 3) for group and (SHM_* >> 6) for world permissions */
54 /* predefine tbd *LOCK shmctl commands */
58 /* ipcs shmctl commands */
62 #ifndef _PID_T_DECLARED
63 typedef __pid_t pid_t;
64 #define _PID_T_DECLARED
67 #ifndef _TIME_T_DECLARED
68 typedef __time_t time_t;
69 #define _TIME_T_DECLARED
72 #ifndef _SIZE_T_DECLARED
73 typedef __size_t size_t;
74 #define _SIZE_T_DECLARED
78 struct ipc_perm shm_perm; /* operation permission structure */
79 int shm_segsz; /* size of segment in bytes */
80 pid_t shm_lpid; /* process ID of last shared memory op */
81 pid_t shm_cpid; /* process ID of creator */
82 short shm_nattch; /* number of current attaches */
83 time_t shm_atime; /* time of last shmat() */
84 time_t shm_dtime; /* time of last shmdt() */
85 time_t shm_ctime; /* time of last change by shmctl() */
86 void *shm_internal; /* sysv stupidity */
92 * System 5 style catch-all structure for shared memory constants that
93 * might be of interest to user programs. Do we really want/need this?
96 int shmmax, /* max shared memory segment size (bytes) */
97 shmmin, /* min shared memory segment size (bytes) */
98 shmmni, /* max number of shared memory identifiers */
99 shmseg, /* max shared memory segments per process */
100 shmall; /* max amount of shared memory (pages) */
104 * Add a kernel wrapper to the shmid_ds struct so that private info (like the
105 * MAC label) can be added to it, without changing the user interface.
107 struct shmid_kernel {
109 struct label *label; /* MAC label */
112 extern struct shminfo shminfo;
116 unsigned long shm_tot;
117 unsigned long shm_rss;
118 unsigned long shm_swp;
119 unsigned long swap_attempts;
120 unsigned long swap_successes;
129 #include <sys/cdefs.h>
131 #ifndef _SIZE_T_DECLARED
132 typedef __size_t size_t;
133 #define _SIZE_T_DECLARED
136 // FUNCTION PROTOTYPES
139 // FORWARD DECLARATIONS
142 // CLASS/STRUCT/FUNCTION DECLARATION
145 * Get shared memory identifier using the IPC key generated by ftok.
148 IMPORT_C int shmget(key_t key, int size, int shmflg);
152 * Attaches the shared memory segment associated with the shared memory identifier
153 * specified by shmid to the address space of the calling process.
156 IMPORT_C void* shmat(int shmid, const void *shmaddr, int shmflg);
160 * Detaches the shared memory segment located at the address specified by shmaddr
161 * from the address space of the calling process.
164 IMPORT_C int shmdt(const void *shmaddr);
168 * Provides a variety of shared memory control operations as specified by cmd.
171 IMPORT_C int shmctl(int shmid, int cmd, struct shmid_ds *buf);
176 #endif /* !_KERNEL */