util: tune signatures of generated enum operators

This allows use of these operators in a constexpr context and silences
a clang -Wunused-function warning.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10784>
This commit is contained in:
Tony Wasserka 2021-05-13 12:04:11 +02:00 committed by Marge Bot
parent c0f4bb9a22
commit a50d5b13be
1 changed files with 4 additions and 3 deletions

View File

@ -23,12 +23,13 @@
#ifdef __cplusplus
#include "macros.h"
#include <type_traits>
// some enum helpers
#define MESA_DEFINE_CPP_ENUM_BINARY_OPERATOR(Enum, op) \
extern "C++" { \
static inline \
UNUSED static constexpr \
Enum operator op (Enum a, Enum b) \
{ \
using IntType = std::underlying_type_t<Enum>; \
@ -37,7 +38,7 @@ Enum operator op (Enum a, Enum b) \
return static_cast<Enum>(ua op ub); \
} \
\
static inline \
UNUSED static constexpr \
Enum& operator op##= (Enum &a, Enum b) \
{ \
using IntType = std::underlying_type_t<Enum>; \
@ -51,7 +52,7 @@ Enum& operator op##= (Enum &a, Enum b) \
#define MESA_DEFINE_CPP_ENUM_UNARY_OPERATOR(Enum, op) \
extern "C++" { \
static inline \
UNUSED static constexpr \
Enum operator op (Enum a) \
{ \
using IntType = std::underlying_type_t<Enum>; \