]>
git.saurik.com Git - apple/xnu.git/blob - bsd/sys/msg.h
7621a0966bba299c7e270647ef764c758cd6295d
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 /* $NetBSD: msg.h,v 1.4 1994/06/29 06:44:43 cgd Exp $ */
28 * SVID compatible msg.h file
30 * Author: Daniel Boulet
32 * Copyright 1993 Daniel Boulet and RTMX Inc.
34 * This system call was implemented by Daniel Boulet under contract from RTMX.
36 * Redistribution and use in source forms, with and without modification,
37 * are permitted provided that this entire comment appears intact.
39 * Redistribution in binary form may occur without any restrictions.
40 * Obviously, it would be nice if you gave credit where credit is due
41 * but requiring it would be too onerous.
43 * This software is provided ``AS IS'' without any warranties of any kind.
49 #include <sys/appleapiopts.h>
51 #ifdef __APPLE_API_UNSTABLE
56 * The MSG_NOERROR identifier value, the msqid_ds struct and the msg struct
57 * are as defined by the SV API Intel 386 Processor Supplement.
60 #define MSG_NOERROR 010000 /* don't complain about too long msgs */
63 struct ipc_perm msg_perm
; /* msg queue permission bits */
64 struct msg
*msg_first
; /* first message in the queue */
65 struct msg
*msg_last
; /* last message in the queue */
66 u_long msg_cbytes
; /* number of bytes in use on the queue */
67 u_long msg_qnum
; /* number of msgs in the queue */
68 u_long msg_qbytes
; /* max # of bytes on the queue */
69 pid_t msg_lspid
; /* pid of last msgsnd() */
70 pid_t msg_lrpid
; /* pid of last msgrcv() */
71 time_t msg_stime
; /* time of last msgsnd() */
73 time_t msg_rtime
; /* time of last msgrcv() */
75 time_t msg_ctime
; /* time of last msgctl() */
81 struct msg
*msg_next
; /* next msg in the chain */
82 long msg_type
; /* type of this message */
83 /* >0 -> type of this message */
84 /* 0 -> free header */
85 u_short msg_ts
; /* size of this message */
86 short msg_spot
; /* location of start of msg in buffer */
90 * Structure describing a message. The SVID doesn't suggest any
91 * particular name for this structure. There is a reference in the
92 * msgop man page that reads "The structure mymsg is an example of what
93 * this user defined buffer might look like, and includes the following
94 * members:". This sentence is followed by two lines equivalent
95 * to the mtype and mtext field declarations below. It isn't clear
96 * if "mymsg" refers to the naem of the structure type or the name of an
97 * instance of the structure...
100 long mtype
; /* message type (+ve integer) */
101 char mtext
[1]; /* message body */
105 * Based on the configuration parameters described in an SVR2 (yes, two)
106 * config(1m) man page.
108 * Each message is broken up and stored in segments that are msgssz bytes
109 * long. For efficiency reasons, this should be a power of two. Also,
110 * it doesn't make sense if it is less than 8 or greater than about 256.
111 * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
112 * two between 8 and 1024 inclusive (and panic's if it isn't).
115 int msgmax
, /* max chars in a message */
116 msgmni
, /* max message queue identifiers */
117 msgmnb
, /* max chars in a queue */
118 msgtql
, /* max messages in system */
119 msgssz
, /* size of a message segment (see notes above) */
120 msgseg
; /* number of message segments */
123 extern struct msginfo msginfo
;
126 #define MSGSSZ 8 /* Each segment must be 2^N long */
129 #define MSGSEG 2048 /* must be less than 32767 */
131 #define MSGMAX (MSGSSZ*MSGSEG)
133 #define MSGMNB 2048 /* max # of bytes in a queue */
143 * macros to convert between msqid_ds's and msqid's.
144 * (specific to this implementation)
146 #define MSQID(ix,ds) ((ix) & 0xffff | (((ds).msg_perm.seq << 16) & 0xffff0000))
147 #define MSQID_IX(id) ((id) & 0xffff)
148 #define MSQID_SEQ(id) (((id) >> 16) & 0xffff)
151 * The rest of this file is specific to this particular implementation.
156 * Stuff allocated in machdep.h
159 short next
; /* next segment in buffer */
160 /* -1 -> available */
161 /* 0..(MSGSEG-1) -> index of next segment */
164 extern char *msgpool
; /* MSGMAX byte long msg buffer pool */
165 extern struct msgmap
*msgmaps
; /* MSGSEG msgmap structures */
166 extern struct msg
*msghdrs
; /* MSGTQL msg headers */
167 extern struct msqid_ds
*msqids
; /* MSGMNI msqid_ds struct's */
169 #define MSG_LOCKED 01000 /* Is this msqid_ds locked? */
174 #include <sys/cdefs.h>
177 int msgsys
__P((int, ...));
178 int msgctl
__P((int, int, struct msqid_ds
*));
179 int msgget
__P((key_t
, int));
180 int msgsnd
__P((int, void *, size_t, int));
181 int msgrcv
__P((int, void*, size_t, long, int));
185 #endif /* __APPLE_API_UNSTABLE */
186 #endif /* !_SYS_MSG_H_ */