From 0539dec10f1c1efcb2c18858cc0aad3630211a7b Mon Sep 17 00:00:00 2001 From: Rohan Garg Date: Thu, 15 Dec 2022 17:52:20 +0100 Subject: [PATCH] util: move pot functions to use existing macros MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Rohan Garg Reviewed-by: Erik Faye-Lund Reviewed-by: Marek Olšák Part-of: --- src/util/bitscan.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/util/bitscan.h b/src/util/bitscan.h index 53cbb91..0e7019a 100644 --- a/src/util/bitscan.h +++ b/src/util/bitscan.h @@ -42,6 +42,8 @@ #include #endif +#include "macros.h" + #ifdef __cplusplus extern "C" { #endif @@ -128,7 +130,7 @@ u_bit_scan64(uint64_t *mask) 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. @@ -139,7 +141,7 @@ util_is_power_of_two_or_zero(unsigned v) 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. @@ -162,7 +164,7 @@ util_is_power_of_two_nonzero(unsigned v) #ifdef __POPCNT__ return _mm_popcnt_u32(v) == 1; #else - return v != 0 && (v & (v - 1)) == 0; + return v != 0 && IS_POT(v); #endif } -- 2.7.4