DPDK patches and discussions
 help / color / mirror / Atom feed
* [RFC] eal: add rte_counted_by attribute
@ 2024-03-12 21:01 Stephen Hemminger
  0 siblings, 0 replies; only message in thread
From: Stephen Hemminger @ 2024-03-12 21:01 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Both Gcc 14 and clang support this in latest versions.
Add to EAL first, then instrument flexible arrays.

[1] https://reviews.llvm.org/D148381
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/include/rte_compat.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/eal/include/rte_compat.h b/lib/eal/include/rte_compat.h
index 716bc0361640..6bf6b0baaccf 100644
--- a/lib/eal/include/rte_compat.h
+++ b/lib/eal/include/rte_compat.h
@@ -68,6 +68,16 @@ _Pragma("GCC diagnostic pop")
 __attribute__((section(".text.internal")))
 #endif
 
+/*
+ * Used to by ASAN bounds checker for flexible arrays
+ * Supported by Gcc >= 14 and clang >=18
+ */
+#if __has_attribute(__element_count__)
+# define __rte_counted_by(member)	__attribute__((__element_count__(member)))
+#else
+# define __rte_counted_by(member)
+#endif
+
 #endif
 
 #ifdef __cplusplus
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-12 21:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-12 21:01 [RFC] eal: add rte_counted_by attribute Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).