summaryrefslogtreecommitdiff
path: root/lib/interception/interception.h
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-09-11 15:02:20 +0000
committerAlexey Samsonov <samsonov@google.com>2012-09-11 15:02:20 +0000
commitb66bfd1e28776f0a350b9c197926c2c172678603 (patch)
treef420cde467bcc669e5076407fbfd3ec3e0e75103 /lib/interception/interception.h
parent726fa673ede563a4785b5a44110b36071c4295b1 (diff)
[Sanitizer] get rid of empty DEFAULT_CONVENTION in interception lib to remove empty macro arguments
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@163622 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/interception/interception.h')
-rw-r--r--lib/interception/interception.h50
1 files changed, 23 insertions, 27 deletions
diff --git a/lib/interception/interception.h b/lib/interception/interception.h
index b52a10674..7c0de4a6f 100644
--- a/lib/interception/interception.h
+++ b/lib/interception/interception.h
@@ -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.
-
+// 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.
#if !MAC_INTERPOSE_FUNCTIONS
-# define DEFINE_REAL_EX(ret_type, convention, func, ...) \
- typedef ret_type (convention *FUNC_TYPE(func))(__VA_ARGS__); \
+# 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_EX(ret_type, convention, func, ...)
+# define DEFINE_REAL(ret_type, 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__) \
+#define INTERCEPTOR(ret_type, func, ...) \
+ DEFINE_REAL(ret_type, func, __VA_ARGS__) \
+ DECLARE_WRAPPER(ret_type, func, __VA_ARGS__) \
extern "C" \
INTERCEPTOR_ATTRIBUTE \
- ret_type convention WRAP(func)(__VA_ARGS__)
-
-#define INTERCEPTOR(ret_type, func, ...) \
- INTERCEPTOR_EX(ret_type, DEFAULT_CONVENTION, func, __VA_ARGS__)
+ 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,