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