1 //===-- interception_mac.h --------------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of AddressSanitizer, an address sanity checker.
10 // Mac-specific interception methods.
11 //===----------------------------------------------------------------------===//
15 #if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
16 # error "interception_mac.h should be included from interception.h only"
19 #ifndef INTERCEPTION_MAC_H
20 #define INTERCEPTION_MAC_H
22 #include <mach/mach_error.h>
25 // Allocate memory for the escape island. This cannot be moved to
26 // mach_override, because each user of interceptors may specify its
27 // own memory range for escape islands.
29 mach_error_t
__interception_allocate_island(void **ptr
, size_t unused_size
,
31 mach_error_t
__interception_deallocate_island(void *ptr
);
34 namespace __interception
{
35 // returns true if the old function existed.
36 bool OverrideFunction(uptr old_func
, uptr new_func
, uptr
*orig_old_func
);
37 } // namespace __interception
39 # define OVERRIDE_FUNCTION_MAC(old_func, new_func) \
40 ::__interception::OverrideFunction( \
41 (::__interception::uptr)old_func, \
42 (::__interception::uptr)new_func, \
43 (::__interception::uptr*)((::__interception::uptr)&REAL(old_func)))
44 # define INTERCEPT_FUNCTION_MAC(func) OVERRIDE_FUNCTION_MAC(func, WRAP(func))
46 #endif // INTERCEPTION_MAC_H