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 * Copyright 1993 Daniel Boulet and RTMX Inc.
11 * This system call was implemented by Daniel Boulet under contract from RTMX.
13 * Redistribution and use in source forms, with and without modification,
14 * are permitted provided that this entire comment appears intact.
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.
20 * This software is provided ``AS IS'' without any warranties of any kind.
26 #include <sys/cdefs.h>
27 #include <sys/_types.h>
28 #ifdef _WANT_SYSVMSG_INTERNALS
29 #define _WANT_SYSVIPC_INTERNALS
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.
38 #define MSG_NOERROR 010000 /* don't complain about too long msgs */
40 typedef unsigned long msglen_t;
41 typedef unsigned long msgqnum_t;
43 #ifndef _PID_T_DECLARED
44 typedef __pid_t pid_t;
45 #define _PID_T_DECLARED
48 #ifndef _SIZE_T_DECLARED
49 typedef __size_t size_t;
50 #define _SIZE_T_DECLARED
53 #ifndef _SSIZE_T_DECLARED
54 typedef __ssize_t ssize_t;
55 #define _SSIZE_T_DECLARED
58 #ifndef _TIME_T_DECLARED
59 typedef __time_t time_t;
60 #define _TIME_T_DECLARED
63 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
64 defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
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() */
76 time_t msg_rtime; /* time of last msgrcv() */
78 time_t msg_ctime; /* time of last msgctl() */
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 * are namespace pollution.
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() */
106 struct msg *msg_next; /* next msg in the chain */
107 long msg_type; /* type of this message */
108 /* >0 -> type of this message */
109 /* 0 -> free header */
110 u_short msg_ts; /* size of this message */
111 short msg_spot; /* location of start of msg in buffer */
112 struct label *label; /* MAC Framework label */
116 #if defined(_KERNEL) || defined(_WANT_SYSVMSG_INTERNALS)
118 * Based on the configuration parameters described in an SVR2 (yes, two)
119 * config(1m) man page.
121 * Each message is broken up and stored in segments that are msgssz bytes
122 * long. For efficiency reasons, this should be a power of two. Also,
123 * it doesn't make sense if it is less than 8 or greater than about 256.
124 * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
125 * two between 8 and 1024 inclusive (and panic's if it isn't).
128 int msgmax; /* max chars in a message */
129 int msgmni; /* max message queue identifiers */
130 int msgmnb; /* max chars in a queue */
131 int msgtql; /* max messages in system */
132 int msgssz; /* size of a message segment (see note) */
133 int msgseg; /* number of message segments */
137 * Kernel wrapper for the user-level structure.
139 struct msqid_kernel {
141 * Data structure exposed to user space.
146 * Kernel-private components of the message queue.
148 struct label *label; /* MAC label */
149 struct ucred *cred; /* creator's credentials */
154 extern struct msginfo msginfo;
159 int msgctl(int, int, struct msqid_ds *);
160 int msgget(key_t, int);
161 ssize_t msgrcv(int, void *, size_t, long, int);
162 int msgsnd(int, const void *, size_t, int);
164 int msgsys(int, ...);
167 #endif /* !_KERNEL */
169 #endif /* !_SYS_MSG_H_ */