[dpdk-dev] [PATCH v5 04/11] eal/mem: extract common code for memseg list initialization

Thomas Monjalon thomas at monjalon.net
Thu May 28 09:31:54 CEST 2020


25/05/2020 02:37, Dmitry Kozlyuk:
> All supported OS create memory segment lists (MSL) and reserve VA space
> for them in a nearly identical way. Move common code into EAL private
> functions to reduce duplication.
> 
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk at gmail.com>
> ---
> +void
> +eal_memseg_list_populate(struct rte_memseg_list *msl, void *addr, int n_segs)
> +{
> +	uint64_t page_sz = msl->page_sz;
[...]
> +		addr = RTE_PTR_ADD(addr, page_sz);

This is an error in 32-bit compilation:

lib/librte_eal/common/eal_common_memory.c:
In function ‘eal_memseg_list_populate’: rte_common.h:215:30: error:
cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  215 | #define RTE_PTR_ADD(ptr, x) ((void*)((uintptr_t)(ptr) + (x)))
      |                              ^

The original code was doing a cast to size_t.

> --- a/lib/librte_eal/linux/eal_memory.c
> +++ b/lib/librte_eal/linux/eal_memory.c
> -			addr = RTE_PTR_ADD(addr, (size_t)page_sz);

I believe the correct cast should be uintptr_t.
Maybe it would be even more correct to do this cast inside RTE_PTR_ADD?




More information about the dev mailing list