malloc/Makefile: Split and sort tests
[glibc.git] / mach / msg.c
blob8eb252a16e036d72248d1f8616645f495e297863
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989, 1995 Carnegie Mellon University
4 * All Rights Reserved.
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>
28 #include <mach.h>
30 #ifdef MACH_MSG_OVERWRITE
31 /* In variants with this feature, the actual system call is
32 __mach_msg_overwrite_trap. */
33 mach_msg_return_t
34 __mach_msg_trap (mach_msg_header_t *msg,
35 mach_msg_option_t option,
36 mach_msg_size_t send_size,
37 mach_msg_size_t rcv_size,
38 mach_port_t rcv_name,
39 mach_msg_timeout_t timeout,
40 mach_port_t notify)
42 return __mach_msg_overwrite_trap (msg, option, send_size,
43 rcv_size, rcv_name, timeout, notify,
44 MACH_MSG_NULL, 0);
46 weak_alias (__mach_msg_trap, mach_msg_trap)
48 /* See comments below in __mach_msg. */
49 mach_msg_return_t
50 __mach_msg_overwrite (mach_msg_header_t *msg,
51 mach_msg_option_t option,
52 mach_msg_size_t send_size,
53 mach_msg_size_t rcv_size,
54 mach_port_t rcv_name,
55 mach_msg_timeout_t timeout,
56 mach_port_t notify,
57 mach_msg_header_t *rcv_msg,
58 mach_msg_size_t rcv_msg_size)
61 mach_msg_return_t ret;
63 /* Consider the following cases:
64 1. Errors in pseudo-receive (eg, MACH_SEND_INTERRUPTED
65 plus special bits).
66 2. Use of MACH_SEND_INTERRUPT/MACH_RCV_INTERRUPT options.
67 3. RPC calls with interruptions in one/both halves.
70 ret = __mach_msg_overwrite_trap (msg, option, send_size,
71 rcv_size, rcv_name, timeout, notify,
72 rcv_msg, rcv_msg_size);
73 if (ret == MACH_MSG_SUCCESS)
74 return MACH_MSG_SUCCESS;
76 if (!(option & MACH_SEND_INTERRUPT))
77 while (ret == MACH_SEND_INTERRUPTED)
78 ret = __mach_msg_overwrite_trap (msg, option, send_size,
79 rcv_size, rcv_name, timeout, notify,
80 rcv_msg, rcv_msg_size);
82 if (!(option & MACH_RCV_INTERRUPT))
83 while (ret == MACH_RCV_INTERRUPTED)
84 ret = __mach_msg_overwrite_trap (msg, option & ~MACH_SEND_MSG,
85 0, rcv_size, rcv_name, timeout, notify,
86 rcv_msg, rcv_msg_size);
88 return ret;
90 weak_alias (__mach_msg_overwrite, mach_msg_overwrite)
91 #endif
93 mach_msg_return_t
94 __mach_msg (mach_msg_header_t *msg,
95 mach_msg_option_t option,
96 mach_msg_size_t send_size,
97 mach_msg_size_t rcv_size,
98 mach_port_t rcv_name,
99 mach_msg_timeout_t timeout,
100 mach_port_t notify)
102 mach_msg_return_t ret;
104 /* Consider the following cases:
105 1. Errors in pseudo-receive (eg, MACH_SEND_INTERRUPTED
106 plus special bits).
107 2. Use of MACH_SEND_INTERRUPT/MACH_RCV_INTERRUPT options.
108 3. RPC calls with interruptions in one/both halves.
111 ret = __mach_msg_trap (msg, option, send_size,
112 rcv_size, rcv_name, timeout, notify);
113 if (ret == MACH_MSG_SUCCESS)
114 return MACH_MSG_SUCCESS;
116 if (!(option & MACH_SEND_INTERRUPT))
117 while (ret == MACH_SEND_INTERRUPTED)
118 ret = __mach_msg_trap (msg, option, send_size,
119 rcv_size, rcv_name, timeout, notify);
121 if (!(option & MACH_RCV_INTERRUPT))
122 while (ret == MACH_RCV_INTERRUPTED)
123 ret = __mach_msg_trap (msg, option & ~MACH_SEND_MSG,
124 0, rcv_size, rcv_name, timeout, notify);
126 return ret;
128 weak_alias (__mach_msg, mach_msg)
129 libc_hidden_def (__mach_msg)
131 mach_msg_return_t
132 __mach_msg_send (mach_msg_header_t *msg)
134 return __mach_msg (msg, MACH_SEND_MSG,
135 msg->msgh_size, 0, MACH_PORT_NULL,
136 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
138 weak_alias (__mach_msg_send, mach_msg_send)
140 mach_msg_return_t
141 __mach_msg_receive (mach_msg_header_t *msg)
143 return __mach_msg (msg, MACH_RCV_MSG,
144 0, msg->msgh_size, msg->msgh_local_port,
145 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
147 weak_alias (__mach_msg_receive, mach_msg_receive)