Signed-off-by: Rohan Garg <rohan.garg@intel.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20153>
#include <popcntintrin.h>
#endif
+#include "macros.h"
+
#ifdef __cplusplus
extern "C" {
#endif
static inline bool
util_is_power_of_two_or_zero(unsigned v)
{
- return (v & (v - 1)) == 0;
+ return IS_POT(v);
}
/* Determine if an uint64_t value is a power of two.
static inline bool
util_is_power_of_two_or_zero64(uint64_t v)
{
- return (v & (v - 1)) == 0;
+ return IS_POT(v);
}
/* Determine if an unsigned value is a power of two.
#ifdef __POPCNT__
return _mm_popcnt_u32(v) == 1;
#else
- return v != 0 && (v & (v - 1)) == 0;
+ return v != 0 && IS_POT(v);
#endif
}