xref: /netbsd-src/sys/compat/linux/common/linux_shm.h (revision 267197ec1eebfcb9810ea27a89625b6ddf68e3e7)
1 /*	$NetBSD: linux_shm.h,v 1.11 2008/01/28 14:14:48 njoly Exp $	*/
2 
3 /*-
4  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Frank van der Linden and Eric Haszlakiewicz.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by the NetBSD
21  *	Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #ifndef _LINUX_SHM_H
40 #define _LINUX_SHM_H
41 
42 #include <sys/shm.h>
43 
44 /*
45  * shm segment control structure
46  */
47 struct linux_shmid_ds {
48 	struct linux_ipc_perm	l_shm_perm;
49 	int			l_shm_segsz;
50 	linux_time_t		l_shm_atime;
51 	linux_time_t		l_shm_dtime;
52 	linux_time_t		l_shm_ctime;
53 	ushort			l_shm_cpid;
54 	ushort			l_shm_lpid;
55 	short			l_shm_nattch;
56 	ushort			l_private1;
57 	void			*l_private2;
58 	void			*l_private3;
59 };
60 
61 struct linux_shmid64_ds {
62 	struct linux_ipc64_perm	l_shm_perm;
63 	size_t			l_shm_segsz;
64 	linux_time_t		l_shm_atime;
65 #ifndef _LP64
66 	u_long			l____unused1;
67 #endif
68 	linux_time_t		l_shm_dtime;
69 #ifndef _LP64
70 	u_long			l____unused2;
71 #endif
72 	linux_time_t		l_shm_ctime;
73 #ifndef _LP64
74 	u_long			l____unused3;
75 #endif
76 	int			l_shm_cpid;
77 	int			l_shm_lpid;
78 	u_long			l_shm_nattch;
79 	u_long			l___unused4;
80 	u_long			l___unused5;
81 };
82 
83 struct linux_shminfo64 {
84 	u_long			l_shmmax;
85 	u_long			l_shmmin;
86 	u_long			l_shmmni;
87 	u_long			l_shmseg;
88 	u_long			l_shmall;
89 	u_long			l___unused1;
90 	u_long			l___unused2;
91 	u_long			l___unused3;
92 	u_long			l___unused4;
93 };
94 
95 struct linux_shm_info {
96 	int			l_used_ids;
97 	u_long			l_shm_tot;
98 	u_long			l_shm_rss;
99 	u_long			l_shm_swp;
100 	u_long			l_swap_attempts;
101 	u_long			l_swap_successes;
102 };
103 
104 #define LINUX_SHM_RDONLY	0x1000
105 #define LINUX_SHM_RND		0x2000
106 #define LINUX_SHM_REMAP		0x4000
107 
108 #define LINUX_SHM_LOCK		11
109 #define LINUX_SHM_UNLOCK	12
110 #define LINUX_SHM_STAT		13
111 #define LINUX_SHM_INFO		14
112 
113 
114 /* Pretend the sys_shmat and sys_shmctl syscalls are defined */
115 struct linux_sys_shmat_args {
116 	syscallarg(int) shmid;
117 	syscallarg(void *) shmaddr;
118 	syscallarg(int) shmflg;
119 	syscallarg(u_long *) raddr;
120 };
121 
122 struct linux_sys_shmctl_args {
123 	syscallarg(int) shmid;
124 	syscallarg(int) cmd;
125 	syscallarg(struct linux_shmid_ds *) buf;
126 };
127 
128 struct linux_sys_shmget_args {
129 	syscallarg(key_t) key;
130 	syscallarg(size_t) size;
131 	syscallarg(int) shmflg;
132 };
133 
134 #ifdef SYSVSHM
135 #ifdef _KERNEL
136 __BEGIN_DECLS
137 int linux_sys_shmget(struct lwp *, const struct linux_sys_shmget_args *, register_t *);
138 int linux_sys_shmat(struct lwp *, const struct linux_sys_shmat_args *, register_t *);
139 int linux_sys_shmctl(struct lwp *, const struct linux_sys_shmctl_args *, register_t *);
140 void linux_to_bsd_shmid_ds(struct linux_shmid_ds *,
141     struct shmid_ds *);
142 void linux_to_bsd_shmid64_ds(struct linux_shmid64_ds *,
143     struct shmid_ds *);
144 void bsd_to_linux_shmid_ds(struct shmid_ds *,
145     struct linux_shmid_ds *);
146 void bsd_to_linux_shmid64_ds(struct shmid_ds *,
147     struct linux_shmid64_ds *);
148 __END_DECLS
149 #endif	/* !_KERNEL */
150 #endif	/* !SYSVSHM */
151 
152 #endif /* !_LINUX_SHM_H */
153