diff mbox series

[10/74] backports: Add __counted_by attribute

Message ID 20240524190906.03404f605970.I5f3ab2eb202242a2ccac0053fab1fb7d96c35829@changeid (mailing list archive)
State New, archived
Headers show
Series backport updates from Intel | expand

Commit Message

Johannes Berg May 24, 2024, 5:07 p.m. UTC
From: Gregory Greenman <gregory.greenman@intel.com>

This adds __counted_by attribute from
c8248faf3ca2 ("Compiler Attributes: counted_by: Adjust name and identifier expansion")

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 .../backport-include/linux/compiler_attributes.h    | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/backport/backport-include/linux/compiler_attributes.h b/backport/backport-include/linux/compiler_attributes.h
index 31ddc163e09a..6a0ffca2e102 100644
--- a/backport/backport-include/linux/compiler_attributes.h
+++ b/backport/backport-include/linux/compiler_attributes.h
@@ -31,4 +31,17 @@ 
 #endif
 #endif /* fallthrough */
 
+/*
+ * Optional: only supported since gcc >= 14
+ * Optional: only supported since clang >= 18
+ *
+ *   gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
+ * clang: https://reviews.llvm.org/D148381
+ */
+#if __has_attribute(__counted_by__)
+# define __counted_by(member)		__attribute__((__counted_by__(member)))
+#else
+# define __counted_by(member)
+#endif
+
 #endif /* _BACKPORTS_LINUX_COMPILER_ATTRIBUTES_H */