FreeBSD/Linux Kernel Cross Reference
sys/ipc/ipc_mqueue.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1993,1991,1990,1989 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: ipc_mqueue.h,v $
29 * Revision 2.7 93/11/17 16:59:06 dbg
30 * Use CONTINUE_NULL instead of IMQ_NULL_CONTINUE.
31 * [93/06/03 dbg]
32 *
33 * Use proper type for continuations.
34 * [93/05/04 dbg]
35 *
36 * Added ANSI function prototypes. Cleaned up return type of
37 * ipc_kmsg result parameter from ipc_mqueue_receive by using union
38 * type defined in ipc/ipc_types.h.
39 * [93/03/29 dbg]
40 *
41 * Revision 2.6 91/08/28 11:13:37 jsb
42 * Added seqno argument to ipc_mqueue_receive.
43 * [91/08/10 rpd]
44 *
45 * Revision 2.5 91/05/14 16:34:12 mrt
46 * Correcting copyright
47 *
48 * Revision 2.4 91/02/05 17:22:29 mrt
49 * Changed to new Mach copyright
50 * [91/02/01 15:46:46 mrt]
51 *
52 * Revision 2.3 91/01/08 15:14:42 rpd
53 * Changed continuation argument and IMQ_NULL_CONTINUE to (void (*)()).
54 * [90/12/18 rpd]
55 * Reorganized ipc_mqueue_receive.
56 * [90/11/22 rpd]
57 *
58 * Revision 2.2 90/06/02 14:50:44 rpd
59 * Created for new IPC.
60 * [90/03/26 20:57:40 rpd]
61 *
62 */
63 /*
64 * File: ipc/ipc_mqueue.h
65 * Author: Rich Draves
66 * Date: 1989
67 *
68 * Definitions for message queues.
69 */
70
71 #ifndef _IPC_IPC_MQUEUE_H_
72 #define _IPC_IPC_MQUEUE_H_
73
74 #include <mach_assert.h>
75
76 #include <mach/message.h>
77 #include <kern/assert.h>
78 #include <kern/lock.h>
79 #include <kern/macro_help.h>
80 #include <kern/sched_prim.h> /* continuation_t */
81 #include <ipc/ipc_types.h>
82 #include <ipc/ipc_kmsg.h>
83 #include <ipc/ipc_object.h>
84 #include <ipc/ipc_thread.h>
85
86 typedef struct ipc_mqueue {
87 decl_simple_lock_data(, imq_lock_data)
88 struct ipc_kmsg_queue imq_messages;
89 struct ipc_thread_queue imq_threads;
90 } *ipc_mqueue_t;
91
92 #define IMQ_NULL ((ipc_mqueue_t) 0)
93
94 #define imq_lock_init(mq) simple_lock_init(&(mq)->imq_lock_data)
95 #define imq_lock(mq) simple_lock(&(mq)->imq_lock_data)
96 #define imq_lock_try(mq) simple_lock_try(&(mq)->imq_lock_data)
97 #define imq_unlock(mq) simple_unlock(&(mq)->imq_lock_data)
98
99 extern void
100 ipc_mqueue_init(ipc_mqueue_t);
101
102 extern void
103 ipc_mqueue_move(
104 ipc_mqueue_t dest,
105 ipc_mqueue_t source,
106 ipc_port_t port);
107
108 extern void
109 ipc_mqueue_changed(
110 ipc_mqueue_t mqueue,
111 mach_msg_return_t mr);
112
113 extern mach_msg_return_t
114 ipc_mqueue_send(
115 ipc_kmsg_t kmsg,
116 mach_msg_option_t option,
117 mach_msg_timeout_t time_out);
118
119 extern mach_msg_return_t
120 ipc_mqueue_copyin(
121 ipc_space_t space,
122 mach_port_t name,
123 ipc_mqueue_t *mqueuep,
124 ipc_object_t *objectp);
125
126 extern mach_msg_return_t
127 ipc_mqueue_receive(
128 ipc_mqueue_t mqueue,
129 mach_msg_option_t option,
130 mach_msg_size_t max_size,
131 mach_msg_timeout_t time_out,
132 boolean_t resume,
133 continuation_t continuation,
134 union ipc_kmsg_return *kmsg_retp,
135 mach_port_seqno_t *seqnop);
136
137 /*
138 * extern void
139 * ipc_mqueue_send_always(ipc_kmsg_t);
140 *
141 * Unfortunately, to avoid warnings/lint about unused variables
142 * when assertions are turned off, we need two versions of this.
143 */
144
145 #if MACH_ASSERT
146
147 #define ipc_mqueue_send_always(kmsg) \
148 MACRO_BEGIN \
149 mach_msg_return_t mr; \
150 \
151 mr = ipc_mqueue_send((kmsg), MACH_SEND_ALWAYS, \
152 MACH_MSG_TIMEOUT_NONE); \
153 assert(mr == MACH_MSG_SUCCESS); \
154 MACRO_END
155
156 #else /* MACH_ASSERT */
157
158 #define ipc_mqueue_send_always(kmsg) \
159 MACRO_BEGIN \
160 (void) ipc_mqueue_send((kmsg), MACH_SEND_ALWAYS, \
161 MACH_MSG_TIMEOUT_NONE); \
162 MACRO_END
163
164 #endif /* MACH_ASSERT */
165
166 #endif /* _IPC_IPC_MQUEUE_H_ */
Cache object: 1ea31c0c567de27c185c816853073e9c
|