[PATCH v3 1/6] eal: variable first arguments of RTE_SHIFT_VALxx
Konstantin Ananyev
konstantin.ananyev at huawei.com
Fri Dec 19 14:06:35 CET 2025
> Macros RTE_SHIFT_VAL32 and RTE_SHIFT_VAL64 were implemented by applying
> UINT32_C or UINT64_C correspondingly to its first argument. As a
> consequence first argument had to be a constant. Replace UINT32_C and
> UINT64_C with casts to uint32_t and uint64_t to allow these arguments be
> variable. For constants the result should be the same.
>
> (Yes, technically UINT64_C promotes to uint_least64_t, not uint64_t, but
> I think most users of RTE_SHIFT_VAL64 expect the result to be uint64_t.)
>
> Signed-off-by: Marat Khalili <marat.khalili at huawei.com>
> Reviewed-by: Morten Brørup <mb at smartsharesystems.com>
> ---
> lib/eal/include/rte_bitops.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/eal/include/rte_bitops.h b/lib/eal/include/rte_bitops.h
> index 2d1b9d281c..aa6ac73abb 100644
> --- a/lib/eal/include/rte_bitops.h
> +++ b/lib/eal/include/rte_bitops.h
> @@ -51,7 +51,7 @@ extern "C" {
> * @param nr
> * The shift number in range of 0 to (32 - width of val).
> */
> -#define RTE_SHIFT_VAL32(val, nr) (UINT32_C(val) << (nr))
> +#define RTE_SHIFT_VAL32(val, nr) ((uint32_t)(val) << (nr))
>
> /**
> * Get the uint64_t shifted value.
> @@ -61,7 +61,7 @@ extern "C" {
> * @param nr
> * The shift number in range of 0 to (64 - width of val).
> */
> -#define RTE_SHIFT_VAL64(val, nr) (UINT64_C(val) << (nr))
> +#define RTE_SHIFT_VAL64(val, nr) ((uint64_t)(val) << (nr))
>
> /**
> * Generate a contiguous 32-bit mask
> --
Acked-by: Konstantin Ananyev <konstantin.ananyev at huawei.com>
> 2.43.0
More information about the stable
mailing list