linux_ipc.h revision 331755
1261268Sjhb/*-
2261268Sjhb * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3261268Sjhb *
4261268Sjhb * Copyright (c) 2000 Marcel Moolenaar
5261268Sjhb * All rights reserved.
6261268Sjhb *
7261268Sjhb * Redistribution and use in source and binary forms, with or without
8261268Sjhb * modification, are permitted provided that the following conditions
9261268Sjhb * are met:
10261268Sjhb * 1. Redistributions of source code must retain the above copyright
11261268Sjhb *    notice, this list of conditions and the following disclaimer.
12261268Sjhb * 2. Redistributions in binary form must reproduce the above copyright
13261268Sjhb *    notice, this list of conditions and the following disclaimer in the
14261268Sjhb *    documentation and/or other materials provided with the distribution.
15261268Sjhb *
16261268Sjhb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17261268Sjhb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18261268Sjhb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19261268Sjhb * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20261268Sjhb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21261268Sjhb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22261268Sjhb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23261268Sjhb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24261268Sjhb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25261268Sjhb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26261268Sjhb * SUCH DAMAGE.
27261268Sjhb *
28261268Sjhb * $FreeBSD: stable/11/sys/compat/linux/linux_ipc.h 331755 2018-03-30 01:53:14Z emaste $
29261268Sjhb */
30261268Sjhb
31261268Sjhb#ifndef _LINUX_IPC_H_
32261268Sjhb#define _LINUX_IPC_H_
33261268Sjhb
34261268Sjhb/*
35261268Sjhb * SystemV IPC defines
36261268Sjhb */
37261268Sjhb#define	LINUX_SEMOP		1
38261268Sjhb#define	LINUX_SEMGET		2
39261268Sjhb#define	LINUX_SEMCTL		3
40261268Sjhb#define	LINUX_MSGSND		11
41261268Sjhb#define	LINUX_MSGRCV		12
42261268Sjhb#define	LINUX_MSGGET		13
43261268Sjhb#define	LINUX_MSGCTL		14
44261268Sjhb#define	LINUX_SHMAT		21
45261268Sjhb#define	LINUX_SHMDT		22
46261268Sjhb#define	LINUX_SHMGET		23
47261268Sjhb#define	LINUX_SHMCTL		24
48261268Sjhb
49261268Sjhb#define	LINUX_IPC_RMID		0
50261268Sjhb#define	LINUX_IPC_SET		1
51261268Sjhb#define	LINUX_IPC_STAT		2
52261268Sjhb#define	LINUX_IPC_INFO		3
53261268Sjhb
54261268Sjhb#define	LINUX_MSG_INFO	12
55261268Sjhb
56261268Sjhb#define	LINUX_SHM_LOCK		11
57261268Sjhb#define	LINUX_SHM_UNLOCK	12
58261268Sjhb#define	LINUX_SHM_STAT		13
59261268Sjhb#define	LINUX_SHM_INFO		14
60261268Sjhb
61261268Sjhb#define	LINUX_SHM_RDONLY	0x1000
62261268Sjhb#define	LINUX_SHM_RND		0x2000
63261268Sjhb#define	LINUX_SHM_REMAP		0x4000
64261268Sjhb
65261268Sjhb/* semctl commands */
66261268Sjhb#define	LINUX_GETPID		11
67261268Sjhb#define	LINUX_GETVAL		12
68261268Sjhb#define	LINUX_GETALL		13
69261268Sjhb#define	LINUX_GETNCNT		14
70261268Sjhb#define	LINUX_GETZCNT		15
71261268Sjhb#define	LINUX_SETVAL		16
72261268Sjhb#define	LINUX_SETALL		17
73261268Sjhb#define	LINUX_SEM_STAT		18
74261268Sjhb#define	LINUX_SEM_INFO		19
75
76/*
77 * Version flags for semctl, msgctl, and shmctl commands
78 * These are passed as bitflags or-ed with the actual command
79 */
80#define	LINUX_IPC_OLD	0	/* Old version (no 32-bit UID support on many
81				   architectures) */
82#define	LINUX_IPC_64	0x0100	/* New version (support 32-bit UIDs, bigger
83				   message sizes, etc. */
84
85#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
86
87struct linux_msgctl_args
88{
89	l_int		msqid;
90	l_int		cmd;
91	struct l_msqid_ds *buf;
92};
93
94struct linux_msgget_args
95{
96	l_key_t		key;
97	l_int		msgflg;
98};
99
100struct linux_msgrcv_args
101{
102	l_int		msqid;
103	struct l_msgbuf *msgp;
104	l_size_t	msgsz;
105	l_long		msgtyp;
106	l_int		msgflg;
107};
108
109struct linux_msgsnd_args
110{
111	l_int		msqid;
112	struct l_msgbuf *msgp;
113	l_size_t	msgsz;
114	l_int		msgflg;
115};
116
117struct linux_semctl_args
118{
119	l_int		semid;
120	l_int		semnum;
121	l_int		cmd;
122	union l_semun	arg;
123};
124
125struct linux_semget_args
126{
127	l_key_t		key;
128	l_int		nsems;
129	l_int		semflg;
130};
131
132struct linux_semop_args
133{
134	l_int		semid;
135	struct l_sembuf *tsops;
136	l_uint		nsops;
137};
138
139struct linux_shmat_args
140{
141	l_int		shmid;
142	char		*shmaddr;
143	l_int		shmflg;
144	l_ulong		*raddr;
145};
146
147struct linux_shmctl_args
148{
149	l_int		shmid;
150	l_int		cmd;
151	struct l_shmid_ds *buf;
152};
153
154struct linux_shmdt_args
155{
156	char *shmaddr;
157};
158
159struct linux_shmget_args
160{
161	l_key_t		key;
162	l_size_t	size;
163	l_int		shmflg;
164};
165
166int linux_msgctl(struct thread *, struct linux_msgctl_args *);
167int linux_msgget(struct thread *, struct linux_msgget_args *);
168int linux_msgrcv(struct thread *, struct linux_msgrcv_args *);
169int linux_msgsnd(struct thread *, struct linux_msgsnd_args *);
170
171int linux_semctl(struct thread *, struct linux_semctl_args *);
172int linux_semget(struct thread *, struct linux_semget_args *);
173int linux_semop(struct thread *, struct linux_semop_args *);
174
175int linux_shmat(struct thread *, struct linux_shmat_args *);
176int linux_shmctl(struct thread *, struct linux_shmctl_args *);
177int linux_shmdt(struct thread *, struct linux_shmdt_args *);
178int linux_shmget(struct thread *, struct linux_shmget_args *);
179
180#endif	/* __i386__ || (__amd64__ && COMPAT_LINUX32) */
181
182#endif /* _LINUX_IPC_H_ */
183