util: move pot functions to use existing macros
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>
This commit is contained in:
@@ -42,6 +42,8 @@
|
|||||||
#include <popcntintrin.h>
|
#include <popcntintrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -128,7 +130,7 @@ u_bit_scan64(uint64_t *mask)
|
|||||||
static inline bool
|
static inline bool
|
||||||
util_is_power_of_two_or_zero(unsigned v)
|
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.
|
/* Determine if an uint64_t value is a power of two.
|
||||||
@@ -139,7 +141,7 @@ util_is_power_of_two_or_zero(unsigned v)
|
|||||||
static inline bool
|
static inline bool
|
||||||
util_is_power_of_two_or_zero64(uint64_t v)
|
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.
|
/* Determine if an unsigned value is a power of two.
|
||||||
@@ -162,7 +164,7 @@ util_is_power_of_two_nonzero(unsigned v)
|
|||||||
#ifdef __POPCNT__
|
#ifdef __POPCNT__
|
||||||
return _mm_popcnt_u32(v) == 1;
|
return _mm_popcnt_u32(v) == 1;
|
||||||
#else
|
#else
|
||||||
return v != 0 && (v & (v - 1)) == 0;
|
return v != 0 && IS_POT(v);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user