xref: /linux-6.15/include/uapi/linux/msg.h (revision 443d5670)
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 {
37*443d5670SH.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 /*
54607ca46eSDavid Howells  * Scaling factor to compute msgmni:
55607ca46eSDavid Howells  * the memory dedicated to msg queues (msgmni * msgmnb) should occupy
56607ca46eSDavid Howells  * at most 1/MSG_MEM_SCALE of the lowmem (see the formula in ipc/msg.c):
57607ca46eSDavid Howells  * up to 8MB       : msgmni = 16 (MSGMNI)
58607ca46eSDavid Howells  * 4 GB            : msgmni = 8K
59607ca46eSDavid Howells  * more than 16 GB : msgmni = 32K (IPCMNI)
60607ca46eSDavid Howells  */
61607ca46eSDavid Howells #define MSG_MEM_SCALE 32
62607ca46eSDavid Howells 
63607ca46eSDavid Howells #define MSGMNI    16   /* <= IPCMNI */     /* max # of msg queue identifiers */
64607ca46eSDavid Howells #define MSGMAX  8192   /* <= INT_MAX */   /* max size of message (bytes) */
65607ca46eSDavid Howells #define MSGMNB 16384   /* <= INT_MAX */   /* default max size of a message queue */
66607ca46eSDavid Howells 
67607ca46eSDavid Howells /* unused */
68607ca46eSDavid Howells #define MSGPOOL (MSGMNI * MSGMNB / 1024) /* size in kbytes of message pool */
69607ca46eSDavid Howells #define MSGTQL  MSGMNB            /* number of system message headers */
70607ca46eSDavid Howells #define MSGMAP  MSGMNB            /* number of entries in message map */
71607ca46eSDavid Howells #define MSGSSZ  16                /* message segment size */
72607ca46eSDavid Howells #define __MSGSEG ((MSGPOOL * 1024) / MSGSSZ) /* max no. of segments */
73607ca46eSDavid Howells #define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff)
74607ca46eSDavid Howells 
75607ca46eSDavid Howells 
76607ca46eSDavid Howells #endif /* _UAPI_LINUX_MSG_H */
77