eal: fix cache guard for pedantic compilation
PATCH 1/1 eal: fix cache guard for pedantic compilation
The cache guard macro uses __COUNTER__ to generate unique names. However, although most C compilers support __COUNTER__, it is not yet part of the C standard, so compilation fails when building in pedantic mode.
The macro was changed to use __LINE__ instead.
--- lib/eal/include/rte_common.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +5 -1
@@ -751,8 +751,12 @@ rte_is_aligned(const void * const __rte_restrict ptr, const unsigned int align)* * Use as spacing between data accessed by different lcores, * to prevent cache thrashing on hardware with speculative prefetching. +* +* Note: Although __COUNTER__ would be better for uniqueness, it is not yet +* (March 2026) part of the C standard, so compilation would fail when building +* in pedantic mode. */ -#define RTE_CACHE_GUARD _RTE_CACHE_GUARD_HELPER1(__COUNTER__) +#define RTE_CACHE_GUARD _RTE_CACHE_GUARD_HELPER1(__LINE__)/*********** PA/IOVA type definitions ********/
Signature · 1 line
2.43.0
Forgot cc stable.
Quoted 41 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Monday, 23 March 2026 09.12The cache guard macro uses
__COUNTER__to generate unique names. However, although most C compilers support__COUNTER__, it is not yet part of the C standard, so compilation fails when building in pedantic mode.
The macro was changed to use__LINE__instead.Fixes 65f600c0f000 ("eal: add empty cache line macro")Signed-off-by Morten Brørup <[email protected]>--- lib/eal/include/rte_common.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)lib/eal/include/rte_common.h +0
-0@@ -751,8 +751,12 @@ rte_is_aligned(const void * const __rte_restrict ptr, const unsigned int align) * * Use as spacing between data accessed by different lcores, * to prevent cache thrashing on hardware with speculativeprefetching.
+ *
+ * Note: Although__COUNTER__would be better for uniqueness, it is not yet
+ * (March 2026) part of the C standard, so compilation would fail when building
+ * in pedantic mode.
*/lib/eal/include/rte_common.h +1
-2-#define RTE_CACHE_GUARD _RTE_CACHE_GUARD_HELPER1(__COUNTER__) +#define RTE_CACHE_GUARD _RTE_CACHE_GUARD_HELPER1(__LINE__)/*********** PA/IOVA type definitions ********/ --2.43.0
Thomas Monjalon
Applied23/03/2026 09:12, Morten Brørup:
Quoted 9 lines
The cache guard macro uses
__COUNTER__to generate unique names. However, although most C compilers support__COUNTER__, it is not yet part of the C standard, so compilation fails when building in pedantic mode.
The macro was changed to use__LINE__instead.Fixes 65f600c0f000 ("eal: add empty cache line macro")Signed-off-by Morten Brørup <[email protected]>
Applied, thanks.