Skip to content

Commit a510c18

Browse files
committed
compiler_types: Identify compiler versions for __builtin_dynamic_object_size
Clarify when __builtin_dynamic_object_size() is available. All our supported Clang versions support it. GCC 12 and later support it. Link to documentation for both. Acked-by: Miguel Ojeda <ojeda@kernel.org> Link: https://lore.kernel.org/r/20250416172016.work.154-kees@kernel.org Signed-off-by: Kees Cook <kees@kernel.org>
1 parent 0d6efa2 commit a510c18

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

include/linux/compiler_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ struct ftrace_likely_data {
449449
/*
450450
* When the size of an allocated object is needed, use the best available
451451
* mechanism to find it. (For cases where sizeof() cannot be used.)
452+
*
453+
* Optional: only supported since gcc >= 12
454+
*
455+
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
456+
* clang: https://clang.llvm.org/docs/LanguageExtensions.html#evaluating-object-size
452457
*/
453458
#if __has_builtin(__builtin_dynamic_object_size)
454459
#define __struct_size(p) __builtin_dynamic_object_size(p, 0)

0 commit comments

Comments
 (0)