Update.
[glibc.git] / mach / msg.c
blobece110868d60ed5c68468dea44788fb250e9a582
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989, 1995 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.
26 #include <mach/port.h>
27 #include <mach/message.h>
29 mach_msg_return_t
30 __mach_msg (mach_msg_header_t *msg,
31 mach_msg_option_t option,
32 mach_msg_size_t send_size,
33 mach_msg_size_t rcv_size,
34 mach_port_t rcv_name,
35 mach_msg_timeout_t timeout,
36 mach_port_t notify)
38 mach_msg_return_t ret;
40 /* Consider the following cases:
41 1. Errors in pseudo-receive (eg, MACH_SEND_INTERRUPTED
42 plus special bits).
43 2. Use of MACH_SEND_INTERRUPT/MACH_RCV_INTERRUPT options.
44 3. RPC calls with interruptions in one/both halves.
47 ret = __mach_msg_trap (msg, option, send_size,
48 rcv_size, rcv_name, timeout, notify);
49 if (ret == MACH_MSG_SUCCESS)
50 return MACH_MSG_SUCCESS;
52 if (!(option & MACH_SEND_INTERRUPT))
53 while (ret == MACH_SEND_INTERRUPTED)
54 ret = __mach_msg_trap (msg, option, send_size,
55 rcv_size, rcv_name, timeout, notify);
57 if (!(option & MACH_RCV_INTERRUPT))
58 while (ret == MACH_RCV_INTERRUPTED)
59 ret = __mach_msg_trap (msg, option & ~MACH_SEND_MSG,
60 0, rcv_size, rcv_name, timeout, notify);
62 return ret;
64 weak_alias (__mach_msg, mach_msg)
66 mach_msg_return_t
67 __mach_msg_send (mach_msg_header_t *msg)
69 return __mach_msg (msg, MACH_SEND_MSG,
70 msg->msgh_size, 0, MACH_PORT_NULL,
71 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
73 weak_alias (__mach_msg_send, mach_msg_send)
75 mach_msg_return_t
76 __mach_msg_receive (mach_msg_header_t *msg)
78 return __mach_msg (msg, MACH_RCV_MSG,
79 0, msg->msgh_size, msg->msgh_local_port,
80 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
82 weak_alias (__mach_msg_receive, mach_msg_receive)