[PATCH v11 3/6] ptr_compress: add pointer compression library

Morten Brørup mb at smartsharesystems.com
Fri May 24 14:50:35 CEST 2024


> +#define BITS_REQUIRED_TO_STORE_VALUE(x) \
> +	((x) == 0 ? 1 : (sizeof(size_t) * CHAR_BIT - __builtin_clzl((size_t)x)))
> +
> +#define BIT_SHIFT_FROM_ALIGNMENT(x) ((x) == 0 ? 0 : __builtin_ctzl(x))

The two built-ins used are not available with MSVC.
Please see if you can find similar functions in /lib/eal/include/rte_bitops.h instead of defining these macros.

> +
> +#define CAN_USE_RTE_PTR_COMPRESS_16_SHIFT(mem_range, obj_alignment) \
> +	((BITS_REQUIRED_TO_STORE_VALUE(mem_range) - \
> +	BIT_SHIFT_FROM_ALIGNMENT(obj_alignment)) <= 16 ? 1 : 0)
> +
> +#define CAN_USE_RTE_PTR_COMPRESS_32_SHIFT(mem_range, obj_alignment) \
> +	((BITS_REQUIRED_TO_STORE_VALUE(mem_range) - \
> +	BIT_SHIFT_FROM_ALIGNMENT(obj_alignment)) <= 32 ? 1 : 0)
> +

These macros are in a public header file, and thus public.

Their names should begin with RTE_PTR_COMPRESS.
And they should have Doxygen descriptions.

Please also use them in the tests or some other code, for the CI to verify that MSVC can be build them.



More information about the dev mailing list