On Tue, Oct 1, 2024 at 6:39 PM Stephen Hemminger
<step...@networkplumber.org> wrote:
> diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
> index eec0400dad..595cadd5b8 100644
> --- a/lib/eal/include/rte_common.h
> +++ b/lib/eal/include/rte_common.h
> @@ -228,6 +228,40 @@ typedef uint16_t unaligned_uint16_t;
>  #define __rte_alloc_size(...)
>  #endif
>
> +/**
> + * Tells the compiler that the function returns a value that points to
> + * memory aligned by a function argument.
> + *
> + * Note: not enabled on Clang because it warns if align argument is zero.
> + */
> +#if defined(RTE_CC_GCC)
> +#define __rte_alloc_align(argno) __attribute__((alloc_align(argno)))
> +#else
> +#define __rte_alloc_align(argno)
> +#endif
> +
> +/**
> + * Tells the compiler this is a function like malloc and that the pointer
> + * returned cannot alias any other pointer (ie new memory).
> + */
> +#if defined(RTE_CC_GCC) || defined(RTE_CC_CLANG)
> +#define __rte_malloc __attribute__((malloc))
> +#else
> +#define __rte_malloc
> +#endif
> +
> +/**
> + * With recent GCC versions also able to track that proper
> + * dealloctor function is used for this pointer.

deallocator*


> + */
> +#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 110000)
> +#define __rte_dealloc(dealloc, argno) __attribute__((malloc(dealloc, argno)))
> +#define __rte_dealloc_free __rte_dealloc(rte_free, 1)

__rte_dealloc_free should not be in rte_common.h but in rte_malloc.h.


> +#else
> +#define __rte_dealloc(dealloc, argno)
> +#define __rte_dealloc_free
> +#endif
> +
>  #define RTE_PRIORITY_LOG 101
>  #define RTE_PRIORITY_BUS 110
>  #define RTE_PRIORITY_CLASS 120
> diff --git a/lib/eal/include/rte_malloc.h b/lib/eal/include/rte_malloc.h
> index 1f91e7bdde..9261605939 100644
> --- a/lib/eal/include/rte_malloc.h
> +++ b/lib/eal/include/rte_malloc.h
> @@ -31,6 +31,22 @@ struct rte_malloc_socket_stats {
>         size_t heap_allocsz_bytes; /**< Total allocated bytes on heap */
>  };
>
> +

Nit: no need for extra line.


> +/**
> + * Frees the memory space pointed to by the provided pointer.
> + *
> + * This pointer must have been returned by a previous call to
> + * rte_malloc(), rte_zmalloc(), rte_calloc() or rte_realloc(). The behaviour 
> of
> + * rte_free() is undefined if the pointer does not match this requirement.
> + *


-- 
David Marchand

Reply via email to