blob: e01957f7502d3a6b206835549c403cb70a5d3874 [file] [log] [blame]
Xiao Yang004f2142017-01-23 18:31:14 +08001/*
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
Xiao Yangfed008c2017-06-01 19:49:11 +080021#include <sys/types.h>
22#include <sys/ipc.h>
23#include <sys/msg.h>
24#include <sys/shm.h>
25
Xiao Yang004f2142017-01-23 18:31:14 +080026int safe_msgget(const char *file, const int lineno, key_t key, int msgflg);
27#define SAFE_MSGGET(key, msgflg) \
28 safe_msgget(__FILE__, __LINE__, (key), (msgflg))
29
30int safe_msgsnd(const char *file, const int lineno, int msqid, const void *msgp,
31 size_t msgsz, int msgflg);
32#define SAFE_MSGSND(msqid, msgp, msgsz, msgflg) \
33 safe_msgsnd(__FILE__, __LINE__, (msqid), (msgp), (msgsz), (msgflg))
34
35ssize_t safe_msgrcv(const char *file, const int lineno, int msqid, void *msgp,
36 size_t msgsz, long msgtyp, int msgflg);
37#define SAFE_MSGRCV(msqid, msgp, msgsz, msgtyp, msgflg) \
38 safe_msgrcv(__FILE__, __LINE__, (msqid), (msgp), (msgsz), (msgtyp), (msgflg))
39
40int safe_msgctl(const char *file, const int lineno, int msqid, int cmd,
41 struct msqid_ds *buf);
Cyril Hrubised8e0672017-01-23 15:13:23 +010042#define SAFE_MSGCTL(msqid, cmd, buf) do { \
43 safe_msgctl(__FILE__, __LINE__, (msqid), (cmd), (buf)); \
44 (msqid) = ((cmd) == IPC_RMID ? -1 : (msqid)); \
45 } while (0)
Xiao Yang004f2142017-01-23 18:31:14 +080046
Xiao Yangfed008c2017-06-01 19:49:11 +080047int safe_shmget(const char *file, const int lineno, key_t key, size_t size,
48 int shmflg);
49#define SAFE_SHMGET(key, size, shmflg) \
50 safe_shmget(__FILE__, __LINE__, (key), (size), (shmflg))
51
52void *safe_shmat(const char *file, const int lineno, int shmid,
53 const void *shmaddr, int shmflg);
54#define SAFE_SHMAT(shmid, shmaddr, shmflg) \
55 safe_shmat(__FILE__, __LINE__, (shmid), (shmaddr), (shmflg))
56
57int safe_shmdt(const char *file, const int lineno, const void *shmaddr);
58#define SAFE_SHMDT(shmaddr) safe_shmdt(__FILE__, __LINE__, (shmaddr))
59
60int safe_shmctl(const char *file, const int lineno, int shmid, int cmd,
61 struct shmid_ds *buf);
62#define SAFE_SHMCTL(shmid, cmd, buf) do { \
63 safe_shmctl(__FILE__, __LINE__, (shmid), (cmd), (buf)); \
64 (shmid) = ((cmd) == IPC_RMID ? -1 : (shmid)); \
65 } while (0)
66
Xiao Yang004f2142017-01-23 18:31:14 +080067#endif /* TST_SAFE_SYSV_IPC_H__ */