[PATCH 10/74] backports: Add __counted_by attribute

Johannes Berg <[email protected]> Fri, 24 May 2024 19:07:22 +0200
Newsgroups org.kernel.vger.backports
Message-ID <20240524190906.03404f605970.I5f3ab2eb202242a2ccac0053fab1fb7d96c35829@changeid>
From: Gregory Greenman <[email protected]>

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

Signed-off-by: Gregory Greenman <[email protected]>
Signed-off-by: Johannes Berg <[email protected]>
---
 .../backport-include/linux/compiler_attributes.h    | 13 +++++++++++++
 1 file changed, 13 insertions(+)

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 */
-- 
2.45.1