xref: /third_party/ltp/include/lapi/msgbuf.h (revision f08c3bdf)
1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
2f08c3bdfSopenharmony_ci/*
3f08c3bdfSopenharmony_ci * Copyright (c) 2020 Linaro Limited. All rights reserved.
4f08c3bdfSopenharmony_ci * Author: Viresh Kumar <viresh.kumar@linaro.org>
5f08c3bdfSopenharmony_ci */
6f08c3bdfSopenharmony_ci
7f08c3bdfSopenharmony_ci#ifndef LAPI_MSGBUF_H__
8f08c3bdfSopenharmony_ci#define LAPI_MSGBUF_H__
9f08c3bdfSopenharmony_ci
10f08c3bdfSopenharmony_ci#include "lapi/posix_types.h"
11f08c3bdfSopenharmony_ci#include <sys/sem.h>
12f08c3bdfSopenharmony_ci#include "tst_timer.h"
13f08c3bdfSopenharmony_ci#include "ipcbuf.h"
14f08c3bdfSopenharmony_ci
15f08c3bdfSopenharmony_ci#ifndef HAVE_MSQID64_DS
16f08c3bdfSopenharmony_ci
17f08c3bdfSopenharmony_ci#if defined(__mips__)
18f08c3bdfSopenharmony_ci#define HAVE_MSQID64_DS
19f08c3bdfSopenharmony_ci
20f08c3bdfSopenharmony_ci#if __BITS_PER_LONG == 64
21f08c3bdfSopenharmony_ci/*
22f08c3bdfSopenharmony_ci * The msqid64_ds structure for the MIPS architecture.
23f08c3bdfSopenharmony_ci * Note extra padding because this structure is passed back and forth
24f08c3bdfSopenharmony_ci * between kernel and user space.
25f08c3bdfSopenharmony_ci *
26f08c3bdfSopenharmony_ci * Pad space is left for:
27f08c3bdfSopenharmony_ci * - 2 miscellaneous unsigned long values
28f08c3bdfSopenharmony_ci */
29f08c3bdfSopenharmony_ci
30f08c3bdfSopenharmony_cistruct msqid64_ds {
31f08c3bdfSopenharmony_ci	struct ipc64_perm msg_perm;
32f08c3bdfSopenharmony_ci	long msg_stime;			/* last msgsnd time */
33f08c3bdfSopenharmony_ci	long msg_rtime;			/* last msgrcv time */
34f08c3bdfSopenharmony_ci	long msg_ctime;			/* last change time */
35f08c3bdfSopenharmony_ci	unsigned long  msg_cbytes;	/* current number of bytes on queue */
36f08c3bdfSopenharmony_ci	unsigned long  msg_qnum;	/* number of messages in queue */
37f08c3bdfSopenharmony_ci	unsigned long  msg_qbytes;	/* max number of bytes on queue */
38f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lspid;	/* pid of last msgsnd */
39f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lrpid;	/* last receive pid */
40f08c3bdfSopenharmony_ci	unsigned long  __unused4;
41f08c3bdfSopenharmony_ci	unsigned long  __unused5;
42f08c3bdfSopenharmony_ci};
43f08c3bdfSopenharmony_ci#elif defined (__MIPSEB__)
44f08c3bdfSopenharmony_ci#define HAVE_MSQID64_DS_TIME_HIGH
45f08c3bdfSopenharmony_cistruct msqid64_ds {
46f08c3bdfSopenharmony_ci	struct ipc64_perm msg_perm;
47f08c3bdfSopenharmony_ci	unsigned long  msg_stime_high;
48f08c3bdfSopenharmony_ci	unsigned long  msg_stime;	/* last msgsnd time */
49f08c3bdfSopenharmony_ci	unsigned long  msg_rtime_high;
50f08c3bdfSopenharmony_ci	unsigned long  msg_rtime;	/* last msgrcv time */
51f08c3bdfSopenharmony_ci	unsigned long  msg_ctime_high;
52f08c3bdfSopenharmony_ci	unsigned long  msg_ctime;	/* last change time */
53f08c3bdfSopenharmony_ci	unsigned long  msg_cbytes;	/* current number of bytes on queue */
54f08c3bdfSopenharmony_ci	unsigned long  msg_qnum;	/* number of messages in queue */
55f08c3bdfSopenharmony_ci	unsigned long  msg_qbytes;	/* max number of bytes on queue */
56f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lspid;	/* pid of last msgsnd */
57f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lrpid;	/* last receive pid */
58f08c3bdfSopenharmony_ci	unsigned long  __unused4;
59f08c3bdfSopenharmony_ci	unsigned long  __unused5;
60f08c3bdfSopenharmony_ci};
61f08c3bdfSopenharmony_ci#elif defined (__MIPSEL__)
62f08c3bdfSopenharmony_ci#define HAVE_MSQID64_DS_TIME_HIGH
63f08c3bdfSopenharmony_cistruct msqid64_ds {
64f08c3bdfSopenharmony_ci	struct ipc64_perm msg_perm;
65f08c3bdfSopenharmony_ci	unsigned long  msg_stime;	/* last msgsnd time */
66f08c3bdfSopenharmony_ci	unsigned long  msg_stime_high;
67f08c3bdfSopenharmony_ci	unsigned long  msg_rtime;	/* last msgrcv time */
68f08c3bdfSopenharmony_ci	unsigned long  msg_rtime_high;
69f08c3bdfSopenharmony_ci	unsigned long  msg_ctime;	/* last change time */
70f08c3bdfSopenharmony_ci	unsigned long  msg_ctime_high;
71f08c3bdfSopenharmony_ci	unsigned long  msg_cbytes;	/* current number of bytes on queue */
72f08c3bdfSopenharmony_ci	unsigned long  msg_qnum;	/* number of messages in queue */
73f08c3bdfSopenharmony_ci	unsigned long  msg_qbytes;	/* max number of bytes on queue */
74f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lspid;	/* pid of last msgsnd */
75f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lrpid;	/* last receive pid */
76f08c3bdfSopenharmony_ci	unsigned long  __unused4;
77f08c3bdfSopenharmony_ci	unsigned long  __unused5;
78f08c3bdfSopenharmony_ci};
79f08c3bdfSopenharmony_ci#endif
80f08c3bdfSopenharmony_ci
81f08c3bdfSopenharmony_ci#endif /* __mips__ */
82f08c3bdfSopenharmony_ci
83f08c3bdfSopenharmony_ci#if defined(__hppa__)
84f08c3bdfSopenharmony_ci#define HAVE_MSQID64_DS
85f08c3bdfSopenharmony_ci/*
86f08c3bdfSopenharmony_ci * The msqid64_ds structure for parisc architecture, copied from sparc.
87f08c3bdfSopenharmony_ci * Note extra padding because this structure is passed back and forth
88f08c3bdfSopenharmony_ci * between kernel and user space.
89f08c3bdfSopenharmony_ci *
90f08c3bdfSopenharmony_ci * Pad space is left for:
91f08c3bdfSopenharmony_ci * - 2 miscellaneous 32-bit values
92f08c3bdfSopenharmony_ci */
93f08c3bdfSopenharmony_ci
94f08c3bdfSopenharmony_cistruct msqid64_ds {
95f08c3bdfSopenharmony_ci	struct ipc64_perm msg_perm;
96f08c3bdfSopenharmony_ci#if __BITS_PER_LONG == 64
97f08c3bdfSopenharmony_ci	long		 msg_stime;	/* last msgsnd time */
98f08c3bdfSopenharmony_ci	long		 msg_rtime;	/* last msgrcv time */
99f08c3bdfSopenharmony_ci	long		 msg_ctime;	/* last change time */
100f08c3bdfSopenharmony_ci#else
101f08c3bdfSopenharmony_ci#define HAVE_MSQID64_DS_TIME_HIGH
102f08c3bdfSopenharmony_ci	unsigned long	msg_stime_high;
103f08c3bdfSopenharmony_ci	unsigned long	msg_stime;	/* last msgsnd time */
104f08c3bdfSopenharmony_ci	unsigned long	msg_rtime_high;
105f08c3bdfSopenharmony_ci	unsigned long	msg_rtime;	/* last msgrcv time */
106f08c3bdfSopenharmony_ci	unsigned long	msg_ctime_high;
107f08c3bdfSopenharmony_ci	unsigned long	msg_ctime;	/* last change time */
108f08c3bdfSopenharmony_ci#endif
109f08c3bdfSopenharmony_ci	unsigned long	msg_cbytes;	/* current number of bytes on queue */
110f08c3bdfSopenharmony_ci	unsigned long	msg_qnum;	/* number of messages in queue */
111f08c3bdfSopenharmony_ci	unsigned long	msg_qbytes;	/* max number of bytes on queue */
112f08c3bdfSopenharmony_ci	__kernel_pid_t	msg_lspid;	/* pid of last msgsnd */
113f08c3bdfSopenharmony_ci	__kernel_pid_t	msg_lrpid;	/* last receive pid */
114f08c3bdfSopenharmony_ci	unsigned long	__unused1;
115f08c3bdfSopenharmony_ci	unsigned long	__unused2;
116f08c3bdfSopenharmony_ci};
117f08c3bdfSopenharmony_ci
118f08c3bdfSopenharmony_ci#endif /* __hppa__ */
119f08c3bdfSopenharmony_ci
120f08c3bdfSopenharmony_ci#if defined(__powerpc__) || defined(__powerpc64__)
121f08c3bdfSopenharmony_ci#define HAVE_MSQID64_DS
122f08c3bdfSopenharmony_ci/*
123f08c3bdfSopenharmony_ci * The msqid64_ds structure for the PowerPC architecture.
124f08c3bdfSopenharmony_ci * Note extra padding because this structure is passed back and forth
125f08c3bdfSopenharmony_ci * between kernel and user space.
126f08c3bdfSopenharmony_ci */
127f08c3bdfSopenharmony_ci
128f08c3bdfSopenharmony_cistruct msqid64_ds {
129f08c3bdfSopenharmony_ci	struct ipc64_perm msg_perm;
130f08c3bdfSopenharmony_ci#ifdef __powerpc64__
131f08c3bdfSopenharmony_ci	long		 msg_stime;	/* last msgsnd time */
132f08c3bdfSopenharmony_ci	long		 msg_rtime;	/* last msgrcv time */
133f08c3bdfSopenharmony_ci	long		 msg_ctime;	/* last change time */
134f08c3bdfSopenharmony_ci#else
135f08c3bdfSopenharmony_ci#define HAVE_MSQID64_DS_TIME_HIGH
136f08c3bdfSopenharmony_ci	unsigned long  msg_stime_high;
137f08c3bdfSopenharmony_ci	unsigned long  msg_stime;	/* last msgsnd time */
138f08c3bdfSopenharmony_ci	unsigned long  msg_rtime_high;
139f08c3bdfSopenharmony_ci	unsigned long  msg_rtime;	/* last msgrcv time */
140f08c3bdfSopenharmony_ci	unsigned long  msg_ctime_high;
141f08c3bdfSopenharmony_ci	unsigned long  msg_ctime;	/* last change time */
142f08c3bdfSopenharmony_ci#endif
143f08c3bdfSopenharmony_ci	unsigned long  msg_cbytes;	/* current number of bytes on queue */
144f08c3bdfSopenharmony_ci	unsigned long  msg_qnum;	/* number of messages in queue */
145f08c3bdfSopenharmony_ci	unsigned long  msg_qbytes;	/* max number of bytes on queue */
146f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lspid;	/* pid of last msgsnd */
147f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lrpid;	/* last receive pid */
148f08c3bdfSopenharmony_ci	unsigned long  __unused4;
149f08c3bdfSopenharmony_ci	unsigned long  __unused5;
150f08c3bdfSopenharmony_ci};
151f08c3bdfSopenharmony_ci
152f08c3bdfSopenharmony_ci#endif /* defined(__powerpc__) || defined(__powerpc64__) */
153f08c3bdfSopenharmony_ci
154f08c3bdfSopenharmony_ci#if defined(__sparc__)
155f08c3bdfSopenharmony_ci#define HAVE_MSQID64_DS
156f08c3bdfSopenharmony_ci/*
157f08c3bdfSopenharmony_ci * The msqid64_ds structure for sparc64 architecture.
158f08c3bdfSopenharmony_ci * Note extra padding because this structure is passed back and forth
159f08c3bdfSopenharmony_ci * between kernel and user space.
160f08c3bdfSopenharmony_ci *
161f08c3bdfSopenharmony_ci * Pad space is left for:
162f08c3bdfSopenharmony_ci * - 2 miscellaneous 32-bit values
163f08c3bdfSopenharmony_ci */
164f08c3bdfSopenharmony_cistruct msqid64_ds {
165f08c3bdfSopenharmony_ci	struct ipc64_perm msg_perm;
166f08c3bdfSopenharmony_ci#if defined(__arch64__)
167f08c3bdfSopenharmony_ci	long msg_stime;			/* last msgsnd time */
168f08c3bdfSopenharmony_ci	long msg_rtime;			/* last msgrcv time */
169f08c3bdfSopenharmony_ci	long msg_ctime;			/* last change time */
170f08c3bdfSopenharmony_ci#else
171f08c3bdfSopenharmony_ci#define HAVE_MSQID64_DS_TIME_HIGH
172f08c3bdfSopenharmony_ci	unsigned long msg_stime_high;
173f08c3bdfSopenharmony_ci	unsigned long msg_stime;	/* last msgsnd time */
174f08c3bdfSopenharmony_ci	unsigned long msg_rtime_high;
175f08c3bdfSopenharmony_ci	unsigned long msg_rtime;	/* last msgrcv time */
176f08c3bdfSopenharmony_ci	unsigned long msg_ctime_high;
177f08c3bdfSopenharmony_ci	unsigned long msg_ctime;	/* last change time */
178f08c3bdfSopenharmony_ci#endif
179f08c3bdfSopenharmony_ci	unsigned long  msg_cbytes;	/* current number of bytes on queue */
180f08c3bdfSopenharmony_ci	unsigned long  msg_qnum;	/* number of messages in queue */
181f08c3bdfSopenharmony_ci	unsigned long  msg_qbytes;	/* max number of bytes on queue */
182f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lspid;	/* pid of last msgsnd */
183f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lrpid;	/* last receive pid */
184f08c3bdfSopenharmony_ci	unsigned long  __unused1;
185f08c3bdfSopenharmony_ci	unsigned long  __unused2;
186f08c3bdfSopenharmony_ci};
187f08c3bdfSopenharmony_ci
188f08c3bdfSopenharmony_ci#endif /* __sparc__ */
189f08c3bdfSopenharmony_ci
190f08c3bdfSopenharmony_ci#if defined(__x86_64__) && defined(__ILP32__)
191f08c3bdfSopenharmony_ci#define HAVE_MSQID64_DS
192f08c3bdfSopenharmony_ci/*
193f08c3bdfSopenharmony_ci * The msqid64_ds structure for x86 architecture with x32 ABI.
194f08c3bdfSopenharmony_ci *
195f08c3bdfSopenharmony_ci * On x86-32 and x86-64 we can just use the generic definition, but
196f08c3bdfSopenharmony_ci * x32 uses the same binary layout as x86_64, which is differnet
197f08c3bdfSopenharmony_ci * from other 32-bit architectures.
198f08c3bdfSopenharmony_ci */
199f08c3bdfSopenharmony_ci
200f08c3bdfSopenharmony_cistruct msqid64_ds {
201f08c3bdfSopenharmony_ci	struct ipc64_perm msg_perm;
202f08c3bdfSopenharmony_ci	__kernel_long_t msg_stime;	/* last msgsnd time */
203f08c3bdfSopenharmony_ci	__kernel_long_t msg_rtime;	/* last msgrcv time */
204f08c3bdfSopenharmony_ci	__kernel_long_t msg_ctime;	/* last change time */
205f08c3bdfSopenharmony_ci	__kernel_ulong_t msg_cbytes;	/* current number of bytes on queue */
206f08c3bdfSopenharmony_ci	__kernel_ulong_t msg_qnum;	/* number of messages in queue */
207f08c3bdfSopenharmony_ci	__kernel_ulong_t msg_qbytes;	/* max number of bytes on queue */
208f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lspid;	/* pid of last msgsnd */
209f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lrpid;	/* last receive pid */
210f08c3bdfSopenharmony_ci	__kernel_ulong_t __unused4;
211f08c3bdfSopenharmony_ci	__kernel_ulong_t __unused5;
212f08c3bdfSopenharmony_ci};
213f08c3bdfSopenharmony_ci
214f08c3bdfSopenharmony_ci#endif /* defined(__x86_64__) && defined(__ILP32__) */
215f08c3bdfSopenharmony_ci
216f08c3bdfSopenharmony_ci#if defined(__xtensa__)
217f08c3bdfSopenharmony_ci#define HAVE_MSQID64_DS
218f08c3bdfSopenharmony_ci/*
219f08c3bdfSopenharmony_ci * The msqid64_ds structure for the Xtensa architecture.
220f08c3bdfSopenharmony_ci * Note extra padding because this structure is passed back and forth
221f08c3bdfSopenharmony_ci * between kernel and user space.
222f08c3bdfSopenharmony_ci *
223f08c3bdfSopenharmony_ci * Pad space is left for:
224f08c3bdfSopenharmony_ci * - 2 miscellaneous 32-bit values
225f08c3bdfSopenharmony_ci */
226f08c3bdfSopenharmony_ci
227f08c3bdfSopenharmony_cistruct msqid64_ds {
228f08c3bdfSopenharmony_ci	struct ipc64_perm msg_perm;
229f08c3bdfSopenharmony_ci#ifdef __XTENSA_EB__
230f08c3bdfSopenharmony_ci#define HAVE_MSQID64_DS_TIME_HIGH
231f08c3bdfSopenharmony_ci	unsigned long  msg_stime_high;
232f08c3bdfSopenharmony_ci	unsigned long  msg_stime;	/* last msgsnd time */
233f08c3bdfSopenharmony_ci	unsigned long  msg_rtime_high;
234f08c3bdfSopenharmony_ci	unsigned long  msg_rtime;	/* last msgrcv time */
235f08c3bdfSopenharmony_ci	unsigned long  msg_ctime_high;
236f08c3bdfSopenharmony_ci	unsigned long  msg_ctime;	/* last change time */
237f08c3bdfSopenharmony_ci#elif defined(__XTENSA_EL__)
238f08c3bdfSopenharmony_ci#define HAVE_MSQID64_DS_TIME_HIGH
239f08c3bdfSopenharmony_ci	unsigned long  msg_stime;	/* last msgsnd time */
240f08c3bdfSopenharmony_ci	unsigned long  msg_stime_high;
241f08c3bdfSopenharmony_ci	unsigned long  msg_rtime;	/* last msgrcv time */
242f08c3bdfSopenharmony_ci	unsigned long  msg_rtime_high;
243f08c3bdfSopenharmony_ci	unsigned long  msg_ctime;	/* last change time */
244f08c3bdfSopenharmony_ci	unsigned long  msg_ctime_high;
245f08c3bdfSopenharmony_ci#else
246f08c3bdfSopenharmony_ci# error processor byte order undefined!
247f08c3bdfSopenharmony_ci#endif
248f08c3bdfSopenharmony_ci	unsigned long  msg_cbytes;	/* current number of bytes on queue */
249f08c3bdfSopenharmony_ci	unsigned long  msg_qnum;	/* number of messages in queue */
250f08c3bdfSopenharmony_ci	unsigned long  msg_qbytes;	/* max number of bytes on queue */
251f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lspid;	/* pid of last msgsnd */
252f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lrpid;	/* last receive pid */
253f08c3bdfSopenharmony_ci	unsigned long  __unused4;
254f08c3bdfSopenharmony_ci	unsigned long  __unused5;
255f08c3bdfSopenharmony_ci};
256f08c3bdfSopenharmony_ci
257f08c3bdfSopenharmony_ci#endif /* __xtensa__ */
258f08c3bdfSopenharmony_ci
259f08c3bdfSopenharmony_ci#ifndef HAVE_MSQID64_DS
260f08c3bdfSopenharmony_ci/*
261f08c3bdfSopenharmony_ci * generic msqid64_ds structure.
262f08c3bdfSopenharmony_ci *
263f08c3bdfSopenharmony_ci * Note extra padding because this structure is passed back and forth
264f08c3bdfSopenharmony_ci * between kernel and user space.
265f08c3bdfSopenharmony_ci *
266f08c3bdfSopenharmony_ci * msqid64_ds was originally meant to be architecture specific, but
267f08c3bdfSopenharmony_ci * everyone just ended up making identical copies without specific
268f08c3bdfSopenharmony_ci * optimizations, so we may just as well all use the same one.
269f08c3bdfSopenharmony_ci *
270f08c3bdfSopenharmony_ci * 64 bit architectures use a 64-bit long time field here, while
271f08c3bdfSopenharmony_ci * 32 bit architectures have a pair of unsigned long values.
272f08c3bdfSopenharmony_ci * On big-endian systems, the lower half is in the wrong place.
273f08c3bdfSopenharmony_ci *
274f08c3bdfSopenharmony_ci * Pad space is left for:
275f08c3bdfSopenharmony_ci * - 2 miscellaneous 32-bit values
276f08c3bdfSopenharmony_ci */
277f08c3bdfSopenharmony_ci
278f08c3bdfSopenharmony_cistruct msqid64_ds {
279f08c3bdfSopenharmony_ci	struct ipc64_perm msg_perm;
280f08c3bdfSopenharmony_ci#if __BITS_PER_LONG == 64
281f08c3bdfSopenharmony_ci	long		 msg_stime;	/* last msgsnd time */
282f08c3bdfSopenharmony_ci	long		 msg_rtime;	/* last msgrcv time */
283f08c3bdfSopenharmony_ci	long		 msg_ctime;	/* last change time */
284f08c3bdfSopenharmony_ci#else
285f08c3bdfSopenharmony_ci#define HAVE_MSQID64_DS_TIME_HIGH
286f08c3bdfSopenharmony_ci	unsigned long	msg_stime;	/* last msgsnd time */
287f08c3bdfSopenharmony_ci	unsigned long	msg_stime_high;
288f08c3bdfSopenharmony_ci	unsigned long	msg_rtime;	/* last msgrcv time */
289f08c3bdfSopenharmony_ci	unsigned long	msg_rtime_high;
290f08c3bdfSopenharmony_ci	unsigned long	msg_ctime;	/* last change time */
291f08c3bdfSopenharmony_ci	unsigned long	msg_ctime_high;
292f08c3bdfSopenharmony_ci#endif
293f08c3bdfSopenharmony_ci	unsigned long	msg_cbytes;	/* current number of bytes on queue */
294f08c3bdfSopenharmony_ci	unsigned long	msg_qnum;	/* number of messages in queue */
295f08c3bdfSopenharmony_ci	unsigned long	 msg_qbytes;	/* max number of bytes on queue */
296f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lspid;	/* pid of last msgsnd */
297f08c3bdfSopenharmony_ci	__kernel_pid_t msg_lrpid;	/* last receive pid */
298f08c3bdfSopenharmony_ci	unsigned long	 __unused4;
299f08c3bdfSopenharmony_ci	unsigned long	 __unused5;
300f08c3bdfSopenharmony_ci};
301f08c3bdfSopenharmony_ci
302f08c3bdfSopenharmony_ci#endif /* msqid64_ds */
303f08c3bdfSopenharmony_ci
304f08c3bdfSopenharmony_ci#endif /* HAVE_MSQID64_DS */
305f08c3bdfSopenharmony_ci
306f08c3bdfSopenharmony_ci#endif /* LAPI_MSGBUF_H__ */
307