swr: fix build with mingw
[mesa.git] / src / gallium / drivers / swr / rasterizer / common / swr_assert.h
index d74b7981255f45da8be45c5033755fb7f1609fb5..cd9854f2549943b516bc1c1060fb8a4585822160 100644 (file)
@@ -71,7 +71,7 @@
     while (0)          \
     _SWR_WARN_RESTORE
 
-#if defined(_WIN32)
+#if defined(_MSC_VER)
 #define SWR_ASSUME(e, ...)        \
     _SWR_MACRO_START __assume(e); \
     _SWR_MACRO_END
@@ -164,12 +164,6 @@ void SwrTrace(
 #define SWR_ASSERT(e, ...) _SWR_ASSERT(true, e, ##__VA_ARGS__)
 #define SWR_ASSUME_ASSERT(e, ...) SWR_ASSERT(e, ##__VA_ARGS__)
 #define SWR_TRACE(_fmtstr, ...) _SWR_TRACE(_fmtstr, ##__VA_ARGS__)
-
-#if defined(assert)
-#undef assert
-#endif
-#define assert(exp) SWR_ASSERT(exp)
-
 #endif // SWR_ENABLE_ASSERTS
 
 #if SWR_ENABLE_REL_ASSERTS
@@ -192,7 +186,11 @@ void SwrTrace(
 #define SWR_INVALID(...)                                                                       \
     _SWR_INVALID_CONCAT(_SWR_INVALID_, _SWR_INVALID_VARGS(_SWR_INVALID_VARGS_0 __VA_ARGS__())) \
     (__VA_ARGS__)
-#endif
+
+#define SWR_STATIC_ASSERT(expression, ...) \
+    static_assert((expression), "Failed:\n    " #expression "\n    " __VA_ARGS__);
+
+#endif // SWR_ENABLE_REL_ASSERTS
 
 #endif // C++
 
@@ -226,6 +224,9 @@ static bool SwrSizeofWorkaround(T)
 #define SWR_REL_TRACE(_fmtstr, ...) \
     _SWR_MACRO_START(void)(0);      \
     _SWR_MACRO_END
+#define SWR_STATIC_ASSERT(e, ...)                           \
+    _SWR_MACRO_START(void)  sizeof(SwrSizeofWorkaround(e)); \
+    _SWR_MACRO_END
 #endif
 
 #if defined(_MSC_VER)