[Mesa-dev] [PATCH 12/13] gallium/util: Add u_bit_scan_consecutive_range64.

Marek Olšák maraeo at gmail.com
Fri Apr 15 19:51:39 UTC 2016


On Thu, Apr 14, 2016 at 8:05 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> On 13.04.2016 20:35, Bas Nieuwenhuizen wrote:
>>
>> For use by radeonsi.
>>
>> Signed-off-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
>> ---
>>   src/gallium/auxiliary/util/u_math.h | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/src/gallium/auxiliary/util/u_math.h
>> b/src/gallium/auxiliary/util/u_math.h
>> index b4ac0db..3a468e4 100644
>> --- a/src/gallium/auxiliary/util/u_math.h
>> +++ b/src/gallium/auxiliary/util/u_math.h
>> @@ -523,6 +523,14 @@ u_bit_scan_consecutive_range(unsigned *mask, int
>> *start, int *count)
>>      *mask &= ~(((1 << *count) - 1) << *start);
>>   }
>>
>> +static inline void
>> +u_bit_scan_consecutive_range64(uint64_t *mask, int *start, int *count)
>> +{
>> +   *start = ffsll(*mask) - 1;
>> +   *count = ffsll(~(*mask >> *start)) - 1;
>> +   *mask &= ~(((1llu << *count) - 1) << *start);
>> +}
>> +
>
>
> I don't think this does the right thing when *mask is ~0llu: *start will be
> 0 (correct), *count will be -1, and *mask will most likely be undefined.

It looks like the 32-bit version has the same bug.

Marek


More information about the mesa-dev mailing list