On 09/30/2014 04:24 PM, Matt Turner wrote: > --- > src/util/macros.h | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/src/util/macros.h b/src/util/macros.h > index 40ebf02..77055e8 100644 > --- a/src/util/macros.h > +++ b/src/util/macros.h > @@ -75,6 +75,19 @@ do { \ > #define unreachable(str) > #endif > > +/** > + * Assume macro. Useful for expressing our assumptions to the compiler, > + * typically for purposes of silencing warnings. > + */ > +#ifdef HAVE___BUILTIN_UNREACHABLE > +#define assume(expr) ((expr) ? (void)0 : assert(!"assumption failed"), \ > + __builtin_unreachable()) > +#elif _MSC_VER >= 1200 > +#define assume(expr) __assume(expr) > +#else > +#define assume(expr) assert(expr) > +#endif > +
I like it. :) Based on http://msdn.microsoft.com/en-us/library/1b3fsfxw.aspx, it seems like we should have a version of unreachable() that uses __assume(0). Series is Reviewed-by: Ian Romanick <ian.d.roman...@intel.com> > #ifdef HAVE_FUNC_ATTRIBUTE_FLATTEN > #define FLATTEN __attribute__((__flatten__)) > #else > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev