[llvm-commits] [compiler-rt] r163622 - /compiler-rt/trunk/lib/interception/interception.h

Alexey Samsonov samsonov at google.com
Tue Sep 11 08:02:20 PDT 2012


Author: samsonov
Date: Tue Sep 11 10:02:20 2012
New Revision: 163622

URL: http://llvm.org/viewvc/llvm-project?rev=163622&view=rev
Log:
[Sanitizer] get rid of empty DEFAULT_CONVENTION in interception lib to remove empty macro arguments

Modified:
    compiler-rt/trunk/lib/interception/interception.h

Modified: compiler-rt/trunk/lib/interception/interception.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception.h?rev=163622&r1=163621&r2=163622&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/interception.h (original)
+++ compiler-rt/trunk/lib/interception/interception.h Tue Sep 11 10:02:20 2012
@@ -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,





More information about the llvm-commits mailing list