drd/tests/swapcontext: Improve the portability of this test further
[valgrind.git] / coregrind / m_mach / mach_msg.c
blobc21425472ae79b2b9ce4038b4e387788b10a9b70
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.
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.
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]
34 * Revision 2.2 92/01/15 17:17:13 rpd
35 * Created from msg.c.
36 * [92/01/15 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,
55 mach_port_t rcv_name,
56 mach_msg_timeout_t timeout,
57 mach_port_t notify);
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;
69 mach_msg_return_t mr;
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.
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,
85 timeout, notify);
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,
94 timeout, notify);
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);
103 return mr;
106 #endif // defined(VGO_darwin)
108 /*--------------------------------------------------------------------*/
109 /*--- end ---*/
110 /*--------------------------------------------------------------------*/