[dpdk-dev] [PATCH v3 1/3] net/sfc: fix power of 2 round up when align has smaller type

Ferruh Yigit ferruh.yigit at intel.com
Wed Jul 24 18:57:34 CEST 2019


On 7/24/2019 2:16 PM, Andrew Rybchenko wrote:
> Substitute driver-defined P2ROUNDUP() h with EFX_P2ROUNDUP()
> defined in libefx.
> 
> Cast value and alignment to one specified type to guarantee result
> correctness.
> 
> Fixes: e1b944598579 ("net/sfc: build libefx")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Andrew Rybchenko <arybchenko at solarflare.com>

<...>

> @@ -29,6 +29,10 @@ extern "C" {
>  /* The macro expands divider twice */
>  #define	EFX_DIV_ROUND_UP(_n, _d)		(((_n) + (_d) - 1) / (_d))
>  
> +/* Round value up to the nearest power of two. */
> +#define	EFX_P2ROUNDUP(_type, _value, _align)	\
> +	(-(-(_type)(_value) & -(_type)(_align)))
> +

I trust you it does what it says J

Just a high level comment, should we have some kind of tools/utilities file in
one of the libraries so everyone can use/share them?


More information about the dev mailing list