[Mesa-dev] [PATCH 1/3] glsl: Add convenience function get_sampler_instance

Matt Turner mattst88 at gmail.com
Thu Dec 4 21:34:39 PST 2014


On Thu, Dec 4, 2014 at 7:54 PM, Carl Worth <cworth at cworth.org> wrote:
> On Thu, Dec 04 2014, Carl Worth wrote:
>> So I think I'll follow up with a separate patch to clean these up.
>
> Before I do that, I noticed the following in util/macros.h:
>
>         /**
>          * 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)
>         #endif
>
> I don't know under what conditions HAVE___BUILTIN_UNREACHABLE might not
> be defined. But in the final fallback below shouldn't we at least define
> unreachable to use assert:

__builtin_unreachable() is available in gcc >= 4.5 and unknown
versions of clang.

>
>         #ifndef unreachable
>         #define unreachable(str) assert(!str)
>         #endif

Seems like a good idea.


More information about the mesa-dev mailing list