[dpdk-dev] [PATCH v3 3/5] common: add missing implementations

Burakov, Anatoly anatoly.burakov at intel.com
Thu Nov 15 11:07:52 CET 2018


On 15-Nov-18 8:40 AM, Jerin Jacob wrote:
> -----Original Message-----
>> Date: Wed, 14 Nov 2018 16:47:08 +0000
>> From: Anatoly Burakov <anatoly.burakov at intel.com>
>> To: dev at dpdk.org
>> CC: cristian.dumitrescu at intel.com, thomas at monjalon.net,
>>   bruce.richardson at intel.com, ferruh.yigit at intel.com,
>>   jasvinder.singh at intel.com
>> Subject: [dpdk-dev] [PATCH v3 3/5] common: add missing implementations
>> X-Mailer: git-send-email 1.7.0.7
>>
>> External Email
>>
>> Implement missing functions for 32-bit safe bsf, as well as 64-bit
>> fls and log2.
>>
>> Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
>> Acked-by: Cristian Dumitrescu <cristian.dumitrescu at intel.com>
>> ---
> 
>> +/**
>> + * Return the last (most-significant) bit set.
>> + *
>> + * @note The last (most significant) bit is at position 32.
> 
> s/position 32/position 64
> 
>> + * @note rte_fls_u32(0) = 0, rte_fls_u32(1) = 1, rte_fls_u32(0x80000000) = 32
> 
> Fix here too
> 
> IMO, it is better to add unit test case for newly added common functions
> in test/test/test_common.c

Good catches and good ideas, thanks!

> 
>> + *
>> + * @param x
>> + *     The input parameter.
>> + * @return
>> + *     The last (most-significant) bit set, or 0 if the input is 0.
>> + */
>> +static inline int
>> +rte_fls_u64(uint64_t x)
>> +{
>> +       return (x == 0) ? 0 : 64 - __builtin_clzll(x);
>> +}
>> +
> 


-- 
Thanks,
Anatoly


More information about the dev mailing list