1 /*
2 * Copyright (c) 2003 Roland McGrath <roland@redhat.com>
3 * Copyright (c) 2003-2022 The strace developers.
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: LGPL-2.1-or-later
7 */
8
9 #ifndef STRACE_IPC_DEFS_H
10 # define STRACE_IPC_DEFS_H
11
12 # ifdef HAVE_LINUX_IPC_H
13 # if defined MPERS_IS_m32
14 # if defined ARCH_M32_SIZEOF_STRUCT_MSQID64_DS && \
15 defined M32_SIZEOF_STRUCT_MSQID64_DS && \
16 ARCH_M32_SIZEOF_STRUCT_MSQID64_DS != M32_SIZEOF_STRUCT_MSQID64_DS
17 # undef HAVE_LINUX_IPC_H
18 # endif
19 # elif defined MPERS_IS_mx32
20 # if defined ARCH_MX32_SIZEOF_STRUCT_MSQID64_DS && \
21 defined MX32_SIZEOF_STRUCT_MSQID64_DS && \
22 ARCH_MX32_SIZEOF_STRUCT_MSQID64_DS != MX32_SIZEOF_STRUCT_MSQID64_DS
23 # undef HAVE_LINUX_IPC_H
24 # endif
25 # else /* !IN_MPERS */
26 # if defined ARCH_SIZEOF_STRUCT_MSQID64_DS && \
27 defined SIZEOF_STRUCT_MSQID64_DS && \
28 ARCH_SIZEOF_STRUCT_MSQID64_DS != SIZEOF_STRUCT_MSQID64_DS
29 # undef HAVE_LINUX_IPC_H
30 # endif
31 # endif
32 # endif /* HAVE_LINUX_IPC_H */
33
34 # if defined HAVE_LINUX_IPC_H
35 # include <linux/ipc.h>
36 # define MSG_H_PROVIDER "linux/msg.h"
37 # define SEM_H_PROVIDER "linux/sem.h"
38 # define SHM_H_PROVIDER "linux/shm.h"
39 # define NAME_OF_STRUCT_MSQID_DS msqid64_ds
40 # define NAME_OF_STRUCT_SEMID_DS semid64_ds
41 # define NAME_OF_STRUCT_SHMID_DS shmid64_ds
42 # define NAME_OF_STRUCT_SHMINFO shminfo64
43 # define NAME_OF_STRUCT_IPC_PERM_KEY key
44 # elif defined HAVE_SYS_IPC_H
45 # include <sys/ipc.h>
46 # define MSG_H_PROVIDER "sys/msg.h"
47 # define SEM_H_PROVIDER "sys/sem.h"
48 # define SHM_H_PROVIDER "sys/shm.h"
49 # define NAME_OF_STRUCT_MSQID_DS msqid_ds
50 # define NAME_OF_STRUCT_SEMID_DS semid_ds
51 # define NAME_OF_STRUCT_SHMID_DS shmid_ds
52 # define NAME_OF_STRUCT_SHMINFO shminfo
53 # define NAME_OF_STRUCT_IPC_PERM_KEY __key
54 # else
55 # error Neither <sys/ipc.h> nor <linux/ipc.h> is available
56 # endif
57
58 # if !defined IPC_64
59 # define IPC_64 0x100
60 # endif
61
62 # define PRINTCTL(flagset, arg, dflt) \
63 do { \
64 tprint_flags_begin(); \
65 if ((arg) & IPC_64) { \
66 print_xlat(IPC_64); \
67 tprint_flags_or(); \
68 } \
69 printxval((flagset), (arg) & ~IPC_64, dflt); \
70 tprint_flags_end(); \
71 } while (0)
72
73 #endif /* !STRACE_IPC_DEFS_H */