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