|
| 1 | +From b63f79524e6f30e58692bc9ee57c6e6e0dd10de4 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Christian Marangi < [email protected]> |
| 3 | +Date: Wed, 10 Dec 2025 22:37:03 +0100 |
| 4 | +Subject: [PATCH] backports: move __counted_by to compiler_types.h header |
| 5 | + |
| 6 | +Port f06e108a3dc5 ("Compiler Attributes: disable __counted_by for clang |
| 7 | +< 19.1.3") changes to align with new kernel version that moved the |
| 8 | +__counted_by to a new header file. |
| 9 | + |
| 10 | +Signed-off-by: Christian Marangi < [email protected]> |
| 11 | +--- |
| 12 | + .../linux/compiler_attributes.h | 15 ------------ |
| 13 | + .../backport-include/linux/compiler_types.h | 23 +++++++++++++++++++ |
| 14 | + 2 files changed, 23 insertions(+), 15 deletions(-) |
| 15 | + create mode 100644 backport-include/linux/compiler_types.h |
| 16 | + |
| 17 | +--- a/backport-include/linux/compiler_attributes.h |
| 18 | ++++ b/backport-include/linux/compiler_attributes.h |
| 19 | +@@ -31,19 +31,4 @@ |
| 20 | + #endif |
| 21 | + #endif /* fallthrough */ |
| 22 | + |
| 23 | +-#ifndef __counted_by |
| 24 | +-/* |
| 25 | +- * Optional: only supported since gcc >= 14 |
| 26 | +- * Optional: only supported since clang >= 17 |
| 27 | +- * |
| 28 | +- * gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896 |
| 29 | +- * clang: https://reviews.llvm.org/D148381 |
| 30 | +- */ |
| 31 | +-#if __has_attribute(__element_count__) |
| 32 | +-# define __counted_by(member) __attribute__((__element_count__(#member))) |
| 33 | +-#else |
| 34 | +-# define __counted_by(member) |
| 35 | +-#endif |
| 36 | +-#endif |
| 37 | +- |
| 38 | + #endif /* _BACKPORTS_LINUX_COMPILER_ATTRIBUTES_H */ |
| 39 | +--- /dev/null |
| 40 | ++++ b/backport-include/linux/compiler_types.h |
| 41 | +@@ -0,0 +1,23 @@ |
| 42 | ++#ifndef _BACKPORTS_LINUX_COMPILER_TYPES_H |
| 43 | ++#define _BACKPORTS_LINUX_COMPILER_TYPES_H 1 |
| 44 | ++ |
| 45 | ++#if LINUX_VERSION_IS_GEQ(6,12,1) |
| 46 | ++#include_next <linux/compiler_types.h> |
| 47 | ++#endif |
| 48 | ++ |
| 49 | ++#ifndef __counted_by |
| 50 | ++/* |
| 51 | ++ * Optional: only supported since gcc >= 14 |
| 52 | ++ * Optional: only supported since clang >= 17 |
| 53 | ++ * |
| 54 | ++ * gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896 |
| 55 | ++ * clang: https://reviews.llvm.org/D148381 |
| 56 | ++ */ |
| 57 | ++#if __has_attribute(__element_count__) |
| 58 | ++# define __counted_by(member) __attribute__((__element_count__(#member))) |
| 59 | ++#else |
| 60 | ++# define __counted_by(member) |
| 61 | ++#endif |
| 62 | ++#endif |
| 63 | ++ |
| 64 | ++#endif /* _BACKPORTS_LINUX_COMPILER_TYPES_H */ |
0 commit comments