FreeBSD/Linux Kernel Cross Reference
sys/sys/msg.h
1 /* $FreeBSD$ */
2 /* $NetBSD: msg.h,v 1.4 1994/06/29 06:44:43 cgd Exp $ */
3
4 /*-
5 * SVID compatible msg.h file
6 *
7 * Author: Daniel Boulet
8 *
9 * Copyright 1993 Daniel Boulet and RTMX Inc.
10 *
11 * This system call was implemented by Daniel Boulet under contract from RTMX.
12 *
13 * Redistribution and use in source forms, with and without modification,
14 * are permitted provided that this entire comment appears intact.
15 *
16 * Redistribution in binary form may occur without any restrictions.
17 * Obviously, it would be nice if you gave credit where credit is due
18 * but requiring it would be too onerous.
19 *
20 * This software is provided ``AS IS'' without any warranties of any kind.
21 */
22
23 #ifndef _SYS_MSG_H_
24 #define _SYS_MSG_H_
25
26 #include <sys/cdefs.h>
27 #include <sys/_types.h>
28 #ifdef _WANT_SYSVMSG_INTERNALS
29 #define _WANT_SYSVIPC_INTERNALS
30 #endif
31 #include <sys/ipc.h>
32
33 /*
34 * The MSG_NOERROR identifier value, the msqid_ds struct and the msg struct
35 * are as defined by the SV API Intel 386 Processor Supplement.
36 */
37
38 #define MSG_NOERROR 010000 /* don't complain about too long msgs */
39
40 typedef unsigned long msglen_t;
41 typedef unsigned long msgqnum_t;
42
43 #ifndef _PID_T_DECLARED
44 typedef __pid_t pid_t;
45 #define _PID_T_DECLARED
46 #endif
47
48 #ifndef _SIZE_T_DECLARED
49 typedef __size_t size_t;
50 #define _SIZE_T_DECLARED
51 #endif
52
53 #ifndef _SSIZE_T_DECLARED
54 typedef __ssize_t ssize_t;
55 #define _SSIZE_T_DECLARED
56 #endif
57
58 #ifndef _TIME_T_DECLARED
59 typedef __time_t time_t;
60 #define _TIME_T_DECLARED
61 #endif
62
63 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
64 defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
65 struct msqid_ds_old {
66 struct ipc_perm_old msg_perm; /* msg queue permission bits */
67 struct msg *msg_first; /* first message in the queue */
68 struct msg *msg_last; /* last message in the queue */
69 msglen_t msg_cbytes; /* number of bytes in use on the queue */
70 msgqnum_t msg_qnum; /* number of msgs in the queue */
71 msglen_t msg_qbytes; /* max # of bytes on the queue */
72 pid_t msg_lspid; /* pid of last msgsnd() */
73 pid_t msg_lrpid; /* pid of last msgrcv() */
74 time_t msg_stime; /* time of last msgsnd() */
75 long msg_pad1;
76 time_t msg_rtime; /* time of last msgrcv() */
77 long msg_pad2;
78 time_t msg_ctime; /* time of last msgctl() */
79 long msg_pad3;
80 long msg_pad4[4];
81 };
82 #endif
83
84 /*
85 * XXX there seems to be no prefix reserved for this header, so the name
86 * "msg" in "struct msg" and the names of all of the nonstandard members
87 * (mainly "msg_pad*) are namespace pollution.
88 */
89
90 struct msqid_ds {
91 struct ipc_perm msg_perm; /* msg queue permission bits */
92 struct msg *msg_first; /* first message in the queue */
93 struct msg *msg_last; /* last message in the queue */
94 msglen_t msg_cbytes; /* number of bytes in use on the queue */
95 msgqnum_t msg_qnum; /* number of msgs in the queue */
96 msglen_t msg_qbytes; /* max # of bytes on the queue */
97 pid_t msg_lspid; /* pid of last msgsnd() */
98 pid_t msg_lrpid; /* pid of last msgrcv() */
99 time_t msg_stime; /* time of last msgsnd() */
100 time_t msg_rtime; /* time of last msgrcv() */
101 time_t msg_ctime; /* time of last msgctl() */
102 };
103
104 #if __BSD_VISIBLE
105 /*
106 * Structure describing a message. The SVID doesn't suggest any
107 * particular name for this structure. There is a reference in the
108 * msgop man page that reads "The structure mymsg is an example of what
109 * this user defined buffer might look like, and includes the following
110 * members:". This sentence is followed by two lines equivalent
111 * to the mtype and mtext field declarations below. It isn't clear
112 * if "mymsg" refers to the name of the structure type or the name of an
113 * instance of the structure...
114 */
115 struct mymsg {
116 long mtype; /* message type (+ve integer) */
117 char mtext[1]; /* message body */
118 };
119 #endif
120
121 #ifdef _KERNEL
122 struct msg {
123 struct msg *msg_next; /* next msg in the chain */
124 long msg_type; /* type of this message */
125 /* >0 -> type of this message */
126 /* 0 -> free header */
127 u_short msg_ts; /* size of this message */
128 short msg_spot; /* location of start of msg in buffer */
129 struct label *label; /* MAC Framework label */
130 };
131 #endif
132
133 #if defined(_KERNEL) || defined(_WANT_SYSVMSG_INTERNALS)
134 /*
135 * Based on the configuration parameters described in an SVR2 (yes, two)
136 * config(1m) man page.
137 *
138 * Each message is broken up and stored in segments that are msgssz bytes
139 * long. For efficiency reasons, this should be a power of two. Also,
140 * it doesn't make sense if it is less than 8 or greater than about 256.
141 * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
142 * two between 8 and 1024 inclusive (and panic's if it isn't).
143 */
144 struct msginfo {
145 int msgmax, /* max chars in a message */
146 msgmni, /* max message queue identifiers */
147 msgmnb, /* max chars in a queue */
148 msgtql, /* max messages in system */
149 msgssz, /* size of a message segment (see notes above) */
150 msgseg; /* number of message segments */
151 };
152
153 /*
154 * Kernel wrapper for the user-level structure.
155 */
156 struct msqid_kernel {
157 /*
158 * Data structure exposed to user space.
159 */
160 struct msqid_ds u;
161
162 /*
163 * Kernel-private components of the message queue.
164 */
165 struct label *label; /* MAC label */
166 struct ucred *cred; /* creator's credentials */
167 };
168 #endif
169
170 #ifdef _KERNEL
171 extern struct msginfo msginfo;
172
173 #else /* _KERNEL */
174
175 __BEGIN_DECLS
176 int msgctl(int, int, struct msqid_ds *);
177 int msgget(key_t, int);
178 /* XXX return value should be ssize_t. */
179 int msgrcv(int, void *, size_t, long, int);
180 int msgsnd(int, const void *, size_t, int);
181 #if __BSD_VISIBLE
182 int msgsys(int, ...);
183 #endif
184 __END_DECLS
185 #endif /* !_KERNEL */
186
187 #endif /* !_SYS_MSG_H_ */
Cache object: 7a6b7e52125e2d6bfc7e3f1d84b3634a
|