David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 1 | #ifndef _UAPI_LINUX_MSG_H |
| 2 | #define _UAPI_LINUX_MSG_H |
| 3 | |
| 4 | #include <linux/ipc.h> |
| 5 | |
| 6 | /* ipcs ctl commands */ |
| 7 | #define MSG_STAT 11 |
| 8 | #define MSG_INFO 12 |
| 9 | |
| 10 | /* msgrcv options */ |
| 11 | #define MSG_NOERROR 010000 /* no error if message is too big */ |
| 12 | #define MSG_EXCEPT 020000 /* recv any msg except of specified type.*/ |
Stanislav Kinsbursky | 4a674f3 | 2013-01-04 15:34:55 -0800 | [diff] [blame] | 13 | #define MSG_COPY 040000 /* copy (not remove) all queue messages */ |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 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 { |
H.J. Lu | 443d567 | 2013-12-27 14:14:20 -0800 | [diff] [blame] | 37 | __kernel_long_t mtype; /* type of message */ |
| 38 | char mtext[1]; /* message text */ |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 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 | /* |
Manfred Spraul | 0050ee0 | 2014-12-12 16:58:17 -0800 | [diff] [blame] | 54 | * MSGMNI, MSGMAX and MSGMNB are default values which can be |
| 55 | * modified by sysctl. |
| 56 | * |
| 57 | * MSGMNI is the upper limit for the number of messages queues per |
| 58 | * namespace. |
| 59 | * It has been chosen to be as large possible without facilitating |
| 60 | * scenarios where userspace causes overflows when adjusting the limits via |
| 61 | * operations of the form retrieve current limit; add X; update limit". |
| 62 | * |
| 63 | * MSGMNB is the default size of a new message queue. Non-root tasks can |
| 64 | * decrease the size with msgctl(IPC_SET), root tasks |
| 65 | * (actually: CAP_SYS_RESOURCE) can both increase and decrease the queue |
| 66 | * size. The optimal value is application dependent. |
| 67 | * 16384 is used because it was always used (since 0.99.10) |
| 68 | * |
| 69 | * MAXMAX is the maximum size of an individual message, it's a global |
| 70 | * (per-namespace) limit that applies for all message queues. |
| 71 | * It's set to 1/2 of MSGMNB, to ensure that at least two messages fit into |
| 72 | * the queue. This is also an arbitrary choice (since 2.6.0). |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 73 | */ |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 74 | |
Manfred Spraul | 0050ee0 | 2014-12-12 16:58:17 -0800 | [diff] [blame] | 75 | #define MSGMNI 32000 /* <= IPCMNI */ /* max # of msg queue identifiers */ |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 76 | #define MSGMAX 8192 /* <= INT_MAX */ /* max size of message (bytes) */ |
| 77 | #define MSGMNB 16384 /* <= INT_MAX */ /* default max size of a message queue */ |
| 78 | |
| 79 | /* unused */ |
| 80 | #define MSGPOOL (MSGMNI * MSGMNB / 1024) /* size in kbytes of message pool */ |
| 81 | #define MSGTQL MSGMNB /* number of system message headers */ |
| 82 | #define MSGMAP MSGMNB /* number of entries in message map */ |
| 83 | #define MSGSSZ 16 /* message segment size */ |
| 84 | #define __MSGSEG ((MSGPOOL * 1024) / MSGSSZ) /* max no. of segments */ |
| 85 | #define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff) |
| 86 | |
| 87 | |
| 88 | #endif /* _UAPI_LINUX_MSG_H */ |