• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2017 Xiao yang <yangx.jy@cn.fujitsu.com>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef TST_SAFE_SYSV_IPC_H__
19 #define TST_SAFE_SYSV_IPC_H__
20 
21 int safe_msgget(const char *file, const int lineno, key_t key, int msgflg);
22 #define SAFE_MSGGET(key, msgflg) \
23 	safe_msgget(__FILE__, __LINE__, (key), (msgflg))
24 
25 int safe_msgsnd(const char *file, const int lineno, int msqid, const void *msgp,
26 		size_t msgsz, int msgflg);
27 #define SAFE_MSGSND(msqid, msgp, msgsz, msgflg) \
28 	safe_msgsnd(__FILE__, __LINE__, (msqid), (msgp), (msgsz), (msgflg))
29 
30 ssize_t safe_msgrcv(const char *file, const int lineno, int msqid, void *msgp,
31 		size_t msgsz, long msgtyp, int msgflg);
32 #define SAFE_MSGRCV(msqid, msgp, msgsz, msgtyp, msgflg) \
33 	safe_msgrcv(__FILE__, __LINE__, (msqid), (msgp), (msgsz), (msgtyp), (msgflg))
34 
35 int safe_msgctl(const char *file, const int lineno, int msqid, int cmd,
36 		struct msqid_ds *buf);
37 #define SAFE_MSGCTL(msqid, cmd, buf) do { \
38 	safe_msgctl(__FILE__, __LINE__, (msqid), (cmd), (buf)); \
39 	(msqid) = ((cmd) == IPC_RMID ? -1 : (msqid)); \
40 	} while (0)
41 
42 #endif /* TST_SAFE_SYSV_IPC_H__ */
43