xref: /freebsd/sys/compat/freebsd32/freebsd32_ipc.h (revision e9ac41698b2f322d55ccf9da50a3596edb2c1800)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2002 Doug Rabson
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #ifndef _COMPAT_FREEBSD32_FREEBSD32_IPC_H_
30 #define _COMPAT_FREEBSD32_FREEBSD32_IPC_H_
31 
32 struct ipc_perm32 {
33 	uid_t		cuid;
34 	gid_t		cgid;
35 	uid_t		uid;
36 	gid_t		gid;
37 	mode_t		mode;
38 	uint16_t	seq;
39 	uint32_t	key;
40 };
41 
42 struct semid_ds32 {
43 	struct ipc_perm32 sem_perm;
44 	uint32_t	__sem_base;
45 	unsigned short	sem_nsems;
46 	time32_t	sem_otime;
47 	time32_t	sem_ctime;
48 };
49 
50 #ifdef _KERNEL
51 struct semid_kernel32 {
52 	/* Data structure exposed to user space. */
53 	struct semid_ds32	u;
54 
55 	/* Kernel-private components of the semaphore. */
56 	int32_t			label;
57 	int32_t			cred;
58 };
59 #endif /* _KERNEL */
60 
61 union semun32 {
62 	int		val;
63 	uint32_t	buf;
64 	uint32_t	array;
65 };
66 
67 struct msqid_ds32 {
68 	struct ipc_perm32 msg_perm;
69 	uint32_t	__msg_first;
70 	uint32_t	__msg_last;
71 	uint32_t	msg_cbytes;
72 	uint32_t	msg_qnum;
73 	uint32_t	msg_qbytes;
74 	pid_t		msg_lspid;
75 	pid_t		msg_lrpid;
76 	time32_t	msg_stime;
77 	time32_t	msg_rtime;
78 	time32_t	msg_ctime;
79 };
80 
81 #ifdef _KERNEL
82 struct msqid_kernel32 {
83 	/* Data structure exposed to user space. */
84 	struct msqid_ds32	u;
85 
86 	/* Kernel-private components of the message queue. */
87 	uint32_t		label;
88 	uint32_t		cred;
89 };
90 #endif
91 
92 struct shmid_ds32 {
93 	struct ipc_perm32 shm_perm;
94 	int32_t		shm_segsz;
95 	pid_t		shm_lpid;
96 	pid_t		shm_cpid;
97 	unsigned int	shm_nattch;
98 	time32_t	shm_atime;
99 	time32_t	shm_dtime;
100 	time32_t	shm_ctime;
101 };
102 
103 #ifdef _KERNEL
104 struct shmid_kernel32 {
105 	struct shmid_ds32	u;
106 	int32_t			object;
107 	int32_t			label;
108 	int32_t			cred;
109 };
110 #endif
111 
112 struct shm_info32 {
113 	int32_t		used_ids;
114 	uint32_t	shm_tot;
115 	uint32_t	shm_rss;
116 	uint32_t	shm_swp;
117 	uint32_t	swap_attempts;
118 	uint32_t	swap_successes;
119 };
120 
121 struct shminfo32 {
122 	uint32_t	shmmax;
123 	uint32_t	shmmin;
124 	uint32_t	shmmni;
125 	uint32_t	shmseg;
126 	uint32_t	shmall;
127 };
128 
129 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
130     defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
131 struct ipc_perm_old32 {
132 	uint16_t	cuid;
133 	uint16_t	cgid;
134 	uint16_t	uid;
135 	uint16_t	gid;
136 	uint16_t	mode;
137 	uint16_t	seq;
138 	uint32_t	key;
139 };
140 
141 struct semid_ds_old32 {
142 	struct ipc_perm_old32 sem_perm;
143 	uint32_t	__sem_base;
144 	unsigned short	sem_nsems;
145 	time32_t	sem_otime;
146 	int32_t		sem_pad1;
147 	time32_t	sem_ctime;
148 	int32_t		sem_pad2;
149 	int32_t		sem_pad3[4];
150 };
151 
152 struct msqid_ds_old32 {
153 	struct ipc_perm_old32 msg_perm;
154 	uint32_t	__msg_first;
155 	uint32_t	__msg_last;
156 	uint32_t	msg_cbytes;
157 	uint32_t	msg_qnum;
158 	uint32_t	msg_qbytes;
159 	pid_t		msg_lspid;
160 	pid_t		msg_lrpid;
161 	time32_t	msg_stime;
162 	int32_t		msg_pad1;
163 	time32_t	msg_rtime;
164 	int32_t		msg_pad2;
165 	time32_t	msg_ctime;
166 	int32_t		msg_pad3;
167 	int32_t		msg_pad4[4];
168 };
169 
170 struct shmid_ds_old32 {
171 	struct ipc_perm_old32 shm_perm;
172 	int32_t		shm_segsz;
173 	pid_t		shm_lpid;
174 	pid_t		shm_cpid;
175 	int16_t		shm_nattch;
176 	time32_t	shm_atime;
177 	time32_t	shm_dtime;
178 	time32_t	shm_ctime;
179 	uint32_t	shm_internal;
180 };
181 
182 union semun_old32 {
183 	int		val;
184 	uint32_t	buf;
185 	uint32_t	array;
186 };
187 
188 void	freebsd32_ipcperm_old_in(struct ipc_perm_old32 *ip32,
189 	    struct ipc_perm *ip);
190 void	freebsd32_ipcperm_old_out(struct ipc_perm *ip,
191 	    struct ipc_perm_old32 *ip32);
192 #endif
193 
194 void	freebsd32_ipcperm_in(struct ipc_perm32 *ip32, struct ipc_perm *ip);
195 void	freebsd32_ipcperm_out(struct ipc_perm *ip, struct ipc_perm32 *ip32);
196 
197 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_IPC_H_ */
198