[RFC] eal: add rte_counted_by attribute

Message ID 20240312210308.8788-1-stephen@networkplumber.org (mailing list archive)
State Rejected
Delegated to: Thomas Monjalon
Series [RFC] eal: add rte_counted_by attribute |


Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build fail github build: failed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Stephen Hemminger March 12, 2024, 9:01 p.m. UTC
  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")
+ * 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)))
+# define __rte_counted_by(member)
 #ifdef __cplusplus