[dpdk-dev] [PATCH v2 1/2] eal: add API to align integer to previous power of 2

Matan Azrad matan at mellanox.com
Tue Feb 27 20:30:40 CET 2018


Hi Pavan

From: Pavan Nikhilesh, Monday, February 26, 2018 9:10 PM
> Hi Matan,
> 
> On Mon, Feb 19, 2018 at 12:09:46PM +0000, Matan Azrad wrote:
> > Since you are using the same 5 lines from the rte_align32pow2() function, I
>> think this part can be in a separate function to do reuse.
> > Also the "fill ones 32" function can be used for other purpose.
> > What do you think?
> 
> I do agree that it would be cleaner to have a common function for both, but
> not able to decide on a appropriate function name "fill ones 32" doesn't
> convey what the function truly does. If you have a cleaner name do suggest, i
> will roll up a v3 adding the function and experimental tag.

Sure.

I'm suggesting next names:
rte_combine32ms1b(register uint32_t x)
rte_combine64ms1b(register uint64_t x)

The description may be something like:
combine the upper bits into the LSBs to construct a value with the same most significant 1 as x but all 1's under it.

I would add the register keyword for each variables in all the align functions here just to hint for the compiler that it's better to save this variables in register and not in memory.  

Matan.
> Thanks,
> Pavan
> 
> >
> >


More information about the dev mailing list