xref: /linux-6.15/include/uapi/linux/msg.h (revision 607ca46e)
1*607ca46eSDavid Howells #ifndef _UAPI_LINUX_MSG_H
2*607ca46eSDavid Howells #define _UAPI_LINUX_MSG_H
3*607ca46eSDavid Howells 
4*607ca46eSDavid Howells #include <linux/ipc.h>
5*607ca46eSDavid Howells 
6*607ca46eSDavid Howells /* ipcs ctl commands */
7*607ca46eSDavid Howells #define MSG_STAT 11
8*607ca46eSDavid Howells #define MSG_INFO 12
9*607ca46eSDavid Howells 
10*607ca46eSDavid Howells /* msgrcv options */
11*607ca46eSDavid Howells #define MSG_NOERROR     010000  /* no error if message is too big */
12*607ca46eSDavid Howells #define MSG_EXCEPT      020000  /* recv any msg except of specified type.*/
13*607ca46eSDavid Howells 
14*607ca46eSDavid Howells /* Obsolete, used only for backwards compatibility and libc5 compiles */
15*607ca46eSDavid Howells struct msqid_ds {
16*607ca46eSDavid Howells 	struct ipc_perm msg_perm;
17*607ca46eSDavid Howells 	struct msg *msg_first;		/* first message on queue,unused  */
18*607ca46eSDavid Howells 	struct msg *msg_last;		/* last message in queue,unused */
19*607ca46eSDavid Howells 	__kernel_time_t msg_stime;	/* last msgsnd time */
20*607ca46eSDavid Howells 	__kernel_time_t msg_rtime;	/* last msgrcv time */
21*607ca46eSDavid Howells 	__kernel_time_t msg_ctime;	/* last change time */
22*607ca46eSDavid Howells 	unsigned long  msg_lcbytes;	/* Reuse junk fields for 32 bit */
23*607ca46eSDavid Howells 	unsigned long  msg_lqbytes;	/* ditto */
24*607ca46eSDavid Howells 	unsigned short msg_cbytes;	/* current number of bytes on queue */
25*607ca46eSDavid Howells 	unsigned short msg_qnum;	/* number of messages in queue */
26*607ca46eSDavid Howells 	unsigned short msg_qbytes;	/* max number of bytes on queue */
27*607ca46eSDavid Howells 	__kernel_ipc_pid_t msg_lspid;	/* pid of last msgsnd */
28*607ca46eSDavid Howells 	__kernel_ipc_pid_t msg_lrpid;	/* last receive pid */
29*607ca46eSDavid Howells };
30*607ca46eSDavid Howells 
31*607ca46eSDavid Howells /* Include the definition of msqid64_ds */
32*607ca46eSDavid Howells #include <asm/msgbuf.h>
33*607ca46eSDavid Howells 
34*607ca46eSDavid Howells /* message buffer for msgsnd and msgrcv calls */
35*607ca46eSDavid Howells struct msgbuf {
36*607ca46eSDavid Howells 	long mtype;         /* type of message */
37*607ca46eSDavid Howells 	char mtext[1];      /* message text */
38*607ca46eSDavid Howells };
39*607ca46eSDavid Howells 
40*607ca46eSDavid Howells /* buffer for msgctl calls IPC_INFO, MSG_INFO */
41*607ca46eSDavid Howells struct msginfo {
42*607ca46eSDavid Howells 	int msgpool;
43*607ca46eSDavid Howells 	int msgmap;
44*607ca46eSDavid Howells 	int msgmax;
45*607ca46eSDavid Howells 	int msgmnb;
46*607ca46eSDavid Howells 	int msgmni;
47*607ca46eSDavid Howells 	int msgssz;
48*607ca46eSDavid Howells 	int msgtql;
49*607ca46eSDavid Howells 	unsigned short  msgseg;
50*607ca46eSDavid Howells };
51*607ca46eSDavid Howells 
52*607ca46eSDavid Howells /*
53*607ca46eSDavid Howells  * Scaling factor to compute msgmni:
54*607ca46eSDavid Howells  * the memory dedicated to msg queues (msgmni * msgmnb) should occupy
55*607ca46eSDavid Howells  * at most 1/MSG_MEM_SCALE of the lowmem (see the formula in ipc/msg.c):
56*607ca46eSDavid Howells  * up to 8MB       : msgmni = 16 (MSGMNI)
57*607ca46eSDavid Howells  * 4 GB            : msgmni = 8K
58*607ca46eSDavid Howells  * more than 16 GB : msgmni = 32K (IPCMNI)
59*607ca46eSDavid Howells  */
60*607ca46eSDavid Howells #define MSG_MEM_SCALE 32
61*607ca46eSDavid Howells 
62*607ca46eSDavid Howells #define MSGMNI    16   /* <= IPCMNI */     /* max # of msg queue identifiers */
63*607ca46eSDavid Howells #define MSGMAX  8192   /* <= INT_MAX */   /* max size of message (bytes) */
64*607ca46eSDavid Howells #define MSGMNB 16384   /* <= INT_MAX */   /* default max size of a message queue */
65*607ca46eSDavid Howells 
66*607ca46eSDavid Howells /* unused */
67*607ca46eSDavid Howells #define MSGPOOL (MSGMNI * MSGMNB / 1024) /* size in kbytes of message pool */
68*607ca46eSDavid Howells #define MSGTQL  MSGMNB            /* number of system message headers */
69*607ca46eSDavid Howells #define MSGMAP  MSGMNB            /* number of entries in message map */
70*607ca46eSDavid Howells #define MSGSSZ  16                /* message segment size */
71*607ca46eSDavid Howells #define __MSGSEG ((MSGPOOL * 1024) / MSGSSZ) /* max no. of segments */
72*607ca46eSDavid Howells #define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff)
73*607ca46eSDavid Howells 
74*607ca46eSDavid Howells 
75*607ca46eSDavid Howells #endif /* _UAPI_LINUX_MSG_H */
76