[Mesa-dev] [PATCH 1/2] gallium: define unreachable macro

Ilia Mirkin imirkin at alum.mit.edu
Wed Feb 11 07:50:51 PST 2015


It's already defined in src/util/macros.h which you can include via
#include "util/macros.h" -- I suspect some key gallium file should
include that...

On Wed, Feb 11, 2015 at 10:47 AM, Tobias Klausmann
<tobias.johannes.klausmann at mni.thm.de> wrote:
> This is done the same way for glsl et al. already
>
> Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
> ---
>  src/gallium/include/pipe/p_compiler.h | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
>
> diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h
> index fb018bf..62ba9d3 100644
> --- a/src/gallium/include/pipe/p_compiler.h
> +++ b/src/gallium/include/pipe/p_compiler.h
> @@ -249,6 +249,29 @@ void _ReadWriteBarrier(void);
>
>
>  /**
> + * Unreachable macro. Useful for suppressing "control reaches end of non-void
> + * function" warnings.
> + */
> +#ifdef HAVE___BUILTIN_UNREACHABLE
> +#define unreachable(str)    \
> +do {                        \
> +   assert(!str);            \
> +   __builtin_unreachable(); \
> +} while (0)
> +#elif _MSC_VER >= 1200
> +#define unreachable(str)    \
> +do {                        \
> +   assert(!str);            \
> +   __assume(0);             \
> +} while (0)
> +#endif
> +
> +#ifndef unreachable
> +#define unreachable(str) assert(!str)
> +#endif
> +
> +
> +/**
>   * Static (compile-time) assertion.
>   * Basically, use COND to dimension an array.  If COND is false/zero the
>   * array size will be -1 and we'll get a compilation error.
> --
> 2.2.2
>


More information about the mesa-dev mailing list