diff options
Diffstat (limited to 'mesalib/src/util/macros.h')
-rw-r--r-- | mesalib/src/util/macros.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/mesalib/src/util/macros.h b/mesalib/src/util/macros.h index ff37a7d63..5fc672953 100644 --- a/mesalib/src/util/macros.h +++ b/mesalib/src/util/macros.h @@ -29,6 +29,10 @@ # define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) #endif +/* For compatibility with Clang's __has_builtin() */ +#ifndef __has_builtin +# define __has_builtin(x) 0 +#endif /** * __builtin_expect macros @@ -69,6 +73,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 @@ -79,7 +89,13 @@ do { \ * Assume macro. Useful for expressing our assumptions to the compiler, * typically for purposes of silencing warnings. */ -#ifdef HAVE___BUILTIN_UNREACHABLE +#if __has_builtin(__builtin_assume) +#define assume(expr) \ +do { \ + assert(expr); \ + __builtin_assume(expr); \ +} while (0) +#elif defined HAVE___BUILTIN_UNREACHABLE #define assume(expr) ((expr) ? ((void) 0) \ : (assert(!"assumption failed"), \ __builtin_unreachable())) |