• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016 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
12  * the 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.
16  */
17 
18 /*
19  * common definitions for the IPC system calls.
20  */
21 
22 #ifndef __LIBNEWIPC_H
23 #define __LIBNEWIPC_H	1
24 
25 #include <time.h>
26 #include <sys/types.h>
27 
28 #define MSG_RD	0400
29 #define MSG_WR	0200
30 #define MSG_RW	(MSG_RD | MSG_WR)
31 #define MSGSIZE	1024
32 #define MSGTYPE	1
33 #define NR_MSGQUEUES	16
34 #define min(a, b)	(((a) < (b)) ? (a) : (b))
35 
36 #define SEM_RD	0400
37 #define SEM_ALT	0200
38 #define SEM_RA	(SEM_RD | SEM_ALT)
39 #define PSEMS	10
40 
41 #define SHM_RD	0400
42 #define SHM_WR	0200
43 #define SHM_RW	(SHM_RD | SHM_WR)
44 #define SHM_SIZE	2048
45 #define INT_SIZE	4
46 #define MODE_MASK	0x01FF
47 
48 key_t getipckey(const char *file, const int lineno);
49 #define GETIPCKEY() \
50 	getipckey(__FILE__, __LINE__)
51 
52 int get_used_sysvipc(const char *file, const int lineno, const char *sysvipc_file);
53 #define GET_USED_QUEUES() \
54 	get_used_sysvipc(__FILE__, __LINE__, "/proc/sysvipc/msg")
55 #define GET_USED_SEGMENTS() \
56 	get_used_sysvipc(__FILE__, __LINE__, "/proc/sysvipc/shm")
57 
58 void *probe_free_addr(const char *file, const int lineno);
59 #define PROBE_FREE_ADDR() \
60 	probe_free_addr(__FILE__, __LINE__)
61 
62 #endif /* newlibipc.h */
63