interception.h revision 216719b23134b9719bbf3e1de4a7d5d351c21fa8
15b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//===-- interception.h ------------------------------------------*- C++ -*-===//
25b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//
35b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//                     The LLVM Compiler Infrastructure
45b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//
55b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// This file is distributed under the University of Illinois Open Source
65b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// License. See LICENSE.TXT for details.
75b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//
85b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//===----------------------------------------------------------------------===//
95b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//
105b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// This file is a part of AddressSanitizer, an address sanity checker.
115b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//
125b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// Machinery for providing replacements/wrappers for system functions.
135b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//===----------------------------------------------------------------------===//
145b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov
155b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#ifndef INTERCEPTION_H
165b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#define INTERCEPTION_H
175b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov
185b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32)
195b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov# error "Interception doesn't work on this operating system."
205b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#endif
215b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov
22216719b23134b9719bbf3e1de4a7d5d351c21fa8Alexey Samsonov#include "sanitizer_common/sanitizer_internal_defs.h"
236afa1b0406f5cce7256d4f8717bfe394a16999b5Kostya Serebryany
246afa1b0406f5cce7256d4f8717bfe394a16999b5Kostya Serebryany// These typedefs should be used only in the interceptor definitions to replace
256afa1b0406f5cce7256d4f8717bfe394a16999b5Kostya Serebryany// the standard system types (e.g. SSIZE_T instead of ssize_t)
266afa1b0406f5cce7256d4f8717bfe394a16999b5Kostya Serebryanytypedef __sanitizer::uptr SIZE_T;
276afa1b0406f5cce7256d4f8717bfe394a16999b5Kostya Serebryanytypedef __sanitizer::sptr SSIZE_T;
28996c4f2fa53cce8f9d7b517073f38569460de505Evgeniy Stepanovtypedef __sanitizer::sptr PTRDIFF_T;
29996c4f2fa53cce8f9d7b517073f38569460de505Evgeniy Stepanovtypedef __sanitizer::s64  INTMAX_T;
306afa1b0406f5cce7256d4f8717bfe394a16999b5Kostya Serebryanytypedef __sanitizer::u64  OFF_T;
316afa1b0406f5cce7256d4f8717bfe394a16999b5Kostya Serebryanytypedef __sanitizer::u64  OFF64_T;
326afa1b0406f5cce7256d4f8717bfe394a16999b5Kostya Serebryany
335b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// How to use this library:
345b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//      1) Include this header to define your own interceptors
355b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//         (see details below).
365b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//      2) Build all *.cc files and link against them.
375b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// On Mac you will also need to:
385b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//      3) Provide your own implementation for the following functions:
395b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//           mach_error_t __interception::allocate_island(void **ptr,
405b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//                                                      size_t size,
415b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//                                                      void *hint);
425b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//           mach_error_t __interception::deallocate_island(void *ptr);
435b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//         See "interception_mac.h" for more details.
445b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov
455b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// How to add an interceptor:
465b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// Suppose you need to wrap/replace system function (generally, from libc):
475b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//      int foo(const char *bar, double baz);
485b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// You'll need to:
495b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//      1) define INTERCEPTOR(int, foo, const char *bar, double baz) { ... } in
505b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//         your source file.
515b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//      2) Call "INTERCEPT_FUNCTION(foo)" prior to the first call of "foo".
525b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//         INTERCEPT_FUNCTION(foo) evaluates to "true" iff the function was
535b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//         intercepted successfully.
545b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// You can access original function by calling REAL(foo)(bar, baz).
555b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// By default, REAL(foo) will be visible only inside your interceptor, and if
565b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// you want to use it in other parts of RTL, you'll need to:
57b4fefa713da3dabda1cd83ae4182c71f1683f02cAlexey Samsonov//      3a) add DECLARE_REAL(int, foo, const char*, double) to a
585b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//          header file.
595b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// However, if the call "INTERCEPT_FUNCTION(foo)" and definition for
605b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// INTERCEPTOR(..., foo, ...) are in different files, you'll instead need to:
61b4fefa713da3dabda1cd83ae4182c71f1683f02cAlexey Samsonov//      3b) add DECLARE_REAL_AND_INTERCEPTOR(int, foo, const char*, double)
625b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//          to a header file.
635b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov
645b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// Notes: 1. Things may not work properly if macro INTERCEPT(...) {...} or
65b4fefa713da3dabda1cd83ae4182c71f1683f02cAlexey Samsonov//           DECLARE_REAL(...) are located inside namespaces.
665b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//        2. On Mac you can also use: "OVERRIDE_FUNCTION(foo, zoo);" to
675b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//           effectively redirect calls from "foo" to "zoo". In this case
685b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//           you aren't required to implement
69b4fefa713da3dabda1cd83ae4182c71f1683f02cAlexey Samsonov//           INTERCEPTOR(int, foo, const char *bar, double baz) {...}
705b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//           but instead you'll have to add
71b4fefa713da3dabda1cd83ae4182c71f1683f02cAlexey Samsonov//           DEFINE_REAL(int, foo, const char *bar, double baz) in your
725b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov//           source file (to define a pointer to overriden function).
735b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov
745b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// How it works:
75580469d7e40e39319cb2d3750edac4bccca18105Dmitry Vyukov// To replace system functions on Linux we just need to declare functions
765b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// with same names in our library and then obtain the real function pointers
77580469d7e40e39319cb2d3750edac4bccca18105Dmitry Vyukov// using dlsym().
78580469d7e40e39319cb2d3750edac4bccca18105Dmitry Vyukov// There is one complication. A user may also intercept some of the functions
79f54c0e3321e2381fca3f02faefaaa6639d59c7cfDmitry Vyukov// we intercept. To resolve this we declare our interceptors with __interceptor_
80f54c0e3321e2381fca3f02faefaaa6639d59c7cfDmitry Vyukov// prefix, and then make actual interceptors weak aliases to __interceptor_
81580469d7e40e39319cb2d3750edac4bccca18105Dmitry Vyukov// functions.
82580469d7e40e39319cb2d3750edac4bccca18105Dmitry Vyukov// This is not so on Mac OS, where the two-level namespace makes
835b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// our replacement functions invisible to other libraries. This may be overcomed
845b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// using the DYLD_FORCE_FLAT_NAMESPACE, but some errors loading the shared
85580469d7e40e39319cb2d3750edac4bccca18105Dmitry Vyukov// libraries in Chromium were noticed when doing so. Instead we use
86580469d7e40e39319cb2d3750edac4bccca18105Dmitry Vyukov// mach_override, a handy framework for patching functions at runtime.
87580469d7e40e39319cb2d3750edac4bccca18105Dmitry Vyukov// To avoid possible name clashes, our replacement functions have
885b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov// the "wrap_" prefix on Mac.
890ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko// An alternative to function patching is to create a dylib containing a
900ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko// __DATA,__interpose section that associates library functions with their
910ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko// wrappers. When this dylib is preloaded before an executable using
920ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko// DYLD_INSERT_LIBRARIES, it routes all the calls to interposed functions done
930ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko// through stubs to the wrapper functions. Such a library is built with
940ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko// -DMAC_INTERPOSE_FUNCTIONS=1.
950ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko
960ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko#if !defined(MAC_INTERPOSE_FUNCTIONS) || !defined(__APPLE__)
970ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko# define MAC_INTERPOSE_FUNCTIONS 0
980ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko#endif
995b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov
1005b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#if defined(__APPLE__)
1015b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov# define WRAP(x) wrap_##x
1025b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov# define WRAPPER_NAME(x) "wrap_"#x
1035b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov# define INTERCEPTOR_ATTRIBUTE
104b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov# define DECLARE_WRAPPER(ret_type, func, ...)
1055b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#elif defined(_WIN32)
1062716a61d085a8fdf13a099822720e320414cc4dcTimur Iskhodzhanov# if defined(_DLL)  // DLL CRT
1072716a61d085a8fdf13a099822720e320414cc4dcTimur Iskhodzhanov#  define WRAP(x) x
1082716a61d085a8fdf13a099822720e320414cc4dcTimur Iskhodzhanov#  define WRAPPER_NAME(x) #x
1092716a61d085a8fdf13a099822720e320414cc4dcTimur Iskhodzhanov#  define INTERCEPTOR_ATTRIBUTE
1102716a61d085a8fdf13a099822720e320414cc4dcTimur Iskhodzhanov# else  // Static CRT
1112716a61d085a8fdf13a099822720e320414cc4dcTimur Iskhodzhanov#  define WRAP(x) wrap_##x
1122716a61d085a8fdf13a099822720e320414cc4dcTimur Iskhodzhanov#  define WRAPPER_NAME(x) "wrap_"#x
1132716a61d085a8fdf13a099822720e320414cc4dcTimur Iskhodzhanov#  define INTERCEPTOR_ATTRIBUTE
1142716a61d085a8fdf13a099822720e320414cc4dcTimur Iskhodzhanov# endif
115b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov# define DECLARE_WRAPPER(ret_type, func, ...)
1165b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#else
117f54c0e3321e2381fca3f02faefaaa6639d59c7cfDmitry Vyukov# define WRAP(x) __interceptor_ ## x
118f54c0e3321e2381fca3f02faefaaa6639d59c7cfDmitry Vyukov# define WRAPPER_NAME(x) "__interceptor_" #x
1195b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov# define INTERCEPTOR_ATTRIBUTE __attribute__((visibility("default")))
120b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov# define DECLARE_WRAPPER(ret_type, func, ...) \
121b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov    extern "C" ret_type func(__VA_ARGS__) \
122ba362a7f0e98b369758f07aec8794c61e688b82dAlexey Samsonov    __attribute__((weak, alias("__interceptor_" #func), visibility("default")));
1235b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#endif
1245b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov
1250ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko#if !MAC_INTERPOSE_FUNCTIONS
1260ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko# define PTR_TO_REAL(x) real_##x
1270ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko# define REAL(x) __interception::PTR_TO_REAL(x)
1280ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko# define FUNC_TYPE(x) x##_f
1290ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko
1300ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko# define DECLARE_REAL(ret_type, func, ...) \
1310ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko    typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__); \
1320ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko    namespace __interception { \
1330ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko      extern FUNC_TYPE(func) PTR_TO_REAL(func); \
1340ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko    }
1350ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko#else  // MAC_INTERPOSE_FUNCTIONS
1360ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko# define REAL(x) x
1370ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko# define DECLARE_REAL(ret_type, func, ...) \
1380ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko    extern "C" ret_type func(__VA_ARGS__);
1390ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko#endif  // MAC_INTERPOSE_FUNCTIONS
1405b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov
1416bae39d1db13f60d3e9b8393e5b9d9eb2ab1b5c0Chandler Carruth#define DECLARE_REAL_AND_INTERCEPTOR(ret_type, func, ...) \
142c27279a4a08e0661f204c3e5dc65aafce79dec8aAlexey Samsonov  DECLARE_REAL(ret_type, func, __VA_ARGS__) \
1435b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov  extern "C" ret_type WRAP(func)(__VA_ARGS__);
1445b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov
145b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov// Generally, you don't need to use DEFINE_REAL by itself, as INTERCEPTOR
146b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov// macros does its job. In exceptional cases you may need to call REAL(foo)
147b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov// without defining INTERCEPTOR(..., foo, ...). For example, if you override
148b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov// foo with an interceptor for other function.
1490ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko#if !MAC_INTERPOSE_FUNCTIONS
150b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov# define DEFINE_REAL(ret_type, func, ...) \
151b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov    typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__); \
1520ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko    namespace __interception { \
1530ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko      FUNC_TYPE(func) PTR_TO_REAL(func); \
1540ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko    }
1550ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko#else
156b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov# define DEFINE_REAL(ret_type, func, ...)
1570ef531054fc25c11e372cbab1384f10954984219Alexander Potapenko#endif
158600972e3427173cc8904d741decd1af0ed5de9fdTimur Iskhodzhanov
159b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov#define INTERCEPTOR(ret_type, func, ...) \
160b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov  DEFINE_REAL(ret_type, func, __VA_ARGS__) \
161b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov  DECLARE_WRAPPER(ret_type, func, __VA_ARGS__) \
1625b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov  extern "C" \
1635b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov  INTERCEPTOR_ATTRIBUTE \
164b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov  ret_type WRAP(func)(__VA_ARGS__)
165600972e3427173cc8904d741decd1af0ed5de9fdTimur Iskhodzhanov
166600972e3427173cc8904d741decd1af0ed5de9fdTimur Iskhodzhanov#if defined(_WIN32)
167600972e3427173cc8904d741decd1af0ed5de9fdTimur Iskhodzhanov# define INTERCEPTOR_WINAPI(ret_type, func, ...) \
168b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov    typedef ret_type (__stdcall *FUNC_TYPE(func))(__VA_ARGS__); \
169b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov    namespace __interception { \
170b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov      FUNC_TYPE(func) PTR_TO_REAL(func); \
171b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov    } \
172b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov    DECLARE_WRAPPER(ret_type, func, __VA_ARGS__) \
173b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov    extern "C" \
174b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov    INTERCEPTOR_ATTRIBUTE \
175b66bfd1e28776f0a350b9c197926c2c172678603Alexey Samsonov    ret_type __stdcall WRAP(func)(__VA_ARGS__)
176600972e3427173cc8904d741decd1af0ed5de9fdTimur Iskhodzhanov#endif
1775b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov
178592d3f707e02968c75fd6e90d06d24f5df99c8b9Alexey Samsonov// ISO C++ forbids casting between pointer-to-function and pointer-to-object,
179592d3f707e02968c75fd6e90d06d24f5df99c8b9Alexey Samsonov// so we use casting via an integral type __interception::uptr,
180592d3f707e02968c75fd6e90d06d24f5df99c8b9Alexey Samsonov// assuming that system is POSIX-compliant. Using other hacks seem
181592d3f707e02968c75fd6e90d06d24f5df99c8b9Alexey Samsonov// challenging, as we don't even pass function type to
182592d3f707e02968c75fd6e90d06d24f5df99c8b9Alexey Samsonov// INTERCEPT_FUNCTION macro, only its name.
183592d3f707e02968c75fd6e90d06d24f5df99c8b9Alexey Samsonovnamespace __interception {
184b46941a1d23012491a7a8a52718cacbde3c19ba1Alexey Samsonov#if defined(_WIN64)
185b46941a1d23012491a7a8a52718cacbde3c19ba1Alexey Samsonovtypedef unsigned long long uptr;  // NOLINT
186b46941a1d23012491a7a8a52718cacbde3c19ba1Alexey Samsonov#else
187592d3f707e02968c75fd6e90d06d24f5df99c8b9Alexey Samsonovtypedef unsigned long uptr;  // NOLINT
188b46941a1d23012491a7a8a52718cacbde3c19ba1Alexey Samsonov#endif  // _WIN64
189592d3f707e02968c75fd6e90d06d24f5df99c8b9Alexey Samsonov}  // namespace __interception
190592d3f707e02968c75fd6e90d06d24f5df99c8b9Alexey Samsonov
1915b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#define INCLUDED_FROM_INTERCEPTION_LIB
1925b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov
1935b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#if defined(__linux__)
1945b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov# include "interception_linux.h"
1955b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov# define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_LINUX(func)
1965b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#elif defined(__APPLE__)
1975b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov# include "interception_mac.h"
1985b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov# define OVERRIDE_FUNCTION(old_func, new_func) \
1995b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov    OVERRIDE_FUNCTION_MAC(old_func, new_func)
2005b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov# define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_MAC(func)
2015b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#else  // defined(_WIN32)
20207bb9f1e3600195119aec1aae1aa48a6ed2f5febTimur Iskhodzhanov# include "interception_win.h"
20307bb9f1e3600195119aec1aae1aa48a6ed2f5febTimur Iskhodzhanov# define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_WIN(func)
2045b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#endif
2055b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov
2065b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#undef INCLUDED_FROM_INTERCEPTION_LIB
2075b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov
2085b29018cf422e7711fb760b733c32127397a43fcAlexey Samsonov#endif  // INTERCEPTION_H
209