2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
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.
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.
16 * Carnegie Mellon requests users of this software to return to
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
29 * Revision 2.3 92/01/23 15:22:17 rpd
30 * Fixed to not pass MACH_SEND_INTERRUPT and MACH_RCV_INTERRUPT
34 * Revision 2.2 92/01/15 17:17:13 rpd
40 #if defined(VGO_darwin)
42 #include "pub_core_basics.h"
43 #include "pub_core_mach.h"
45 #include <mach/port.h>
46 #include <mach/message.h>
48 #define LIBMACH_OPTIONS (MACH_SEND_INTERRUPT|MACH_RCV_INTERRUPT)
50 extern mach_msg_return_t
51 mach_msg_trap(mach_msg_header_t
*msg
,
52 mach_msg_option_t option
,
53 mach_msg_size_t send_size
,
54 mach_msg_size_t rcv_size
,
56 mach_msg_timeout_t timeout
,
60 mach_msg(msg
, option
, send_size
, rcv_size
, rcv_name
, timeout
, notify
)
61 mach_msg_header_t
*msg
;
62 mach_msg_option_t option
;
63 mach_msg_size_t send_size
;
64 mach_msg_size_t rcv_size
;
66 mach_msg_timeout_t timeout
;
72 * Consider the following cases:
73 *1) Errors in pseudo-receive (eg, MACH_SEND_INTERRUPTED
75 *2) Use of MACH_SEND_INTERRUPT/MACH_RCV_INTERRUPT options.
76 *3) RPC calls with interruptions in one/both halves.
78 * We refrain from passing the option bits that we implement
79 * to the kernel. This prevents their presence from inhibiting
80 * the kernel's fast paths (when it checks the option value).
83 mr
= mach_msg_trap(msg
, option
&~ LIBMACH_OPTIONS
,
84 send_size
, rcv_size
, rcv_name
,
86 if (mr
== MACH_MSG_SUCCESS
)
87 return MACH_MSG_SUCCESS
;
89 if ((option
& MACH_SEND_INTERRUPT
) == 0)
90 while (mr
== MACH_SEND_INTERRUPTED
)
91 mr
= mach_msg_trap(msg
,
92 option
&~ LIBMACH_OPTIONS
,
93 send_size
, rcv_size
, rcv_name
,
96 if ((option
& MACH_RCV_INTERRUPT
) == 0)
97 while (mr
== MACH_RCV_INTERRUPTED
)
98 mr
= mach_msg_trap(msg
,
99 option
&~ (LIBMACH_OPTIONS
|MACH_SEND_MSG
),
100 0, rcv_size
, rcv_name
,
106 #endif // defined(VGO_darwin)
108 /*--------------------------------------------------------------------*/
110 /*--------------------------------------------------------------------*/