From 2ee6206751bf456e337d5144e4a697e69d8a04dc Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 3 Jun 2022 14:33:58 -0400 Subject: [PATCH] panfrost: Use C11 static_assert for enums Rather than asserting everything in an unused function, just do it in global context with C11 static_asserts. This is a bit neater now that we depend on C11 projectwide. Obvious follow-on from !16670. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Erik Faye-Lund Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 37b5571..3f6dd1c 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -120,21 +120,14 @@ struct panfrost_vertex_state { /* Statically assert that PIPE_* enums match the hardware enums. * (As long as they match, we don't need to translate them.) */ -UNUSED static void -pan_pipe_asserts() -{ -#define PIPE_ASSERT(x) STATIC_ASSERT((int)x) - - /* Compare functions are natural in both Gallium and Mali */ - PIPE_ASSERT(PIPE_FUNC_NEVER == MALI_FUNC_NEVER); - PIPE_ASSERT(PIPE_FUNC_LESS == MALI_FUNC_LESS); - PIPE_ASSERT(PIPE_FUNC_EQUAL == MALI_FUNC_EQUAL); - PIPE_ASSERT(PIPE_FUNC_LEQUAL == MALI_FUNC_LEQUAL); - PIPE_ASSERT(PIPE_FUNC_GREATER == MALI_FUNC_GREATER); - PIPE_ASSERT(PIPE_FUNC_NOTEQUAL == MALI_FUNC_NOT_EQUAL); - PIPE_ASSERT(PIPE_FUNC_GEQUAL == MALI_FUNC_GEQUAL); - PIPE_ASSERT(PIPE_FUNC_ALWAYS == MALI_FUNC_ALWAYS); -} +static_assert((int)PIPE_FUNC_NEVER == MALI_FUNC_NEVER, "must match"); +static_assert((int)PIPE_FUNC_LESS == MALI_FUNC_LESS, "must match"); +static_assert((int)PIPE_FUNC_EQUAL == MALI_FUNC_EQUAL, "must match"); +static_assert((int)PIPE_FUNC_LEQUAL == MALI_FUNC_LEQUAL, "must match"); +static_assert((int)PIPE_FUNC_GREATER == MALI_FUNC_GREATER, "must match"); +static_assert((int)PIPE_FUNC_NOTEQUAL == MALI_FUNC_NOT_EQUAL, "must match"); +static_assert((int)PIPE_FUNC_GEQUAL == MALI_FUNC_GEQUAL, "must match"); +static_assert((int)PIPE_FUNC_ALWAYS == MALI_FUNC_ALWAYS, "must match"); static inline enum mali_sample_pattern panfrost_sample_pattern(unsigned samples) -- 2.7.4