1 /* 2 * Mach Operating System 3 * Copyright (c) 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 (at) 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:mach_msg.c,v $ 29 * Revision 2.3 92/01/23 15:22:17 rpd 30 * Fixed to not pass MACH_SEND_INTERRUPT and MACH_RCV_INTERRUPT 31 * to the kernel. 32 * [92/01/20 rpd] 33 * 34 * Revision 2.2 92/01/15 17:17:13 rpd 35 * Created from msg.c. 36 * [92/01/15 rpd] 37 * 38 */ 39 40 #if defined(VGO_darwin) 41 42 #include "pub_core_basics.h" 43 #include "pub_core_mach.h" 44 45 #include <mach/port.h> 46 #include <mach/message.h> 47 48 #define LIBMACH_OPTIONS (MACH_SEND_INTERRUPT|MACH_RCV_INTERRUPT) 49 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, 55 mach_port_t rcv_name, 56 mach_msg_timeout_t timeout, 57 mach_port_t notify); 58 59 mach_msg_return_t 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; 65 mach_port_t rcv_name; 66 mach_msg_timeout_t timeout; 67 mach_port_t notify; 68 { 69 mach_msg_return_t mr; 70 71 /* 72 * Consider the following cases: 73 *1) Errors in pseudo-receive (eg, MACH_SEND_INTERRUPTED 74 *plus special bits). 75 *2) Use of MACH_SEND_INTERRUPT/MACH_RCV_INTERRUPT options. 76 *3) RPC calls with interruptions in one/both halves. 77 * 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). 81 */ 82 83 mr = mach_msg_trap(msg, option &~ LIBMACH_OPTIONS, 84 send_size, rcv_size, rcv_name, 85 timeout, notify); 86 if (mr == MACH_MSG_SUCCESS) 87 return MACH_MSG_SUCCESS; 88 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, 94 timeout, notify); 95 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, 101 timeout, notify); 102 103 return mr; 104 } 105 106 #endif // defined(VGO_darwin) 107 108 /*--------------------------------------------------------------------*/ 109 /*--- end ---*/ 110 /*--------------------------------------------------------------------*/ 111