[PATCH 2/5] lib/eal: add portable version of __builtin_add_overflow
Andre Muezerie
andremue at linux.microsoft.com
Fri Jan 3 21:38:44 CET 2025
On Fri, Jan 03, 2025 at 09:19:42AM +0100, Morten Brørup wrote:
> > From: Andre Muezerie [mailto:andremue at linux.microsoft.com]
> > Sent: Thursday, 2 January 2025 23.33
> >
> > __builtin_add_overflow is gcc specific. There's a need for a portable
> > version that can also be used with other compilers.
> >
> > This patch introduces __rte_add_overflow_u8, __rte_add_overflow_u16
> > and __rte_add_overflow_u32.
>
> Instead of the proposed three type-specific macros, add one generic rte_add_overflow(a, b, res) macro, like rte_bit_test() [1] using "_Generic".
>
> [1]: https://elixir.bootlin.com/dpdk/v24.11.1/source/lib/eal/include/rte_bitops.h#L130
>
> You may still need the type-specific macros as internal helpers for the MSVC implementation.
>
> Furthermore, a 64 bit variant might be useful.
>
> PS: DPDK naming convention typically uses just "8"/"16"/"32" postfix to the function name, not "_u8"/"_u16"/"_u32".
These are great suggestions. I'll incorporate them in the v2 of this series.
More information about the dev
mailing list