msg.h 3.2 KB

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