Brian Paul <bri...@vmware.com> writes: > On 12/07/2013 06:17 PM, Francisco Jerez wrote: >>[...] >> + default: >> + unreachable(); > > I think I'd like to see an assertion or _mesa_problem() call to catch > unhandled cases if new texture targets are added in the future. > > How about having the unreachable() macro print out an error and abort if it's ever reached? See the attached patch.
>> + } >> +} >> + >> + >> +/** >> + * Return the number of layers present in the given level of an array, >> + * cubemap or 3D texture. If the texture is not layered return zero. >> + */ >> +GLuint >> +_mesa_get_texture_layers(struct gl_texture_object *texObj, GLint level) > > The pointer could be const-qualifed and level could be GLuint. > I made level a signed integer deriberately, because texture levels seem to be declared as GLint everywhere else. Thanks. >[...]
From a50fecf61ee4cfba453becbada0972828c982c96 Mon Sep 17 00:00:00 2001 From: Francisco Jerez <curroje...@riseup.net> Date: Tue, 10 Dec 2013 16:23:24 +0100 Subject: [PATCH] mesa: Make the unreachable macro abort when reached in debug builds. --- src/mesa/main/compiler.h | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index 97075f5..58e5f5d 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -252,16 +252,23 @@ static INLINE GLuint CPU_TO_LE32(GLuint x) * Unreachable macro. Useful for suppressing "control reaches end of non-void * function" warnings. */ -#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5 -#define unreachable() __builtin_unreachable() -#elif (defined(__clang__) && defined(__has_builtin)) -# if __has_builtin(__builtin_unreachable) -# define unreachable() __builtin_unreachable() -# endif -#endif - -#ifndef unreachable -#define unreachable() +#ifdef NDEBUG +# if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5 +# define unreachable() __builtin_unreachable() +# elif (defined(__clang__) && defined(__has_builtin)) +# if __has_builtin(__builtin_unreachable) +# define unreachable() __builtin_unreachable() +# endif +# endif +# ifndef unreachable +# define unreachable() +# endif +#else +# define unreachable() do { \ + fprintf(stderr, "Unreachable executed at %s:%d\n", \ + __FILE__, __LINE__); \ + abort(); \ + } while (0) #endif #if (__GNUC__ >= 3) -- 1.8.5.1
pgpXQCOYLxUiB.pgp
Description: PGP signature
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev