msg.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _LINUX_MSG_H
  3. #define _LINUX_MSG_H
  4. #include <linux/ipc.h>
  5. /* ipcs ctl commands */
  6. #define MSG_STAT 11
  7. #define MSG_INFO 12
  8. #define MSG_STAT_ANY 13
  9. /* msgrcv options */
  10. #define MSG_NOERROR 010000 /* no error if message is too big */
  11. #define MSG_EXCEPT 020000 /* recv any msg except of specified type.*/
  12. #define MSG_COPY 040000 /* copy (not remove) all queue messages */
  13. /* Obsolete, used only for backwards compatibility and libc5 compiles */
  14. struct msqid_ds {
  15. struct ipc_perm msg_perm;
  16. struct msg *msg_first; /* first message on queue,unused */
  17. struct msg *msg_last; /* last message in queue,unused */
  18. __kernel_old_time_t msg_stime; /* last msgsnd time */
  19. __kernel_old_time_t msg_rtime; /* last msgrcv time */
  20. __kernel_old_time_t msg_ctime; /* last change time */
  21. unsigned long msg_lcbytes; /* Reuse junk fields for 32 bit */
  22. unsigned long msg_lqbytes; /* ditto */
  23. unsigned short msg_cbytes; /* current number of bytes on queue */
  24. unsigned short msg_qnum; /* number of messages in queue */
  25. unsigned short msg_qbytes; /* max number of bytes on queue */
  26. __kernel_ipc_pid_t msg_lspid; /* pid of last msgsnd */
  27. __kernel_ipc_pid_t msg_lrpid; /* last receive pid */
  28. };
  29. /* Include the definition of msqid64_ds */
  30. #include <asm/msgbuf.h>
  31. /* message buffer for msgsnd and msgrcv calls */
  32. struct msgbuf {
  33. __kernel_long_t mtype; /* type of message */
  34. char mtext[1]; /* message text */
  35. };
  36. /* buffer for msgctl calls IPC_INFO, MSG_INFO */
  37. struct msginfo {
  38. int msgpool;
  39. int msgmap;
  40. int msgmax;
  41. int msgmnb;
  42. int msgmni;
  43. int msgssz;
  44. int msgtql;
  45. unsigned short msgseg;
  46. };
  47. /*
  48. * MSGMNI, MSGMAX and MSGMNB are default values which can be
  49. * modified by sysctl.
  50. *
  51. * MSGMNI is the upper limit for the number of messages queues per
  52. * namespace.
  53. * It has been chosen to be as large possible without facilitating
  54. * scenarios where userspace causes overflows when adjusting the limits via
  55. * operations of the form retrieve current limit; add X; update limit".
  56. *
  57. * MSGMNB is the default size of a new message queue. Non-root tasks can
  58. * decrease the size with msgctl(IPC_SET), root tasks
  59. * (actually: CAP_SYS_RESOURCE) can both increase and decrease the queue
  60. * size. The optimal value is application dependent.
  61. * 16384 is used because it was always used (since 0.99.10)
  62. *
  63. * MAXMAX is the maximum size of an individual message, it's a global
  64. * (per-namespace) limit that applies for all message queues.
  65. * It's set to 1/2 of MSGMNB, to ensure that at least two messages fit into
  66. * the queue. This is also an arbitrary choice (since 2.6.0).
  67. */
  68. #define MSGMNI 32000 /* <= IPCMNI */ /* max # of msg queue identifiers */
  69. #define MSGMAX 8192 /* <= INT_MAX */ /* max size of message (bytes) */
  70. #define MSGMNB 16384 /* <= INT_MAX */ /* default max size of a message queue */
  71. /* unused */
  72. #define MSGPOOL (MSGMNI * MSGMNB / 1024) /* size in kbytes of message pool */
  73. #define MSGTQL MSGMNB /* number of system message headers */
  74. #define MSGMAP MSGMNB /* number of entries in message map */
  75. #define MSGSSZ 16 /* message segment size */
  76. #define __MSGSEG ((MSGPOOL * 1024) / MSGSSZ) /* max no. of segments */
  77. #define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff)
  78. #endif /* _LINUX_MSG_H */