[Mesa-dev] [PATCH] gallium/util: fix u_bit_scan_consecutive_range for mask == 0xffffffff

Marek Olšák maraeo at gmail.com
Sat Apr 16 00:09:32 UTC 2016


On Sat, Apr 16, 2016 at 12:40 AM, Bas Nieuwenhuizen
<bas at basnieuwenhuizen.nl> wrote:
> On Sat, Apr 16, 2016 at 12:34 AM, Marek Olšák <maraeo at gmail.com> wrote:
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> The second ffs returns 0, yielding count == -1.
>> ---
>>  src/gallium/auxiliary/util/u_math.h | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
>> index b4ac0db..2880eea 100644
>> --- a/src/gallium/auxiliary/util/u_math.h
>> +++ b/src/gallium/auxiliary/util/u_math.h
>> @@ -518,6 +518,12 @@ 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);
>
> This signed shift needs to be fixed for *count == 31 too. Either way,
>
> Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

Thanks, I'll change 1 to 1u.

Marek


More information about the mesa-dev mailing list