plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright (c) International Business Machines Corp., 2001 |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program 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 |
| 13 | * the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
Wanlong Gao | 4548c6c | 2012-10-19 18:03:36 +0800 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | /* |
| 21 | * ipcmsg.h - common definitions for the IPC message tests. |
| 22 | */ |
| 23 | |
| 24 | #ifndef __IPCMSG_H |
| 25 | #define __IPCMSG_H 1 |
| 26 | |
| 27 | #include <errno.h> |
| 28 | #include <sys/ipc.h> |
| 29 | #include <sys/msg.h> |
Garrett Cooper | 7aa9dbd | 2010-09-06 23:04:20 -0700 | [diff] [blame] | 30 | #include <sys/types.h> |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 31 | |
| 32 | #include "test.h" |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 33 | |
| 34 | void cleanup(void); |
| 35 | void setup(void); |
| 36 | |
| 37 | #define MSG_RD 0400 /* read permission for the queue */ |
| 38 | #define MSG_WR 0200 /* write permission for the queue */ |
| 39 | #define MSG_RW MSG_RD | MSG_WR |
| 40 | |
| 41 | #define MSGSIZE 1024 /* a resonable size for a message */ |
| 42 | #define MSGTYPE 1 /* a type ID for a message */ |
| 43 | |
subrata_modak | 5b69374 | 2008-02-22 08:33:53 +0000 | [diff] [blame] | 44 | #define NR_MSGQUEUES 16 /* MSGMNI as defined in linux/msg.h */ |
| 45 | |
| 46 | #define min(a, b) (((a) < (b)) ? (a) : (b)) |
subrata_modak | 440341b | 2008-02-20 09:40:48 +0000 | [diff] [blame] | 47 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 48 | typedef struct mbuf { /* a generic message structure */ |
| 49 | long mtype; |
| 50 | char mtext[MSGSIZE + 1]; /* add 1 here so the message can be 1024 */ |
| 51 | } MSGBUF; /* characters long with a '\0' termination */ |
| 52 | |
subrata_modak | 104a4d9 | 2008-03-24 08:29:39 +0000 | [diff] [blame] | 53 | #ifdef LIBIPC |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 54 | key_t msgkey; /* the ftok() generated message key */ |
robbiew | 6eaecb2 | 2005-12-22 20:18:22 +0000 | [diff] [blame] | 55 | #else |
| 56 | extern key_t msgkey; /* the ftok() generated message key */ |
| 57 | #endif |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 58 | |
robbiew | 23499f0 | 2002-11-18 19:54:58 +0000 | [diff] [blame] | 59 | void init_buf(MSGBUF *, int, int); |
| 60 | void rm_queue(int); |
| 61 | |
Garrett Cooper | 7aa9dbd | 2010-09-06 23:04:20 -0700 | [diff] [blame] | 62 | key_t getipckey(); |
robbiew | 23499f0 | 2002-11-18 19:54:58 +0000 | [diff] [blame] | 63 | int getuserid(char *); |
| 64 | |
subrata_modak | 5b69374 | 2008-02-22 08:33:53 +0000 | [diff] [blame] | 65 | int get_max_msgqueues(void); |
| 66 | int get_used_msgqueues(void); |
| 67 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 68 | #endif /* ipcmsg.h */ |