[PATCH 17/20] headers: add __counted_by macro for kernels < 6.6
Yi Cong <[email protected]> Wed, 24 Jun 2026 15:38:41 +0800
| Newsgroups | org.kernel.vger.backports |
|---|---|
| Message-ID | <[email protected]> |
From: Yi Cong <[email protected]> __counted_by() was introduced in v6.6 as a compiler attribute for flexible array member bounds checking. Add a definition that expands to the attribute when supported by the compiler, or to nothing otherwise. Signed-off-by: Yi Cong <[email protected]> --- backport/backport-include/linux/compiler_attributes.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backport/backport-include/linux/compiler_attributes.h b/backport/backport-include/linux/compiler_attributes.h index 31ddc163..b39b66b5 100644 --- a/backport/backport-include/linux/compiler_attributes.h +++ b/backport/backport-include/linux/compiler_attributes.h @@ -31,4 +31,12 @@ #endif #endif /* fallthrough */ +#ifndef __counted_by +#if __has_attribute(__counted_by__) +# define __counted_by(member) __attribute__((__counted_by__(member))) +#else +# define __counted_by(member) +#endif +#endif /* __counted_by */ + #endif /* _BACKPORTS_LINUX_COMPILER_ATTRIBUTES_H */ -- 2.43.0