2.9
[glibc/nacl-glibc.git] / mach / mach / mig_support.h
blobf02e8d4f833e480ee83628b9631ff6a2a0c9ce34
1 /* Copyright (C) 1993,94,97,99,2001,2007 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 /* Useful declarations and support functions for MiG-generated stubs. */
21 #ifndef _MACH_MIG_SUPPORT_H
23 #define _MACH_MIG_SUPPORT_H 1
25 #include <mach/std_types.h>
26 #include <mach/message.h>
27 #include <sys/types.h>
28 #include <string.h>
30 #ifndef __USE_GNU
31 /* The only problem that has come up so far is __stpncpy being undeclared
32 below because <string.h> doesn't declare it without __USE_GNU. We could
33 work around that problem by just adding the declaration there, or by
34 eliding the inline functions in the absence of __USE_GNU. But either of
35 these would result in unoptimized calls (because no inline version of
36 __stpncpy will have been defined), and there may be other niggling
37 problems lurking. Instead we simply insist on _GNU_SOURCE for
38 compiling mig output; anyway, that better reflects the fact that mig
39 output requires nonstandard special support code not found elsewhere. */
40 # error mig stubs must be compiled with -D_GNU_SOURCE
41 #endif
43 /* MiG initialization. */
44 extern void __mig_init (void *__first);
45 extern void mig_init (void *__first);
47 /* Shorthand functions for vm_allocate and vm_deallocate on
48 mach_task_self () (and with ANYWHERE=1). */
49 extern void __mig_allocate (vm_address_t *__addr_p, vm_size_t __size);
50 extern void mig_allocate (vm_address_t *__addr_p, vm_size_t __size);
51 extern void __mig_deallocate (vm_address_t __addr, vm_size_t __size);
52 extern void mig_deallocate (vm_address_t __addr, vm_size_t __size);
54 /* Reply-port management support functions. */
55 extern void __mig_dealloc_reply_port (mach_port_t);
56 extern void mig_dealloc_reply_port (mach_port_t);
57 extern mach_port_t __mig_get_reply_port (void);
58 extern mach_port_t mig_get_reply_port (void);
59 extern void __mig_put_reply_port (mach_port_t);
60 extern void mig_put_reply_port (mach_port_t);
62 extern void __mig_reply_setup (const mach_msg_header_t *__request,
63 mach_msg_header_t *__reply);
64 extern void mig_reply_setup (const mach_msg_header_t *__request,
65 mach_msg_header_t *__reply);
67 /* Idiocy support function. */
68 extern vm_size_t mig_strncpy (char *__dst, const char *__src, vm_size_t __len);
69 extern vm_size_t __mig_strncpy (char *__dst, const char *__src, vm_size_t);
70 __extern_inline vm_size_t
71 __mig_strncpy (char *__dst, const char *__src, vm_size_t __len)
73 return __stpncpy (__dst, __src, __len) - __dst;
75 __extern_inline vm_size_t
76 mig_strncpy (char *__dst, const char *__src, vm_size_t __len)
78 return __mig_strncpy (__dst, __src, __len);
83 #endif /* mach/mig_support.h */