xref: /netbsd/sys/compat/linux/common/linux_shm.h (revision ce099b40)
1 /*	$NetBSD: linux_shm.h,v 1.12 2008/04/28 20:23:44 martin 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  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _LINUX_SHM_H
33 #define _LINUX_SHM_H
34 
35 #include <sys/shm.h>
36 
37 /*
38  * shm segment control structure
39  */
40 struct linux_shmid_ds {
41 	struct linux_ipc_perm	l_shm_perm;
42 	int			l_shm_segsz;
43 	linux_time_t		l_shm_atime;
44 	linux_time_t		l_shm_dtime;
45 	linux_time_t		l_shm_ctime;
46 	ushort			l_shm_cpid;
47 	ushort			l_shm_lpid;
48 	short			l_shm_nattch;
49 	ushort			l_private1;
50 	void			*l_private2;
51 	void			*l_private3;
52 };
53 
54 struct linux_shmid64_ds {
55 	struct linux_ipc64_perm	l_shm_perm;
56 	size_t			l_shm_segsz;
57 	linux_time_t		l_shm_atime;
58 #ifndef _LP64
59 	u_long			l____unused1;
60 #endif
61 	linux_time_t		l_shm_dtime;
62 #ifndef _LP64
63 	u_long			l____unused2;
64 #endif
65 	linux_time_t		l_shm_ctime;
66 #ifndef _LP64
67 	u_long			l____unused3;
68 #endif
69 	int			l_shm_cpid;
70 	int			l_shm_lpid;
71 	u_long			l_shm_nattch;
72 	u_long			l___unused4;
73 	u_long			l___unused5;
74 };
75 
76 struct linux_shminfo64 {
77 	u_long			l_shmmax;
78 	u_long			l_shmmin;
79 	u_long			l_shmmni;
80 	u_long			l_shmseg;
81 	u_long			l_shmall;
82 	u_long			l___unused1;
83 	u_long			l___unused2;
84 	u_long			l___unused3;
85 	u_long			l___unused4;
86 };
87 
88 struct linux_shm_info {
89 	int			l_used_ids;
90 	u_long			l_shm_tot;
91 	u_long			l_shm_rss;
92 	u_long			l_shm_swp;
93 	u_long			l_swap_attempts;
94 	u_long			l_swap_successes;
95 };
96 
97 #define LINUX_SHM_RDONLY	0x1000
98 #define LINUX_SHM_RND		0x2000
99 #define LINUX_SHM_REMAP		0x4000
100 
101 #define LINUX_SHM_LOCK		11
102 #define LINUX_SHM_UNLOCK	12
103 #define LINUX_SHM_STAT		13
104 #define LINUX_SHM_INFO		14
105 
106 
107 /* Pretend the sys_shmat and sys_shmctl syscalls are defined */
108 struct linux_sys_shmat_args {
109 	syscallarg(int) shmid;
110 	syscallarg(void *) shmaddr;
111 	syscallarg(int) shmflg;
112 	syscallarg(u_long *) raddr;
113 };
114 
115 struct linux_sys_shmctl_args {
116 	syscallarg(int) shmid;
117 	syscallarg(int) cmd;
118 	syscallarg(struct linux_shmid_ds *) buf;
119 };
120 
121 struct linux_sys_shmget_args {
122 	syscallarg(key_t) key;
123 	syscallarg(size_t) size;
124 	syscallarg(int) shmflg;
125 };
126 
127 #ifdef SYSVSHM
128 #ifdef _KERNEL
129 __BEGIN_DECLS
130 int linux_sys_shmget(struct lwp *, const struct linux_sys_shmget_args *, register_t *);
131 int linux_sys_shmat(struct lwp *, const struct linux_sys_shmat_args *, register_t *);
132 int linux_sys_shmctl(struct lwp *, const struct linux_sys_shmctl_args *, register_t *);
133 void linux_to_bsd_shmid_ds(struct linux_shmid_ds *,
134     struct shmid_ds *);
135 void linux_to_bsd_shmid64_ds(struct linux_shmid64_ds *,
136     struct shmid_ds *);
137 void bsd_to_linux_shmid_ds(struct shmid_ds *,
138     struct linux_shmid_ds *);
139 void bsd_to_linux_shmid64_ds(struct shmid_ds *,
140     struct linux_shmid64_ds *);
141 __END_DECLS
142 #endif	/* !_KERNEL */
143 #endif	/* !SYSVSHM */
144 
145 #endif /* !_LINUX_SHM_H */
146