[Mesa-dev] [PATCH] util: Implement unreachable for MSVC using __assume

Ian Romanick idr at freedesktop.org
Mon Nov 3 15:43:13 PST 2014


From: Ian Romanick <ian.d.romanick at intel.com>

Based on the description of __assume at:

http://msdn.microsoft.com/en-us/library/1b3fsfxw.aspx

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Brian Paul <brianp at vmware.com>
---
 src/util/macros.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/util/macros.h b/src/util/macros.h
index ff37a7d..da5daff 100644
--- a/src/util/macros.h
+++ b/src/util/macros.h
@@ -69,6 +69,12 @@ do {                        \
    assert(!str);            \
    __builtin_unreachable(); \
 } while (0)
+#elif _MSC_VER >= 1200
+#define unreachable(str)    \
+do {                        \
+   assert(!str);            \
+   __assume(0);             \
+} while (0)
 #endif
 
 #ifndef unreachable
-- 
1.8.1.4



More information about the mesa-dev mailing list