]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
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. | |
11 | * | |
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 | |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
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. | |
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> | |
69 | #include <kern/wait_queue.h> | |
70 | ||
71 | #include <ipc/ipc_kmsg.h> | |
72 | #include <ipc/ipc_object.h> | |
73 | #include <ipc/ipc_types.h> | |
74 | ||
75 | typedef struct ipc_mqueue { | |
76 | union { | |
77 | struct { | |
78 | struct wait_queue wait_queue; | |
79 | struct ipc_kmsg_queue messages; | |
80 | mach_port_msgcount_t msgcount; | |
81 | mach_port_msgcount_t qlimit; | |
82 | mach_port_seqno_t seqno; | |
83 | boolean_t fullwaiters; | |
84 | } port; | |
85 | struct wait_queue_sub set_queue; | |
86 | } data; | |
87 | } *ipc_mqueue_t; | |
88 | ||
89 | #define IMQ_NULL ((ipc_mqueue_t) 0) | |
90 | ||
91 | #define imq_wait_queue data.port.wait_queue | |
92 | #define imq_messages data.port.messages | |
93 | #define imq_msgcount data.port.msgcount | |
94 | #define imq_qlimit data.port.qlimit | |
95 | #define imq_seqno data.port.seqno | |
96 | #define imq_fullwaiters data.port.fullwaiters | |
97 | ||
98 | #define imq_set_queue data.set_queue | |
99 | #define imq_setlinks data.set_queue.wqs_sublinks | |
100 | #define imq_is_set(mq) wait_queue_is_sub(&(mq)->imq_set_queue) | |
101 | ||
102 | #define imq_lock(mq) wait_queue_lock(&(mq)->imq_wait_queue) | |
103 | #define imq_lock_try(mq) wait_queue_lock_try(&(mq)->imq_wait_queue) | |
104 | #define imq_unlock(mq) wait_queue_unlock(&(mq)->imq_wait_queue) | |
105 | #define imq_held(mq) wait_queue_held(&(mq)->imq_wait_queue) | |
106 | ||
107 | #define imq_full(mq) ((mq)->imq_msgcount >= (mq)->imq_qlimit) | |
108 | ||
109 | extern int ipc_mqueue_full; | |
110 | extern int ipc_mqueue_rcv; | |
111 | ||
112 | #define IPC_MQUEUE_FULL (event_t)&ipc_mqueue_full | |
113 | #define IPC_MQUEUE_RECEIVE (event_t)&ipc_mqueue_rcv | |
114 | ||
115 | /* | |
116 | * Exported interfaces | |
117 | */ | |
118 | ||
119 | /* Initialize a newly-allocated message queue */ | |
120 | extern void ipc_mqueue_init( | |
121 | ipc_mqueue_t mqueue, | |
122 | boolean_t is_set); | |
123 | ||
124 | /* Move messages from one queue to another */ | |
125 | extern void ipc_mqueue_move( | |
126 | ipc_mqueue_t dest, | |
127 | ipc_mqueue_t source, | |
128 | ipc_port_t port); | |
129 | ||
130 | /* Wake up receivers waiting in a message queue */ | |
131 | extern void ipc_mqueue_changed( | |
132 | ipc_mqueue_t mqueue); | |
133 | ||
134 | /* Send a message to a port */ | |
135 | extern mach_msg_return_t ipc_mqueue_send( | |
136 | ipc_mqueue_t mqueue, | |
137 | ipc_kmsg_t kmsg, | |
138 | mach_msg_option_t option, | |
139 | mach_msg_timeout_t timeout); | |
140 | ||
141 | /* Deliver message to message queue or waiting receiver */ | |
142 | extern void ipc_mqueue_post( | |
143 | ipc_mqueue_t mqueue, | |
144 | ipc_kmsg_t kmsg); | |
145 | ||
146 | /* Receive a message from a message queue */ | |
147 | extern void ipc_mqueue_receive( | |
148 | ipc_mqueue_t mqueue, | |
149 | mach_msg_option_t option, | |
150 | mach_msg_size_t max_size, | |
151 | mach_msg_timeout_t timeout, | |
152 | int interruptible); | |
153 | ||
154 | /* Continuation routine for message receive */ | |
155 | extern void ipc_mqueue_receive_continue(void); | |
156 | ||
157 | /* Select a message from a queue and try to post it to ourself */ | |
158 | extern void ipc_mqueue_select( | |
159 | ipc_mqueue_t mqueue, | |
160 | mach_msg_option_t option, | |
161 | mach_msg_size_t max_size); | |
162 | ||
163 | /* Clear a message count reservation */ | |
164 | extern void ipc_mqueue_release_msgcount( | |
165 | ipc_mqueue_t mqueue); | |
166 | ||
167 | /* Change a queue limit */ | |
168 | extern void ipc_mqueue_set_qlimit( | |
169 | ipc_mqueue_t mqueue, | |
170 | mach_port_msgcount_t qlimit); | |
171 | ||
172 | /* Change a queue's sequence number */ | |
173 | extern void ipc_mqueue_set_seqno( | |
174 | ipc_mqueue_t mqueue, | |
175 | mach_port_seqno_t seqno); | |
176 | ||
177 | /* Convert a name in a space to a message queue */ | |
178 | extern mach_msg_return_t ipc_mqueue_copyin( | |
179 | ipc_space_t space, | |
180 | mach_port_name_t name, | |
181 | ipc_mqueue_t *mqueuep, | |
182 | ipc_object_t *objectp); | |
183 | ||
184 | #endif /* _IPC_IPC_MQUEUE_H_ */ |