Remove stray printfs.
SwiftShader shouldn't print anything to stdout in Release builds.
Also refactor UNIMPLEMENTED macro to be able to take a formatted string
with arguments.
Bug b/73656151
Change-Id: Ibadbfba3371324ba1bd608bd51bdac5e5923a20e
Reviewed-on: https://swiftshader-review.googlesource.com/21108
Reviewed-by: Merck Hung <merckhung@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Common/Debug.hpp b/src/Common/Debug.hpp
index 436854c..5033bc5 100644
--- a/src/Common/Debug.hpp
+++ b/src/Common/Debug.hpp
@@ -25,25 +25,34 @@
#undef min
#undef max
+namespace sw
+{
void trace(const char *format, ...);
+inline void trace() {}
+}
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
- #define TRACE(format, ...) trace("[0x%0.8X]%s(" format ")\n", this, __FUNCTION__, ##__VA_ARGS__)
+ #define TRACE(format, ...) sw::trace("[0x%0.8X]%s(" format ")\n", this, __FUNCTION__, ##__VA_ARGS__)
#else
#define TRACE(...) ((void)0)
#endif
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
- #define UNIMPLEMENTED() {trace("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); ASSERT(false);}
+ #define UNIMPLEMENTED(...) do { \
+ sw::trace("\t! Unimplemented: %s(%d): ", __FUNCTION__, __LINE__); \
+ sw::trace(##__VA_ARGS__); \
+ sw::trace("\n"); \
+ ASSERT(false); \
+ } while(0)
#else
- #define UNIMPLEMENTED() ((void)0)
+ #define UNIMPLEMENTED(...) ((void)0)
#endif
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
- #define ASSERT(expression) {if(!(expression)) trace("\t! Assert failed in %s(%d): " #expression "\n", __FUNCTION__, __LINE__); assert(expression);}
+ #define ASSERT(expression) {if(!(expression)) sw::trace("\t! Assert failed in %s(%d): " #expression "\n", __FUNCTION__, __LINE__); assert(expression);}
#else
#define ASSERT assert
#endif
-#endif // __ANDROID__
+#endif // !__ANDROID__
#endif // Debug_hpp