Skip to contentSkip to conversation

eal: fix cache guard for pedantic compilation

PATCH Applied Morten Brørup 2 participants 3 messages Mar 23 – Mar 25

lore
Share & tools
lore
#0 lore raw

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.

Fixes 65f600c0f000 ("eal: add empty cache line macro")
---
 lib/eal/include/rte_common.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +5 -1
index 573bf4f2ce..97865aaa39 100644
@@ -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
#1 lore raw

Forgot cc stable.

Quoted 41 lines

From: Morten Brørup [mailto:[email protected]]
Sent: Monday, 23 March 2026 09.12

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")
---
 lib/eal/include/rte_common.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/eal/include/rte_common.h +0 -0
index 573bf4f2ce..97865aaa39 100644
@@ -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.
*/

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

#2 lore raw
In reply to Morten Brørup

23/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")

Applied, thanks.