* configure.ac: Change target-libasan to target-libsanitizer.
[official-gcc.git] / libsanitizer / interception / interception_mac.h
blob244b457d738c77bee26af9d6306eeede51f44a04
1 //===-- interception_mac.h --------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of AddressSanitizer, an address sanity checker.
9 //
10 // Mac-specific interception methods.
11 //===----------------------------------------------------------------------===//
13 #ifdef __APPLE__
15 #if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
16 # error "interception_mac.h should be included from interception.h only"
17 #endif
19 #ifndef INTERCEPTION_MAC_H
20 #define INTERCEPTION_MAC_H
22 #include <mach/mach_error.h>
23 #include <stddef.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.
28 extern "C" {
29 mach_error_t __interception_allocate_island(void **ptr, size_t unused_size,
30 void *unused_hint);
31 mach_error_t __interception_deallocate_island(void *ptr);
32 } // extern "C"
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
47 #endif // __APPLE__