summaryrefslogtreecommitdiff
path: root/init/Kconfig
diff options
context:
space:
mode:
authorBill Wendling <morbo@google.com>2026-01-16 00:57:57 +0000
committerKees Cook <kees@kernel.org>2026-01-17 11:00:28 -0800
commit150a04d817d8f5be5a4f92799827cdc8d7e45989 (patch)
tree2551fa6089849d2f48cd9fc99563c7237e9c2d67 /init/Kconfig
parent9f54ab83cb2a17071be70a80b94db6c36e597696 (diff)
downloadlwn-150a04d817d8f5be5a4f92799827cdc8d7e45989.tar.gz
lwn-150a04d817d8f5be5a4f92799827cdc8d7e45989.zip
compiler_types.h: Attributes: Add __counted_by_ptr macro
Introduce __counted_by_ptr(), which works like __counted_by(), but for pointer struct members. struct foo { int a, b, c; char *buffer __counted_by_ptr(bytes); short nr_bars; struct bar *bars __counted_by_ptr(nr_bars); size_t bytes; }; Because "counted_by" can only be applied to pointer members in very recent compiler versions, its application ends up needing to be distinct from flexibe array "counted_by" annotations, hence a separate macro. This is a reworking of Kees' previous patch [1]. Link: https://lore.kernel.org/all/20251020220118.1226740-1-kees@kernel.org/ [1] Co-developed-by: Kees Cook <kees@kernel.org> Signed-off-by: Bill Wendling <morbo@google.com> Link: https://patch.msgid.link/20260116005838.2419118-1-morbo@google.com Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'init/Kconfig')
-rw-r--r--init/Kconfig7
1 files changed, 7 insertions, 0 deletions
diff --git a/init/Kconfig b/init/Kconfig
index fa79feb8fe57..96b7cd481eaa 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -143,6 +143,13 @@ config CC_HAS_COUNTED_BY
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
default y if CC_IS_GCC && GCC_VERSION >= 150100
+config CC_HAS_COUNTED_BY_PTR
+ bool
+ # supported since clang 22
+ default y if CC_IS_CLANG && CLANG_VERSION >= 220000
+ # supported since gcc 16.0.0
+ default y if CC_IS_GCC && GCC_VERSION >= 160000
+
config CC_HAS_MULTIDIMENSIONAL_NONSTRING
def_bool $(success,echo 'char tag[][4] __attribute__((__nonstring__)) = { };' | $(CC) $(CLANG_FLAGS) -x c - -c -o /dev/null -Werror)