Advertisement
Guest User

Untitled

a guest
Nov 14th, 2014
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 2.99 KB | None | 0 0
  1. /**
  2. * D header file for POSIX.
  3. *
  4. * Authors:   Neven Miculinić
  5. * Mostly copied/adapted from
  6. * /usr/include/linux/msg.h
  7. * /usr/include/x86_64-linux-gnu/sys/msg.h
  8. * constants from headers on Linux Mint x86-64
  9. * manuals
  10. */
  11. module core.sys.posix.sys.msg;
  12.  
  13. private import core.sys.posix.sys.ipc;
  14. public import core.sys.posix.sys.types;
  15. private import std.conv;
  16.  
  17. version (Posix):
  18. extern (C):
  19.  
  20.  
  21.  
  22. /* Accorind to manual for msgctl this constants these two constants are linux specific.
  23. /* ipcs ctl commands */
  24. version(Linux) {   
  25.     public enum MSG_STAT = 11;
  26.     public enum MSG_INFO = 12;
  27. }
  28.  
  29. /* msgrcv options */
  30. public enum MSG_NOERROR =    octal!10000;  /* no error if message is too big */
  31. public enum  MSG_EXCEPT =    octal!20000;  /* recv any msg except of specified type.*/
  32. public enum    MSG_COPY =    octal!40000;  /* copy (not remove) all queue messages */
  33.  
  34. /* message buffer for msgsnd and msgrcv calls */
  35. struct msgbuf {
  36.     long mtype;         /* type of message */
  37.     char mtext[1];      /* message text */
  38. };
  39.  
  40. /* buffer for msgctl calls IPC_INFO, MSG_INFO */
  41. struct msginfo {
  42.     int msgpool;
  43.     int msgmap;
  44.     int msgmax;
  45.     int msgmnb;
  46.     int msgmni;
  47.     int msgssz;
  48.     int msgtql;
  49.     ushort msgseg;
  50. };
  51.  
  52. /**
  53. * I have no idea whether this part is correct .
  54. * See http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysmsg.h.html
  55. */
  56. alias ushort msgqnum_t;
  57. alias ushort msglen_t;
  58.  
  59. struct msqid_ds {
  60.     ipc_perm msg_perm;            /* Ownership and permissions */
  61.     time_t          msg_stime;    /* Time of last msgsnd(2) */
  62.     time_t          msg_rtime;    /* Time of last msgrcv(2) */
  63.     time_t          msg_ctime;    /* Time of last change */
  64.     ulong   __msg_cbytes;         /* Current number of bytes in queue (nonstandard) */
  65.     msgqnum_t       msg_qnum;     /* Current number of messages in queue */
  66.     msglen_t        msg_qbytes;   /* Maximum number of bytes allowed in queue */
  67.     pid_t           msg_lspid;    /* PID of last msgsnd(2) */
  68.     pid_t           msg_lrpid;    /* PID of last msgrcv(2) */
  69. };
  70.  
  71. /*
  72. * Scaling factor to compute msgmni:
  73. * the memory dedicated to msg queues (msgmni * msgmnb) should occupy
  74. * at most 1/MSG_MEM_SCALE of the lowmem (see the formula in ipc/msg.c):
  75. * up to 8MB       : msgmni = 16 (MSGMNI)
  76. * 4 GB            : msgmni = 8K
  77. * more than 16 GB : msgmni = 32K (IPCMNI)
  78. */
  79. public enum MSG_MEM_SCALE =  32;
  80. public enum MSGMNI =     16;   /* <= IPCMNI */     /* max # of msg queue identifiers */
  81. public enum MSGMAX =   8192;   /* <= INT_MAX */   /* max size of message (bytes) */
  82. public enum MSGMNB =  16384;   /* <= INT_MAX */   /* default max size of a message queue */
  83.  
  84. /* Message queue control operation.  */  
  85. int msgctl (int msqid, int cmd, msqid_ds *__buf);
  86.  
  87. /* Get messages queue.  */
  88. int msgget ( key_t key, int msgflg );
  89.  
  90. /* Receive message from message queue. */
  91. ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg);
  92.  
  93. /* Send message to message queue. */
  94. int msgsnd ( int msqid, msgbuf *msgp, int msgsz, int msgflg );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement