* sysdeps/unix/sysv/linux/m68k/sysdep.h (INLINE_SYSCALL): Don't
[glibc.git] / mach / bootprivport.c
blob7114caa95fe3e853363e9782e368476f17a8f483
1 /* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #include <mach.h>
21 kern_return_t
22 __mach_get_priv_ports (mach_port_t *host_priv_ptr,
23 mach_port_t *device_master_ptr)
25 kern_return_t err;
26 mach_port_t bootstrap, reply;
28 struct
30 mach_msg_header_t hdr;
31 mach_msg_type_t host_priv_type;
32 mach_port_t host_priv;
33 mach_msg_type_t dev_master_type;
34 mach_port_t dev_master;
35 } msg;
37 if (err = task_get_bootstrap_port (mach_task_self (), &bootstrap))
38 return err;
40 /* We cannot simply use a MiG-generated user stub to do this,
41 because the return message does not contain a return code datum. */
42 reply = __mach_reply_port ();
43 msg.hdr.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_COPY_SEND,
44 MACH_MSG_TYPE_MAKE_SEND_ONCE);
45 msg.hdr.msgh_size = 0;
46 msg.hdr.msgh_remote_port = bootstrap;
47 msg.hdr.msgh_local_port = reply;
48 msg.hdr.msgh_kind = MACH_MSGH_KIND_NORMAL;
49 msg.hdr.msgh_id = 999999;
50 err = __mach_msg (&msg.hdr,
51 MACH_SEND_MSG|MACH_RCV_MSG|MACH_RCV_TIMEOUT,
52 sizeof (msg.hdr), sizeof (msg), reply,
53 500, MACH_PORT_NULL); /* XXX timeout is arbitrary */
54 mach_port_deallocate (mach_task_self (), bootstrap);
55 mach_port_deallocate (mach_task_self (), reply);
57 if (err == KERN_SUCCESS)
59 *host_priv_ptr = msg.host_priv;
60 *device_master_ptr = msg.dev_master;
63 return err;