On Sun, 11 Jan 2026 11:00:58 -0500
[email protected] wrote:
> +#define RTE_PTR_ADD(ptr, x) \
> + (__extension__ ({ \
> + /* Diagnostics suppressed for internal macro operations only. \
> + * Compiler type-checks all _Generic branches even when
> unselected, \
> + * triggering warnings with no external impact. */ \
> + __rte_diagnostic_push \
> + __rte_diagnostic_ignored_wcast_qual \
> + /* Uses uintptr_t arithmetic for integer types (API
> compatibility), \
> + * and char* arithmetic for pointer types (enables
> optimization). */ \
> + __auto_type _ptr_result = _Generic((ptr), \
NAK
No ignoring cast qualifiers. Is this just to preserve const?
DPDK does not guarantee API compatibility across versions, only ABI.
Why not clarify the code by using inline?
static inline void *__rte_ptr_offset(void *ptr, long delta)
{
return (char *)ptr + delta;
}
#define RTE_PTR_ADD(ptr, x) __rte_ptr_offset(ptr, (long)(x))
#define RTE_PTR_SUB(ptr, x) __rte_ptr_offset(ptr, -(long)(x))
What about RTE_PTR_SUB() and RTE_PTR_DIFF()?