[igt-dev] [PATCH 1/2] lib/igt_aux: fix roundup_power_of_two implementation

Andrzej Hajda andrzej.hajda at intel.com
Thu Oct 26 15:50:29 UTC 2023


For arguments greater than (1<<31) 64bit value must
be shifted, otherwise the result is incorrect.

Signed-off-by: Andrzej Hajda <andrzej.hajda at intel.com>
---
 lib/igt_aux.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index fb76b031318..4d887045af7 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -329,7 +329,7 @@ void pipewire_pulse_stop_reserve(void);
 						64 - __builtin_clzll(x), \
 						32 - __builtin_clz(x)) : 0)
 
-#define roundup_power_of_two(x) ((x) != 0 ? 1 << igt_fls((x) - 1) : 0)
+#define roundup_power_of_two(x) ((x) != 0 ? 1ULL << igt_fls((x) - 1) : 0)
 
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
 

-- 
2.34.1



More information about the igt-dev mailing list