home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / msg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  5.7 KB  |  190 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ifndef _SYS_MSG_H
  11. #define _SYS_MSG_H
  12.  
  13. #ident    "@(#)/usr/include/sys/msg.h.sl 1.1 4.0 12/08/90 10110 AT&T-USL"
  14.  
  15. /*
  16.  * IPC Message Facility.
  17.  */
  18.  
  19. /*
  20.  * Implementation Constants.
  21.  */
  22.  
  23. #define    PMSG    (PZERO + 2)    /* message facility sleep priority */
  24.  
  25. /*
  26.  * Permission Definitions.
  27.  */
  28.  
  29. #define    MSG_R    0400    /* read permission */
  30. #define    MSG_W    0200    /* write permission */
  31.  
  32. /*
  33.  * ipc_perm Mode Definitions.
  34.  */
  35.  
  36. #define    MSG_RWAIT    01000    /* a reader is waiting for a message */
  37. #define    MSG_WWAIT    02000    /* a writer is waiting to send */
  38.  
  39. /*
  40.  * Message Operation Flags.
  41.  */
  42.  
  43. #define    MSG_NOERROR    010000    /* no error if big message */
  44.  
  45. /*
  46.  * There is one msg queue id data structure for each q in the system.
  47.  */
  48.  
  49. /* Applications that read /dev/mem must be built like the kernel. A new
  50. ** symbol "_KMEMUSER" is defined for this purpose.
  51. */
  52.  
  53. #if defined(_KERNEL) || defined(_KMEMUSER)
  54. /* expanded msqid_ds structure */
  55.  
  56. struct msqid_ds {
  57.     struct ipc_perm msg_perm;    /* operation permission struct */
  58.     struct msg    *msg_first;    /* ptr to first message on q */
  59.     struct msg    *msg_last;    /* ptr to last message on q */
  60.     ulong        msg_cbytes;    /* current # bytes on q */
  61.     ulong        msg_qnum;    /* # of messages on q */
  62.     ulong        msg_qbytes;    /* max # of bytes on q */
  63.     pid_t        msg_lspid;    /* pid of last msgsnd */
  64.     pid_t        msg_lrpid;    /* pid of last msgrcv */
  65.     time_t        msg_stime;    /* last msgsnd time */
  66.     long        msg_pad1;    /* reserved for time_t expansion */
  67.     time_t        msg_rtime;    /* last msgrcv time */
  68.     long        msg_pad2;    /* time_t expansion */
  69.     time_t        msg_ctime;    /* last change time */
  70.     long        msg_pad3;    /* time expansion */
  71.     long        msg_pad4[4];        /* reserve area */
  72. };
  73.  
  74. /* SVR3 structure */
  75.  
  76. struct o_msqid_ds {
  77.     struct o_ipc_perm msg_perm;    /* operation permission struct */
  78.     struct msg    *msg_first;    /* ptr to first message on q */
  79.     struct msg    *msg_last;    /* ptr to last message on q */
  80.     ushort        msg_cbytes;    /* current # bytes on q */
  81.     ushort        msg_qnum;    /* # of messages on q */
  82.     ushort        msg_qbytes;    /* max # of bytes on q */
  83.     o_pid_t        msg_lspid;    /* pid of last msgsnd */
  84.     o_pid_t        msg_lrpid;    /* pid of last msgrcv */
  85.     time_t        msg_stime;    /* last msgsnd time */
  86.     time_t        msg_rtime;    /* last msgrcv time */
  87.     time_t        msg_ctime;    /* last change time */
  88. };
  89. #else    /* user definition */
  90.  
  91. #if !defined(_STYPES)         /* EFT system */
  92. /* this maps to the kernel struct msgid_ds */
  93.  
  94. struct msqid_ds {
  95.     struct ipc_perm    msg_perm;    /* operation permission struct */
  96.     struct msg    *msg_first;    /* ptr to first message on q */
  97.     struct msg    *msg_last;    /* ptr to last message on q */
  98.     ulong        msg_cbytes;    /* current # bytes on q */
  99.     ulong        msg_qnum;    /* # of messages on q */
  100.     ulong        msg_qbytes;    /* max # of bytes on q */
  101.     pid_t        msg_lspid;    /* pid of last msgsnd */
  102.     pid_t        msg_lrpid;    /* pid of last msgrcv */
  103.     time_t        msg_stime;    /* last msgsnd time */
  104.     long        msg_pad1;    /* reserved for time_t expansion */
  105.     time_t        msg_rtime;    /* last msgrcv time */
  106.     long        msg_pad2;    /* time_t expansion */
  107.     time_t        msg_ctime;    /* last change time */
  108.     long        msg_pad3;    /* time_t expansion */
  109.     long        msg_pad4[4];    /* reserve area */
  110. };
  111. #else    /* NON EFT */
  112.  
  113. /* SVR3 structure - maps to kernel structure o_msqid_ds */
  114.  
  115. struct msqid_ds {
  116.     struct ipc_perm    msg_perm;    /* operation permission struct */
  117.     struct msg    *msg_first;    /* ptr to first message on q */
  118.     struct msg    *msg_last;    /* ptr to last message on q */
  119.     ushort        msg_cbytes;    /* current # bytes on q */
  120.     ushort        msg_qnum;    /* # of messages on q */
  121.     ushort        msg_qbytes;    /* max # of bytes on q */
  122.     o_pid_t        msg_lspid;    /* pid of last msgsnd */
  123.     o_pid_t        msg_lrpid;    /* pid of last msgrcv */
  124.     time_t        msg_stime;    /* last msgsnd time */
  125.     time_t        msg_rtime;    /* last msgrcv time */
  126.     time_t        msg_ctime;    /* last change time */
  127. };
  128.  
  129. #endif    /* !defined(_STYPES) */
  130. #endif  /* defined(_KERNEL) */
  131.  
  132. /*
  133.  * There is one msg structure for each message that may be in the system.
  134.  */
  135.  
  136. struct msg {
  137.     struct msg    *msg_next;    /* ptr to next message on q */
  138.     long        msg_type;    /* message type */
  139.     ushort        msg_ts;        /* message text size */
  140.     short        msg_spot;    /* message text map address */
  141. };
  142.  
  143. /*
  144.  * User message buffer template for msgsnd and msgrecv system calls.
  145.  */
  146.  
  147. struct msgbuf {
  148.     long    mtype;        /* message type */
  149.     char    mtext[1];    /* message text */
  150. };
  151.  
  152. /*
  153.  * Message information structure.
  154.  */
  155.  
  156. struct msginfo {
  157.     int    msgmap;    /* # of entries in msg map */
  158.     int    msgmax;    /* max message size */
  159.     int    msgmnb;    /* max # bytes on queue */
  160.     int    msgmni;    /* # of message queue identifiers */
  161.     int    msgssz;    /* msg segment size (should be word size multiple) */
  162.     int    msgtql;    /* # of system message headers */
  163.     ushort    msgseg;    /* # of msg segments (MUST BE < 32768) */
  164. };
  165.  
  166. /*
  167.  * We have to be able to lock a message queue since we can
  168.  * sleep during message processing due to a page fault in
  169.  * copyin/copyout or iomove.  We cannot add anything to the
  170.  * msqid_ds structure since this is used in user programs
  171.  * and any change would break object file compatibility.
  172.  * Therefore, we allocate a parallel array, msglock, which
  173.  * is used to lock a message queue.  The array is defined
  174.  * in the msg master file.  The following macro takes a
  175.  * pointer to a message queue and returns a pointer to the
  176.  * lock entry.  The argument must be a pointer to a msgqid
  177.  * structure.
  178.  */
  179.  
  180. #define    MSGLOCK(X)    &msglock[X - msgque]
  181.  
  182. #if defined(__STDC__) && !defined(_KERNEL)
  183. int msgctl(int, int, ...);
  184. int msgget(key_t, int);
  185. int msgrcv(int, void *, size_t, long, int);
  186. int msgsnd(int, const void *, size_t, int);
  187. #endif
  188.  
  189. #endif    /* _SYS_MSG_H */
  190.