[Sanitizer] get rid of empty DEFAULT_CONVENTION in interception lib to remove empty macro arguments

llvm-svn: 163622
This commit is contained in:
Alexey Samsonov 2012-09-11 15:02:20 +00:00
parent ef1707c013
commit 788eaeb35b

View File

@ -90,7 +90,7 @@
# define WRAP(x) wrap_##x
# define WRAPPER_NAME(x) "wrap_"#x
# define INTERCEPTOR_ATTRIBUTE
# define DECLARE_WRAPPER(ret_type, convention, func, ...)
# define DECLARE_WRAPPER(ret_type, func, ...)
#elif defined(_WIN32)
# if defined(_DLL) // DLL CRT
# define WRAP(x) x
@ -101,13 +101,13 @@
# define WRAPPER_NAME(x) "wrap_"#x
# define INTERCEPTOR_ATTRIBUTE
# endif
# define DECLARE_WRAPPER(ret_type, convention, func, ...)
# define DECLARE_WRAPPER(ret_type, func, ...)
#else
# define WRAP(x) __interceptor_ ## x
# define WRAPPER_NAME(x) "__interceptor_" #x
# define INTERCEPTOR_ATTRIBUTE __attribute__((visibility("default")))
# define DECLARE_WRAPPER(ret_type, convention, func, ...) \
extern "C" ret_type convention func(__VA_ARGS__) \
# define DECLARE_WRAPPER(ret_type, func, ...) \
extern "C" ret_type func(__VA_ARGS__) \
__attribute__((weak, alias("__interceptor_" #func), visibility("default")));
#endif
@ -131,41 +131,37 @@
DECLARE_REAL(ret_type, func, ##__VA_ARGS__) \
extern "C" ret_type WRAP(func)(__VA_ARGS__);
// FIXME(timurrrr): We might need to add DECLARE_REAL_EX etc to support
// different calling conventions later.
#if !MAC_INTERPOSE_FUNCTIONS
# define DEFINE_REAL_EX(ret_type, convention, func, ...) \
typedef ret_type (convention *FUNC_TYPE(func))(__VA_ARGS__); \
namespace __interception { \
FUNC_TYPE(func) PTR_TO_REAL(func); \
}
#else
# define DEFINE_REAL_EX(ret_type, convention, func, ...)
#endif
// Generally, you don't need to use DEFINE_REAL by itself, as INTERCEPTOR
// macros does its job. In exceptional cases you may need to call REAL(foo)
// without defining INTERCEPTOR(..., foo, ...). For example, if you override
// foo with an interceptor for other function.
#define DEFAULT_CONVENTION
#define DEFINE_REAL(ret_type, func, ...) \
DEFINE_REAL_EX(ret_type, DEFAULT_CONVENTION, func, __VA_ARGS__)
#define INTERCEPTOR_EX(ret_type, convention, func, ...) \
DEFINE_REAL_EX(ret_type, convention, func, __VA_ARGS__) \
DECLARE_WRAPPER(ret_type, convention, func, __VA_ARGS__) \
extern "C" \
INTERCEPTOR_ATTRIBUTE \
ret_type convention WRAP(func)(__VA_ARGS__)
#if !MAC_INTERPOSE_FUNCTIONS
# define DEFINE_REAL(ret_type, func, ...) \
typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__); \
namespace __interception { \
FUNC_TYPE(func) PTR_TO_REAL(func); \
}
#else
# define DEFINE_REAL(ret_type, func, ...)
#endif
#define INTERCEPTOR(ret_type, func, ...) \
INTERCEPTOR_EX(ret_type, DEFAULT_CONVENTION, func, __VA_ARGS__)
DEFINE_REAL(ret_type, func, __VA_ARGS__) \
DECLARE_WRAPPER(ret_type, func, __VA_ARGS__) \
extern "C" \
INTERCEPTOR_ATTRIBUTE \
ret_type WRAP(func)(__VA_ARGS__)
#if defined(_WIN32)
# define INTERCEPTOR_WINAPI(ret_type, func, ...) \
INTERCEPTOR_EX(ret_type, __stdcall, func, __VA_ARGS__)
typedef ret_type (__stdcall *FUNC_TYPE(func))(__VA_ARGS__); \
namespace __interception { \
FUNC_TYPE(func) PTR_TO_REAL(func); \
} \
DECLARE_WRAPPER(ret_type, func, __VA_ARGS__) \
extern "C" \
INTERCEPTOR_ATTRIBUTE \
ret_type __stdcall WRAP(func)(__VA_ARGS__)
#endif
// ISO C++ forbids casting between pointer-to-function and pointer-to-object,