Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _UAPI_LINUX_MSG_H
0003 #define _UAPI_LINUX_MSG_H
0004 
0005 #include <linux/ipc.h>
0006 
0007 /* ipcs ctl commands */
0008 #define MSG_STAT 11
0009 #define MSG_INFO 12
0010 #define MSG_STAT_ANY 13
0011 
0012 /* msgrcv options */
0013 #define MSG_NOERROR     010000  /* no error if message is too big */
0014 #define MSG_EXCEPT      020000  /* recv any msg except of specified type.*/
0015 #define MSG_COPY        040000  /* copy (not remove) all queue messages */
0016 
0017 /* Obsolete, used only for backwards compatibility and libc5 compiles */
0018 struct msqid_ds {
0019     struct ipc_perm msg_perm;
0020     struct msg *msg_first;      /* first message on queue,unused  */
0021     struct msg *msg_last;       /* last message in queue,unused */
0022     __kernel_old_time_t msg_stime;  /* last msgsnd time */
0023     __kernel_old_time_t msg_rtime;  /* last msgrcv time */
0024     __kernel_old_time_t msg_ctime;  /* last change time */
0025     unsigned long  msg_lcbytes; /* Reuse junk fields for 32 bit */
0026     unsigned long  msg_lqbytes; /* ditto */
0027     unsigned short msg_cbytes;  /* current number of bytes on queue */
0028     unsigned short msg_qnum;    /* number of messages in queue */
0029     unsigned short msg_qbytes;  /* max number of bytes on queue */
0030     __kernel_ipc_pid_t msg_lspid;   /* pid of last msgsnd */
0031     __kernel_ipc_pid_t msg_lrpid;   /* last receive pid */
0032 };
0033 
0034 /* Include the definition of msqid64_ds */
0035 #include <asm/msgbuf.h>
0036 
0037 /* message buffer for msgsnd and msgrcv calls */
0038 struct msgbuf {
0039     __kernel_long_t mtype;          /* type of message */
0040     char mtext[1];                  /* message text */
0041 };
0042 
0043 /* buffer for msgctl calls IPC_INFO, MSG_INFO */
0044 struct msginfo {
0045     int msgpool;
0046     int msgmap; 
0047     int msgmax; 
0048     int msgmnb; 
0049     int msgmni; 
0050     int msgssz; 
0051     int msgtql; 
0052     unsigned short  msgseg; 
0053 };
0054 
0055 /*
0056  * MSGMNI, MSGMAX and MSGMNB are default values which can be
0057  * modified by sysctl.
0058  *
0059  * MSGMNI is the upper limit for the number of messages queues per
0060  * namespace.
0061  * It has been chosen to be as large possible without facilitating
0062  * scenarios where userspace causes overflows when adjusting the limits via
0063  * operations of the form retrieve current limit; add X; update limit".
0064  *
0065  * MSGMNB is the default size of a new message queue. Non-root tasks can
0066  * decrease the size with msgctl(IPC_SET), root tasks
0067  * (actually: CAP_SYS_RESOURCE) can both increase and decrease the queue
0068  * size. The optimal value is application dependent.
0069  * 16384 is used because it was always used (since 0.99.10)
0070  *
0071  * MAXMAX is the maximum size of an individual message, it's a global
0072  * (per-namespace) limit that applies for all message queues.
0073  * It's set to 1/2 of MSGMNB, to ensure that at least two messages fit into
0074  * the queue. This is also an arbitrary choice (since 2.6.0).
0075  */
0076 
0077 #define MSGMNI 32000   /* <= IPCMNI */     /* max # of msg queue identifiers */
0078 #define MSGMAX  8192   /* <= INT_MAX */   /* max size of message (bytes) */
0079 #define MSGMNB 16384   /* <= INT_MAX */   /* default max size of a message queue */
0080 
0081 /* unused */
0082 #define MSGPOOL (MSGMNI * MSGMNB / 1024) /* size in kbytes of message pool */
0083 #define MSGTQL  MSGMNB            /* number of system message headers */
0084 #define MSGMAP  MSGMNB            /* number of entries in message map */
0085 #define MSGSSZ  16                /* message segment size */
0086 #define __MSGSEG ((MSGPOOL * 1024) / MSGSSZ) /* max no. of segments */
0087 #define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff)
0088 
0089 
0090 #endif /* _UAPI_LINUX_MSG_H */