From: Timothy Arceri Date: Wed, 6 Feb 2019 01:18:52 +0000 (+1100) Subject: util: move BITFIELD macros to util/macros.h X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d0abbaa528a0b23999079951c88effb3f2c0d27a;p=mesa.git util: move BITFIELD macros to util/macros.h Reviewed-by: Jason Ekstrand --- diff --git a/src/mesa/main/menums.h b/src/mesa/main/menums.h index 40b16cb9cac..79c14da5ea0 100644 --- a/src/mesa/main/menums.h +++ b/src/mesa/main/menums.h @@ -186,28 +186,4 @@ enum mesa_debug_severity /** @} */ -/** Set a single bit */ -#define BITFIELD_BIT(b) (1u << (b)) -/** Set all bits up to excluding bit b */ -#define BITFIELD_MASK(b) \ - ((b) == 32 ? (~0u) : BITFIELD_BIT((b) % 32) - 1) -/** Set count bits starting from bit b */ -#define BITFIELD_RANGE(b, count) \ - (BITFIELD_MASK((b) + (count)) & ~BITFIELD_MASK(b)) - - -/** - * \name 64-bit extension of GLbitfield. - */ -/*@{*/ - -/** Set a single bit */ -#define BITFIELD64_BIT(b) (1ull << (b)) -/** Set all bits up to excluding bit b */ -#define BITFIELD64_MASK(b) \ - ((b) == 64 ? (~0ull) : BITFIELD64_BIT(b) - 1) -/** Set count bits starting from bit b */ -#define BITFIELD64_RANGE(b, count) \ - (BITFIELD64_MASK((b) + (count)) & ~BITFIELD64_MASK(b)) - #endif diff --git a/src/util/macros.h b/src/util/macros.h index c47bbb6dfcd..73d4e68b99a 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -296,4 +296,22 @@ do { \ #define EXPLICIT_CONVERSION #endif +/** Set a single bit */ +#define BITFIELD_BIT(b) (1u << (b)) +/** Set all bits up to excluding bit b */ +#define BITFIELD_MASK(b) \ + ((b) == 32 ? (~0u) : BITFIELD_BIT((b) % 32) - 1) +/** Set count bits starting from bit b */ +#define BITFIELD_RANGE(b, count) \ + (BITFIELD_MASK((b) + (count)) & ~BITFIELD_MASK(b)) + +/** Set a single bit */ +#define BITFIELD64_BIT(b) (1ull << (b)) +/** Set all bits up to excluding bit b */ +#define BITFIELD64_MASK(b) \ + ((b) == 64 ? (~0ull) : BITFIELD64_BIT(b) - 1) +/** Set count bits starting from bit b */ +#define BITFIELD64_RANGE(b, count) \ + (BITFIELD64_MASK((b) + (count)) & ~BITFIELD64_MASK(b)) + #endif /* UTIL_MACROS_H */