]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. |
1c79356b A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
37839358 A |
6 | * The contents of this file constitute Original Code as defined in and |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
1c79356b | 11 | * |
37839358 A |
12 | * This Original Code and all software distributed under the License are |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
37839358 A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * @OSF_COPYRIGHT@ | |
24 | */ | |
25 | /* | |
26 | * Mach Operating System | |
27 | * Copyright (c) 1991,1990,1989 Carnegie Mellon University | |
28 | * All Rights Reserved. | |
29 | * | |
30 | * Permission to use, copy, modify and distribute this software and its | |
31 | * documentation is hereby granted, provided that both the copyright | |
32 | * notice and this permission notice appear in all copies of the | |
33 | * software, derivative works or modified versions, and any portions | |
34 | * thereof, and that both notices appear in supporting documentation. | |
35 | * | |
36 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
37 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
38 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
39 | * | |
40 | * Carnegie Mellon requests users of this software to return to | |
41 | * | |
42 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
43 | * School of Computer Science | |
44 | * Carnegie Mellon University | |
45 | * Pittsburgh PA 15213-3890 | |
46 | * | |
47 | * any improvements or extensions that they make and grant Carnegie Mellon | |
48 | * the rights to redistribute these changes. | |
49 | */ | |
50 | /* | |
51 | */ | |
52 | /* | |
53 | * File: ipc/ipc_mqueue.h | |
54 | * Author: Rich Draves | |
55 | * Date: 1989 | |
56 | * | |
57 | * Definitions for message queues. | |
58 | */ | |
59 | ||
60 | #ifndef _IPC_IPC_MQUEUE_H_ | |
61 | #define _IPC_IPC_MQUEUE_H_ | |
62 | ||
63 | #include <mach_assert.h> | |
64 | ||
65 | #include <mach/message.h> | |
66 | ||
67 | #include <kern/assert.h> | |
68 | #include <kern/macro_help.h> | |
91447636 | 69 | #include <kern/kern_types.h> |
1c79356b A |
70 | #include <kern/wait_queue.h> |
71 | ||
72 | #include <ipc/ipc_kmsg.h> | |
73 | #include <ipc/ipc_object.h> | |
74 | #include <ipc/ipc_types.h> | |
75 | ||
76 | typedef struct ipc_mqueue { | |
77 | union { | |
78 | struct { | |
79 | struct wait_queue wait_queue; | |
80 | struct ipc_kmsg_queue messages; | |
81 | mach_port_msgcount_t msgcount; | |
82 | mach_port_msgcount_t qlimit; | |
83 | mach_port_seqno_t seqno; | |
84 | boolean_t fullwaiters; | |
85 | } port; | |
9bccf70c | 86 | struct wait_queue_set set_queue; |
1c79356b A |
87 | } data; |
88 | } *ipc_mqueue_t; | |
89 | ||
90 | #define IMQ_NULL ((ipc_mqueue_t) 0) | |
91 | ||
92 | #define imq_wait_queue data.port.wait_queue | |
93 | #define imq_messages data.port.messages | |
94 | #define imq_msgcount data.port.msgcount | |
95 | #define imq_qlimit data.port.qlimit | |
96 | #define imq_seqno data.port.seqno | |
97 | #define imq_fullwaiters data.port.fullwaiters | |
98 | ||
99 | #define imq_set_queue data.set_queue | |
9bccf70c A |
100 | #define imq_setlinks data.set_queue.wqs_setlinks |
101 | #define imq_is_set(mq) wait_queue_is_set(&(mq)->imq_set_queue) | |
1c79356b A |
102 | |
103 | #define imq_lock(mq) wait_queue_lock(&(mq)->imq_wait_queue) | |
104 | #define imq_lock_try(mq) wait_queue_lock_try(&(mq)->imq_wait_queue) | |
105 | #define imq_unlock(mq) wait_queue_unlock(&(mq)->imq_wait_queue) | |
106 | #define imq_held(mq) wait_queue_held(&(mq)->imq_wait_queue) | |
107 | ||
108 | #define imq_full(mq) ((mq)->imq_msgcount >= (mq)->imq_qlimit) | |
109 | ||
110 | extern int ipc_mqueue_full; | |
111 | extern int ipc_mqueue_rcv; | |
112 | ||
9bccf70c A |
113 | #define IPC_MQUEUE_FULL (event64_t)&ipc_mqueue_full |
114 | #define IPC_MQUEUE_RECEIVE (event64_t)&ipc_mqueue_rcv | |
1c79356b A |
115 | |
116 | /* | |
117 | * Exported interfaces | |
118 | */ | |
119 | ||
120 | /* Initialize a newly-allocated message queue */ | |
121 | extern void ipc_mqueue_init( | |
91447636 A |
122 | ipc_mqueue_t mqueue, |
123 | boolean_t is_set); | |
124 | ||
125 | /* destroy an mqueue */ | |
126 | extern void ipc_mqueue_destroy( | |
127 | ipc_mqueue_t mqueue); | |
1c79356b | 128 | |
1c79356b A |
129 | /* Wake up receivers waiting in a message queue */ |
130 | extern void ipc_mqueue_changed( | |
131 | ipc_mqueue_t mqueue); | |
132 | ||
91447636 A |
133 | /* Add the specific mqueue as a member of the set */ |
134 | extern kern_return_t ipc_mqueue_add( | |
135 | ipc_mqueue_t mqueue, | |
136 | ipc_mqueue_t set_mqueue); | |
137 | ||
138 | /* Check to see if mqueue is member of set_mqueue */ | |
139 | extern boolean_t ipc_mqueue_member( | |
140 | ipc_mqueue_t mqueue, | |
141 | ipc_mqueue_t set_mqueue); | |
142 | ||
143 | /* Remove an mqueue from a specific set */ | |
144 | extern kern_return_t ipc_mqueue_remove( | |
145 | ipc_mqueue_t mqueue, | |
146 | ipc_mqueue_t set_mqueue); | |
147 | ||
148 | /* Remove an mqueue from all sets */ | |
149 | extern void ipc_mqueue_remove_from_all( | |
150 | ipc_mqueue_t mqueue); | |
151 | ||
152 | /* Remove all the members of the specifiied set */ | |
153 | extern void ipc_mqueue_remove_all( | |
154 | ipc_mqueue_t mqueue); | |
155 | ||
1c79356b A |
156 | /* Send a message to a port */ |
157 | extern mach_msg_return_t ipc_mqueue_send( | |
158 | ipc_mqueue_t mqueue, | |
159 | ipc_kmsg_t kmsg, | |
160 | mach_msg_option_t option, | |
91447636 | 161 | mach_msg_timeout_t timeout_val); |
1c79356b A |
162 | |
163 | /* Deliver message to message queue or waiting receiver */ | |
164 | extern void ipc_mqueue_post( | |
165 | ipc_mqueue_t mqueue, | |
166 | ipc_kmsg_t kmsg); | |
167 | ||
168 | /* Receive a message from a message queue */ | |
169 | extern void ipc_mqueue_receive( | |
170 | ipc_mqueue_t mqueue, | |
171 | mach_msg_option_t option, | |
172 | mach_msg_size_t max_size, | |
91447636 | 173 | mach_msg_timeout_t timeout_val, |
1c79356b A |
174 | int interruptible); |
175 | ||
176 | /* Continuation routine for message receive */ | |
91447636 A |
177 | extern void ipc_mqueue_receive_continue( |
178 | void *param, | |
179 | wait_result_t wresult); | |
1c79356b A |
180 | |
181 | /* Select a message from a queue and try to post it to ourself */ | |
182 | extern void ipc_mqueue_select( | |
183 | ipc_mqueue_t mqueue, | |
184 | mach_msg_option_t option, | |
185 | mach_msg_size_t max_size); | |
186 | ||
187 | /* Clear a message count reservation */ | |
188 | extern void ipc_mqueue_release_msgcount( | |
189 | ipc_mqueue_t mqueue); | |
190 | ||
191 | /* Change a queue limit */ | |
192 | extern void ipc_mqueue_set_qlimit( | |
193 | ipc_mqueue_t mqueue, | |
194 | mach_port_msgcount_t qlimit); | |
195 | ||
196 | /* Change a queue's sequence number */ | |
197 | extern void ipc_mqueue_set_seqno( | |
198 | ipc_mqueue_t mqueue, | |
199 | mach_port_seqno_t seqno); | |
200 | ||
201 | /* Convert a name in a space to a message queue */ | |
202 | extern mach_msg_return_t ipc_mqueue_copyin( | |
203 | ipc_space_t space, | |
204 | mach_port_name_t name, | |
205 | ipc_mqueue_t *mqueuep, | |
206 | ipc_object_t *objectp); | |
207 | ||
208 | #endif /* _IPC_IPC_MQUEUE_H_ */ |