xref: /linux-6.15/include/uapi/linux/msg.h (revision 0050ee05)
1607ca46eSDavid Howells #ifndef _UAPI_LINUX_MSG_H
2607ca46eSDavid Howells #define _UAPI_LINUX_MSG_H
3607ca46eSDavid Howells 
4607ca46eSDavid Howells #include <linux/ipc.h>
5607ca46eSDavid Howells 
6607ca46eSDavid Howells /* ipcs ctl commands */
7607ca46eSDavid Howells #define MSG_STAT 11
8607ca46eSDavid Howells #define MSG_INFO 12
9607ca46eSDavid Howells 
10607ca46eSDavid Howells /* msgrcv options */
11607ca46eSDavid Howells #define MSG_NOERROR     010000  /* no error if message is too big */
12607ca46eSDavid Howells #define MSG_EXCEPT      020000  /* recv any msg except of specified type.*/
134a674f34SStanislav Kinsbursky #define MSG_COPY        040000  /* copy (not remove) all queue messages */
14607ca46eSDavid Howells 
15607ca46eSDavid Howells /* Obsolete, used only for backwards compatibility and libc5 compiles */
16607ca46eSDavid Howells struct msqid_ds {
17607ca46eSDavid Howells 	struct ipc_perm msg_perm;
18607ca46eSDavid Howells 	struct msg *msg_first;		/* first message on queue,unused  */
19607ca46eSDavid Howells 	struct msg *msg_last;		/* last message in queue,unused */
20607ca46eSDavid Howells 	__kernel_time_t msg_stime;	/* last msgsnd time */
21607ca46eSDavid Howells 	__kernel_time_t msg_rtime;	/* last msgrcv time */
22607ca46eSDavid Howells 	__kernel_time_t msg_ctime;	/* last change time */
23607ca46eSDavid Howells 	unsigned long  msg_lcbytes;	/* Reuse junk fields for 32 bit */
24607ca46eSDavid Howells 	unsigned long  msg_lqbytes;	/* ditto */
25607ca46eSDavid Howells 	unsigned short msg_cbytes;	/* current number of bytes on queue */
26607ca46eSDavid Howells 	unsigned short msg_qnum;	/* number of messages in queue */
27607ca46eSDavid Howells 	unsigned short msg_qbytes;	/* max number of bytes on queue */
28607ca46eSDavid Howells 	__kernel_ipc_pid_t msg_lspid;	/* pid of last msgsnd */
29607ca46eSDavid Howells 	__kernel_ipc_pid_t msg_lrpid;	/* last receive pid */
30607ca46eSDavid Howells };
31607ca46eSDavid Howells 
32607ca46eSDavid Howells /* Include the definition of msqid64_ds */
33607ca46eSDavid Howells #include <asm/msgbuf.h>
34607ca46eSDavid Howells 
35607ca46eSDavid Howells /* message buffer for msgsnd and msgrcv calls */
36607ca46eSDavid Howells struct msgbuf {
37443d5670SH.J. Lu 	__kernel_long_t mtype;          /* type of message */
38607ca46eSDavid Howells 	char mtext[1];                  /* message text */
39607ca46eSDavid Howells };
40607ca46eSDavid Howells 
41607ca46eSDavid Howells /* buffer for msgctl calls IPC_INFO, MSG_INFO */
42607ca46eSDavid Howells struct msginfo {
43607ca46eSDavid Howells 	int msgpool;
44607ca46eSDavid Howells 	int msgmap;
45607ca46eSDavid Howells 	int msgmax;
46607ca46eSDavid Howells 	int msgmnb;
47607ca46eSDavid Howells 	int msgmni;
48607ca46eSDavid Howells 	int msgssz;
49607ca46eSDavid Howells 	int msgtql;
50607ca46eSDavid Howells 	unsigned short  msgseg;
51607ca46eSDavid Howells };
52607ca46eSDavid Howells 
53607ca46eSDavid Howells /*
54*0050ee05SManfred Spraul  * MSGMNI, MSGMAX and MSGMNB are default values which can be
55*0050ee05SManfred Spraul  * modified by sysctl.
56*0050ee05SManfred Spraul  *
57*0050ee05SManfred Spraul  * MSGMNI is the upper limit for the number of messages queues per
58*0050ee05SManfred Spraul  * namespace.
59*0050ee05SManfred Spraul  * It has been chosen to be as large possible without facilitating
60*0050ee05SManfred Spraul  * scenarios where userspace causes overflows when adjusting the limits via
61*0050ee05SManfred Spraul  * operations of the form retrieve current limit; add X; update limit".
62*0050ee05SManfred Spraul  *
63*0050ee05SManfred Spraul  * MSGMNB is the default size of a new message queue. Non-root tasks can
64*0050ee05SManfred Spraul  * decrease the size with msgctl(IPC_SET), root tasks
65*0050ee05SManfred Spraul  * (actually: CAP_SYS_RESOURCE) can both increase and decrease the queue
66*0050ee05SManfred Spraul  * size. The optimal value is application dependent.
67*0050ee05SManfred Spraul  * 16384 is used because it was always used (since 0.99.10)
68*0050ee05SManfred Spraul  *
69*0050ee05SManfred Spraul  * MAXMAX is the maximum size of an individual message, it's a global
70*0050ee05SManfred Spraul  * (per-namespace) limit that applies for all message queues.
71*0050ee05SManfred Spraul  * It's set to 1/2 of MSGMNB, to ensure that at least two messages fit into
72*0050ee05SManfred Spraul  * the queue. This is also an arbitrary choice (since 2.6.0).
73607ca46eSDavid Howells  */
74607ca46eSDavid Howells 
75*0050ee05SManfred Spraul #define MSGMNI 32000   /* <= IPCMNI */     /* max # of msg queue identifiers */
76607ca46eSDavid Howells #define MSGMAX  8192   /* <= INT_MAX */   /* max size of message (bytes) */
77607ca46eSDavid Howells #define MSGMNB 16384   /* <= INT_MAX */   /* default max size of a message queue */
78607ca46eSDavid Howells 
79607ca46eSDavid Howells /* unused */
80607ca46eSDavid Howells #define MSGPOOL (MSGMNI * MSGMNB / 1024) /* size in kbytes of message pool */
81607ca46eSDavid Howells #define MSGTQL  MSGMNB            /* number of system message headers */
82607ca46eSDavid Howells #define MSGMAP  MSGMNB            /* number of entries in message map */
83607ca46eSDavid Howells #define MSGSSZ  16                /* message segment size */
84607ca46eSDavid Howells #define __MSGSEG ((MSGPOOL * 1024) / MSGSSZ) /* max no. of segments */
85607ca46eSDavid Howells #define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff)
86607ca46eSDavid Howells 
87607ca46eSDavid Howells 
88607ca46eSDavid Howells #endif /* _UAPI_LINUX_MSG_H */
89