msg.h 2.5 KB

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