Mesa (master): gallium/util: fix u_bit_scan_consecutive_range for mask == 0xffffffff
Marek Olšák
mareko at kemper.freedesktop.org
Mon Apr 18 17:51:40 UTC 2016
Module: Mesa
Branch: master
Commit: 9434aa8103e93c9a80421b20f04b526ef543d46e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9434aa8103e93c9a80421b20f04b526ef543d46e
Author: Marek Olšák <marek.olsak at amd.com>
Date: Fri Apr 15 22:08:57 2016 +0200
gallium/util: fix u_bit_scan_consecutive_range for mask == 0xffffffff
The second ffs returns 0, yielding count == -1.
v2: change 1 to 1u
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
---
src/gallium/auxiliary/util/u_math.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index b4ac0db..0a82915 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -518,9 +518,15 @@ u_bit_scan64(uint64_t *mask)
static inline void
u_bit_scan_consecutive_range(unsigned *mask, int *start, int *count)
{
+ if (*mask == 0xffffffff) {
+ *start = 0;
+ *count = 32;
+ *mask = 0;
+ return;
+ }
*start = ffs(*mask) - 1;
*count = ffs(~(*mask >> *start)) - 1;
- *mask &= ~(((1 << *count) - 1) << *start);
+ *mask &= ~(((1u << *count) - 1) << *start);
}
/**
More information about the mesa-commit
mailing list