msg.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. long 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. * Scaling factor to compute msgmni:
  47. * the memory dedicated to msg queues (msgmni * msgmnb) should occupy
  48. * at most 1/MSG_MEM_SCALE of the lowmem (see the formula in ipc/msg.c):
  49. * up to 8MB : msgmni = 16 (MSGMNI)
  50. * 4 GB : msgmni = 8K
  51. * more than 16 GB : msgmni = 32K (IPCMNI)
  52. */
  53. #define MSG_MEM_SCALE 32
  54. #define MSGMNI 16 /* <= IPCMNI */ /* max # of msg queue identifiers */
  55. #define MSGMAX 8192 /* <= INT_MAX */ /* max size of message (bytes) */
  56. #define MSGMNB 16384 /* <= INT_MAX */ /* default max size of a message queue */
  57. /* unused */
  58. #define MSGPOOL (MSGMNI * MSGMNB / 1024) /* size in kbytes of message pool */
  59. #define MSGTQL MSGMNB /* number of system message headers */
  60. #define MSGMAP MSGMNB /* number of entries in message map */
  61. #define MSGSSZ 16 /* message segment size */
  62. #define __MSGSEG ((MSGPOOL * 1024) / MSGSSZ) /* max no. of segments */
  63. #define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff)
  64. #endif /* _UAPI_LINUX_MSG_H */