drd/tests/swapcontext: Improve the portability of this test further
[valgrind.git] / coregrind / m_mach / mach_basics.c
blob2c968ce7d7a6e3c615deae48ac449a25927e3a71
2 /*--------------------------------------------------------------------*/
3 /*--- Basic Mach interface functions mach_basics.c ---*/
4 /*--------------------------------------------------------------------*/
6 /*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
10 Copyright (C) 2005-2017 Apple Inc.
11 Greg Parker gparker@apple.com
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 #if defined(VGO_darwin)
31 #include "pub_core_basics.h"
32 #include "pub_core_mach.h"
34 #include <mach/mach.h>
35 #include <mach/machine/ndr_def.h>
37 /* From mach_traps-<arch>-darwin.S */
38 //extern mach_port_name_t host_self_trap(void);
39 extern mach_port_name_t thread_self_trap(void);
40 extern mach_port_t mach_reply_port(void);
42 /* Global variables set in mach_init() */
43 vm_size_t vm_page_size = 0;
44 mach_port_name_t mach_task_self_ = 0;
47 mach_port_name_t mach_thread_self(void)
49 return thread_self_trap();
52 static mach_port_t reply = 0;
54 mach_port_t mig_get_reply_port(void)
56 if (!reply) reply = mach_reply_port();
57 return reply;
58 // GrP fixme is just one enough for valgrind's own use?
59 // might work if valgrind never blocks in mig calls on
60 // its own behalf, and doesn't call mig outside the semaphore
64 void mig_dealloc_reply_port(mach_port_t reply_port)
69 void mig_put_reply_port(mach_port_t reply_port)
74 /* Initialize Mach global data.
75 Should be called early in main(). */
76 void VG_(mach_init)(void)
78 reply = 0;
79 mach_task_self_ = task_self_trap();
81 // GrP fixme host_page_size(host_self_trap(), &vm_page_size);
82 vm_page_size = 4096;
85 #endif // defined(VGO_darwin)
87 /*--------------------------------------------------------------------*/
88 /*--- end ---*/
89 /*--------------------------------------------------------------------*/