1 /* Copyright (C) 2002 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3 
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8 
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13 
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, see
16    <http://www.gnu.org/licenses/>.  */
17 
18 #ifndef _SYS_MSG_H
19 # error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
20 #endif
21 
22 #include <bits/types.h>
23 #include <bits/wordsize.h>
24 
25 /* Define options for message queue functions.  */
26 #define MSG_NOERROR	010000	/* no error if message is too big */
27 #ifdef __USE_GNU
28 # define MSG_EXCEPT	020000	/* recv any msg except of specified type */
29 #endif
30 
31 /* Types used in the structure definition.  */
32 typedef unsigned long int msgqnum_t;
33 typedef unsigned long int msglen_t;
34 
35 
36 /* Structure of record for one message inside the kernel.
37    The type `struct msg' is opaque.  */
38 #if (__WORDSIZE == 32) && defined(__MIPSEL__)
39 struct msqid_ds
40 {
41   struct ipc_perm msg_perm;	/* structure describing operation permission */
42 #  if defined(__UCLIBC_USE_TIME64__)
43   unsigned long msg_stime_internal_1;		/* time of last msgsnd command */
44   unsigned long msg_stime_internal_2;
45   unsigned long msg_rtime_internal_1;		/* time of last msgrcv command */
46   unsigned long msg_rtime_internal_2;
47   unsigned long msg_ctime_internal_1;		/* time of last change */
48   unsigned long msg_ctime_internal_2;
49 #  else
50   __time_t msg_stime;
51   unsigned long int __uclibc_unused1;
52   __time_t msg_rtime;
53   unsigned long int __uclibc_unused2;
54   __time_t msg_ctime;
55   unsigned long int __uclibc_unused3;
56 #  endif
57   unsigned long int __msg_cbytes; /* current number of bytes on queue */
58   msgqnum_t msg_qnum;		/* number of messages currently on queue */
59   msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
60   __pid_t msg_lspid;		/* pid of last msgsnd() */
61   __pid_t msg_lrpid;		/* pid of last msgrcv() */
62   unsigned long int __uclibc_unused4;
63   unsigned long int __uclibc_unused5;
64 #  if defined(__UCLIBC_USE_TIME64__)
65   __time_t msg_stime;
66   __time_t msg_rtime;
67   __time_t msg_ctime;
68 #  endif
69 };
70 
71 #elif (__WORDSIZE == 32) && defined(__MIPSEB__)
72 struct msqid_ds
73 {
74   struct ipc_perm msg_perm;	/* structure describing operation permission */
75 #  if defined(__UCLIBC_USE_TIME64__)
76   unsigned long msg_stime_internal_2;		/* time of last msgsnd command */
77   unsigned long msg_stime_internal_1;
78   unsigned long msg_rtime_internal_2;		/* time of last msgrcv command */
79   unsigned long msg_rtime_internal_1;
80   unsigned long msg_ctime_internal_2;		/* time of last change */
81   unsigned long msg_ctime_internal_1;
82 #  else
83   unsigned long int __uclibc_unused1;
84   __time_t msg_stime;
85   unsigned long int __uclibc_unused2;
86   __time_t msg_rtime;
87   unsigned long int __uclibc_unused3;
88   __time_t msg_ctime;
89 #  endif
90   unsigned long int __msg_cbytes; /* current number of bytes on queue */
91   msgqnum_t msg_qnum;		/* number of messages currently on queue */
92   msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
93   __pid_t msg_lspid;		/* pid of last msgsnd() */
94   __pid_t msg_lrpid;		/* pid of last msgrcv() */
95   unsigned long int __uclibc_unused4;
96   unsigned long int __uclibc_unused5;
97 #  if defined(__UCLIBC_USE_TIME64__)
98   __time_t msg_stime;
99   __time_t msg_rtime;
100   __time_t msg_ctime;
101 #  endif
102 };
103 
104 #else
105 
106 struct msqid_ds
107 {
108   struct ipc_perm msg_perm;     /* structure describing operation permission */
109   __time_t msg_stime;           /* time of last msgsnd command */
110   __time_t msg_rtime;           /* time of last msgrcv command */
111   __time_t msg_ctime;           /* time of last change */
112   unsigned long int __msg_cbytes; /* current number of bytes on queue */
113   msgqnum_t msg_qnum;           /* number of messages currently on queue */
114   msglen_t msg_qbytes;          /* max number of bytes allowed on queue */
115   __pid_t msg_lspid;            /* pid of last msgsnd() */
116   __pid_t msg_lrpid;            /* pid of last msgrcv() */
117   unsigned long int __uclibc_unused4;
118   unsigned long int __uclibc_unused5;
119 };
120 
121 #endif
122 
123 #ifdef __USE_MISC
124 
125 # define msg_cbytes	__msg_cbytes
126 
127 /* ipcs ctl commands */
128 # define MSG_STAT 11
129 # define MSG_INFO 12
130 
131 /* buffer for msgctl calls IPC_INFO, MSG_INFO */
132 struct msginfo
133   {
134     int msgpool;
135     int msgmap;
136     int msgmax;
137     int msgmnb;
138     int msgmni;
139     int msgssz;
140     int msgtql;
141     unsigned short int msgseg;
142   };
143 
144 #endif /* __USE_MISC */
145