2 /* $NetBSD: msg.h,v 1.4 1994/06/29 06:44:43 cgd Exp $ */
5 * SVID compatible msg.h file
7 * Author: Daniel Boulet
9 * SPDX-License-Identifier: BSD-1-Clause
11 * Copyright 1993 Daniel Boulet and RTMX Inc.
13 * This system call was implemented by Daniel Boulet under contract from RTMX.
15 * Redistribution and use in source forms, with and without modification,
16 * are permitted provided that this entire comment appears intact.
18 * Redistribution in binary form may occur without any restrictions.
19 * Obviously, it would be nice if you gave credit where credit is due
20 * but requiring it would be too onerous.
22 * This software is provided ``AS IS'' without any warranties of any kind.
28 #include <sys/cdefs.h>
29 #include <sys/_types.h>
33 * The MSG_NOERROR identifier value, the msqid_ds struct and the msg struct
34 * are as defined by the SV API Intel 386 Processor Supplement.
37 #define MSG_NOERROR 010000 /* don't complain about too long msgs */
39 typedef unsigned long msglen_t;
40 typedef unsigned long msgqnum_t;
42 #ifndef _PID_T_DECLARED
43 typedef __pid_t pid_t;
44 #define _PID_T_DECLARED
47 #ifndef _SIZE_T_DECLARED
48 typedef __size_t size_t;
49 #define _SIZE_T_DECLARED
52 #ifndef _SSIZE_T_DECLARED
53 typedef __ssize_t ssize_t;
54 #define _SSIZE_T_DECLARED
57 #ifndef _TIME_T_DECLARED
58 typedef __time_t time_t;
59 #define _TIME_T_DECLARED
62 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
63 defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
65 struct ipc_perm_old msg_perm; /* msg queue permission bits */
66 struct msg *msg_first; /* first message in the queue */
67 struct msg *msg_last; /* last message in the queue */
68 msglen_t msg_cbytes; /* number of bytes in use on the queue */
69 msgqnum_t msg_qnum; /* number of msgs in the queue */
70 msglen_t msg_qbytes; /* max # of bytes on the queue */
71 pid_t msg_lspid; /* pid of last msgsnd() */
72 pid_t msg_lrpid; /* pid of last msgrcv() */
73 time_t msg_stime; /* time of last msgsnd() */
75 time_t msg_rtime; /* time of last msgrcv() */
77 time_t msg_ctime; /* time of last msgctl() */
84 * XXX there seems to be no prefix reserved for this header, so the name
85 * "msg" in "struct msg" and the names of all of the nonstandard members
86 * (mainly "msg_pad*) are namespace pollution.
90 struct ipc_perm msg_perm; /* msg queue permission bits */
91 struct msg *msg_first; /* first message in the queue */
92 struct msg *msg_last; /* last message in the queue */
93 msglen_t msg_cbytes; /* number of bytes in use on the queue */
94 msgqnum_t msg_qnum; /* number of msgs in the queue */
95 msglen_t msg_qbytes; /* max # of bytes on the queue */
96 pid_t msg_lspid; /* pid of last msgsnd() */
97 pid_t msg_lrpid; /* pid of last msgrcv() */
98 time_t msg_stime; /* time of last msgsnd() */
99 time_t msg_rtime; /* time of last msgrcv() */
100 time_t msg_ctime; /* time of last msgctl() */
105 * Structure describing a message. The SVID doesn't suggest any
106 * particular name for this structure. There is a reference in the
107 * msgop man page that reads "The structure mymsg is an example of what
108 * this user defined buffer might look like, and includes the following
109 * members:". This sentence is followed by two lines equivalent
110 * to the mtype and mtext field declarations below. It isn't clear
111 * if "mymsg" refers to the name of the structure type or the name of an
112 * instance of the structure...
115 long mtype; /* message type (+ve integer) */
116 char mtext[1]; /* message body */
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 */
133 * Based on the configuration parameters described in an SVR2 (yes, two)
134 * config(1m) man page.
136 * Each message is broken up and stored in segments that are msgssz bytes
137 * long. For efficiency reasons, this should be a power of two. Also,
138 * it doesn't make sense if it is less than 8 or greater than about 256.
139 * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
140 * two between 8 and 1024 inclusive (and panic's if it isn't).
143 int msgmax, /* max chars in a message */
144 msgmni, /* max message queue identifiers */
145 msgmnb, /* max chars in a queue */
146 msgtql, /* max messages in system */
147 msgssz, /* size of a message segment (see notes above) */
148 msgseg; /* number of message segments */
150 extern struct msginfo msginfo;
153 * Kernel wrapper for the user-level structure.
155 struct msqid_kernel {
157 * Data structure exposed to user space.
162 * Kernel-private components of the message queue.
164 struct label *label; /* MAC label */
165 struct ucred *cred; /* creator's credentials */
170 #if !defined(_KERNEL) || defined(_WANT_MSG_PROTOTYPES)
172 int msgctl(int, int, struct msqid_ds *);
173 int msgget(key_t, int);
174 ssize_t msgrcv(int, void *, size_t, long, int);
175 int msgsnd(int, const void *, size_t, int);
177 int msgsys(int, ...);
181 #endif /* !_KERNEL || _WANT_MSG_PROTOTYPES */
183 #endif /* !_SYS_MSG_H_ */