[ovs-dev] [PATCH v2 2/9] lib/util: Add ctz64() and popcount64().
Jarno Rajahalme
jrajahalme at nicira.com
Mon Nov 18 17:51:10 UTC 2013
Pushed to master,
Jarno
On Nov 15, 2013, at 4:15 PM, Jarno Rajahalme <jrajahalme at nicira.com> wrote:
>
>> On Nov 15, 2013, at 4:08 PM, Ben Pfaff <blp at nicira.com> wrote:
>>
>>> On Fri, Nov 15, 2013 at 04:03:32PM -0800, Jarno Rajahalme wrote:
>>>
>>>>> On Nov 15, 2013, at 3:48 PM, Ben Pfaff <blp at nicira.com> wrote:
>>>>>
>>>>> On Wed, Nov 13, 2013 at 01:32:42PM -0800, Jarno Rajahalme wrote:
>>>>> Add raw_ctz64(), ctz64(), and popcount64() using builtins when
>>>>> available.
>>>>>
>>>>> I'm not sure if the "UINT64_MAX == ~0UL" and "UINT64_MAX == ~0ULL"
>>>>> work in all cases as I imagine they would.
>>>>
>>>> I think you could use ULONG_MAX and ULLONG_MAX, any reason not to?
>>>
>>> It doesn't matter if they are the same in some cases, right?
>>
>> Actually, I guess we can just skip the test entirely. GCC always
>> supports 64-bit integers as unsigned long long, so this by itself
>> ought to do the trick:
>>
>> #elif __GNUC__ >= 4
>> static inline int
>> raw_ctz64(uint64_t n)
>> {
>> return __builtin_ctzll(n);
>> }
>> static inline int
>> popcount64(uint64_t n)
>> {
>> return __builtin_popcountll(n);
>> }
>
> Thanks Ben, I'll fold this in.
>
> Jarno
>
More information about the dev
mailing list