Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_MSG_H |
| 2 | #define _LINUX_MSG_H |
| 3 | |
| 4 | #include <linux/ipc.h> |
| 5 | #include <linux/list.h> |
| 6 | |
| 7 | /* ipcs ctl commands */ |
| 8 | #define MSG_STAT 11 |
| 9 | #define MSG_INFO 12 |
| 10 | |
| 11 | /* msgrcv options */ |
| 12 | #define MSG_NOERROR 010000 /* no error if message is too big */ |
| 13 | #define MSG_EXCEPT 020000 /* recv any msg except of specified type.*/ |
| 14 | |
| 15 | /* Obsolete, used only for backwards compatibility and libc5 compiles */ |
| 16 | struct msqid_ds { |
| 17 | struct ipc_perm msg_perm; |
| 18 | struct msg *msg_first; /* first message on queue,unused */ |
| 19 | struct msg *msg_last; /* last message in queue,unused */ |
| 20 | __kernel_time_t msg_stime; /* last msgsnd time */ |
| 21 | __kernel_time_t msg_rtime; /* last msgrcv time */ |
| 22 | __kernel_time_t msg_ctime; /* last change time */ |
| 23 | unsigned long msg_lcbytes; /* Reuse junk fields for 32 bit */ |
| 24 | unsigned long msg_lqbytes; /* ditto */ |
| 25 | unsigned short msg_cbytes; /* current number of bytes on queue */ |
| 26 | unsigned short msg_qnum; /* number of messages in queue */ |
| 27 | unsigned short msg_qbytes; /* max number of bytes on queue */ |
| 28 | __kernel_ipc_pid_t msg_lspid; /* pid of last msgsnd */ |
| 29 | __kernel_ipc_pid_t msg_lrpid; /* last receive pid */ |
| 30 | }; |
| 31 | |
| 32 | /* Include the definition of msqid64_ds */ |
| 33 | #include <asm/msgbuf.h> |
| 34 | |
| 35 | /* message buffer for msgsnd and msgrcv calls */ |
| 36 | struct msgbuf { |
| 37 | long mtype; /* type of message */ |
| 38 | char mtext[1]; /* message text */ |
| 39 | }; |
| 40 | |
| 41 | /* buffer for msgctl calls IPC_INFO, MSG_INFO */ |
| 42 | struct msginfo { |
| 43 | int msgpool; |
| 44 | int msgmap; |
| 45 | int msgmax; |
| 46 | int msgmnb; |
| 47 | int msgmni; |
| 48 | int msgssz; |
| 49 | int msgtql; |
| 50 | unsigned short msgseg; |
| 51 | }; |
| 52 | |
| 53 | #define MSGMNI 16 /* <= IPCMNI */ /* max # of msg queue identifiers */ |
| 54 | #define MSGMAX 8192 /* <= INT_MAX */ /* max size of message (bytes) */ |
| 55 | #define MSGMNB 16384 /* <= INT_MAX */ /* default max size of a message queue */ |
| 56 | |
| 57 | /* unused */ |
| 58 | #define MSGPOOL (MSGMNI*MSGMNB/1024) /* size in kilobytes of message pool */ |
| 59 | #define MSGTQL MSGMNB /* number of system message headers */ |
| 60 | #define MSGMAP MSGMNB /* number of entries in message map */ |
| 61 | #define MSGSSZ 16 /* message segment size */ |
| 62 | #define __MSGSEG ((MSGPOOL*1024)/ MSGSSZ) /* max no. of segments */ |
| 63 | #define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff) |
| 64 | |
| 65 | #ifdef __KERNEL__ |
| 66 | |
| 67 | /* one msg_msg structure for each message */ |
| 68 | struct msg_msg { |
| 69 | struct list_head m_list; |
| 70 | long m_type; |
| 71 | int m_ts; /* message text size */ |
| 72 | struct msg_msgseg* next; |
| 73 | void *security; |
| 74 | /* the actual message follows immediately */ |
| 75 | }; |
| 76 | |
| 77 | /* one msq_queue structure for each present queue on the system */ |
| 78 | struct msg_queue { |
| 79 | struct kern_ipc_perm q_perm; |
Mike Waychison | 19b4946 | 2005-09-06 15:17:10 -0700 | [diff] [blame^] | 80 | int q_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | time_t q_stime; /* last msgsnd time */ |
| 82 | time_t q_rtime; /* last msgrcv time */ |
| 83 | time_t q_ctime; /* last change time */ |
| 84 | unsigned long q_cbytes; /* current number of bytes on queue */ |
| 85 | unsigned long q_qnum; /* number of messages in queue */ |
| 86 | unsigned long q_qbytes; /* max number of bytes on queue */ |
| 87 | pid_t q_lspid; /* pid of last msgsnd */ |
| 88 | pid_t q_lrpid; /* last receive pid */ |
| 89 | |
| 90 | struct list_head q_messages; |
| 91 | struct list_head q_receivers; |
| 92 | struct list_head q_senders; |
| 93 | }; |
| 94 | |
| 95 | #endif /* __KERNEL__ */ |
| 96 | |
| 97 | #endif /* _LINUX_MSG_H */ |