Compiler Attributes: Add __counted_by macro
[platform/kernel/linux-rpi.git] / include / linux / compiler_attributes.h
index e659cb6..5588bff 100644 (file)
 #endif
 
 /*
+ * Optional: only supported since gcc >= 14
+ * Optional: only supported since clang >= 17
+ *
+ *   gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
+ * clang: https://reviews.llvm.org/D148381
+ */
+#if __has_attribute(__element_count__)
+# define __counted_by(member)          __attribute__((__element_count__(#member)))
+#else
+# define __counted_by(member)
+#endif
+
+/*
  * Optional: only supported since clang >= 14.0
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-error-function-attribute