x86: Check RTM_ALWAYS_ABORT for RTM [BZ #28033]
[glibc.git] / sysvipc / test-sysvipc.h
blobed0057b7871e505c53ae07d4cac347eed1a8894f
1 /* Basic definition for Sysv IPC test functions.
2 Copyright (C) 2020-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #ifndef _TEST_SYSV_H
20 #define _TEST_SYSV_H
22 #include <sys/ipc.h>
23 #include <sys/sem.h>
24 #include <sys/msg.h>
25 #include <sys/shm.h>
26 #include <include/array_length.h>
28 /* Return the first invalid SysV IPC command from common shared
29 between message queue, shared memory, and semaphore. */
30 static inline int
31 first_common_invalid_cmd (void)
33 const int common_cmds[] = {
34 IPC_RMID,
35 IPC_SET,
36 IPC_STAT,
37 IPC_INFO,
40 int invalid = 0;
41 for (int i = 0; i < array_length (common_cmds); i++)
43 if (invalid == common_cmds[i])
45 invalid++;
46 i = 0;
50 return invalid;
53 /* Return the first invalid SysV IPC command for semaphore. */
54 static inline int
55 first_sem_invalid_cmd (void)
57 const int sem_cmds[] = {
58 GETPID,
59 GETVAL,
60 GETALL,
61 GETNCNT,
62 GETZCNT,
63 SETVAL,
64 SETALL,
65 SEM_STAT,
66 SEM_INFO,
67 #ifdef SEM_STAT_ANY
68 SEM_STAT_ANY,
69 #endif
72 int invalid = first_common_invalid_cmd ();
73 for (int i = 0; i < array_length (sem_cmds); i++)
75 if (invalid == sem_cmds[i])
77 invalid++;
78 i = 0;
82 return invalid;
85 /* Return the first invalid SysV IPC command for message queue. */
86 static inline int
87 first_msg_invalid_cmd (void)
89 const int msg_cmds[] = {
90 MSG_STAT,
91 MSG_INFO,
92 #ifdef MSG_STAT_ANY
93 MSG_STAT_ANY,
94 #endif
97 int invalid = first_common_invalid_cmd ();
98 for (int i = 0; i < array_length (msg_cmds); i++)
100 if (invalid == msg_cmds[i])
102 invalid++;
103 i = 0;
107 return invalid;
110 /* Return the first invalid SysV IPC command for shared memory. */
111 static inline int
112 first_shm_invalid_cmd (void)
114 const int shm_cmds[] = {
115 SHM_STAT,
116 SHM_INFO,
117 #ifdef SHM_STAT_ANY
118 SHM_STAT_ANY,
119 #endif
120 SHM_LOCK,
121 SHM_UNLOCK
124 int invalid = first_common_invalid_cmd ();
125 for (int i = 0; i < array_length (shm_cmds); i++)
127 if (invalid == shm_cmds[i])
129 invalid++;
130 i = 0;
134 return invalid;
137 #endif /* _TEST_SYSV_H */