Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Sep 2025 23:29:06 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: ff5bcb742899 - main - LinuxKPI: add __struct_size
Message-ID:  <202509052329.585NT6dF029437@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=ff5bcb742899f8398ccb1b9e292b2e5aeeb7fedb

commit ff5bcb742899f8398ccb1b9e292b2e5aeeb7fedb
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2025-08-18 19:53:55 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2025-09-05 23:24:16 +0000

    LinuxKPI: add __struct_size
    
    Use __builtin_object_size() by default.
    If __builtin_dynamic_object_size() is available use that instead.
    
    I would hope that in a future version we can remove the conditional
    checks but in order to be able to MFC this without checking all
    compiler versions simply keep it this way for now.
    
    Sponsored by:   The FreeBSD Foundation (initially)
    MFC after:      3 days
    Reviewed by:    dumbbell
    Differential Revision:  https://reviews.freebsd.org/D52077
---
 sys/compat/linuxkpi/common/include/linux/compiler.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/compiler.h b/sys/compat/linuxkpi/common/include/linux/compiler.h
index fb5ad3bf4fe4..948396144ad6 100644
--- a/sys/compat/linuxkpi/common/include/linux/compiler.h
+++ b/sys/compat/linuxkpi/common/include/linux/compiler.h
@@ -130,4 +130,10 @@
 #define is_signed_type(t)	((t)-1 < (t)1)
 #define is_unsigned_type(t)	((t)-1 > (t)1)
 
+#if __has_builtin(__builtin_dynamic_object_size)
+#define	__struct_size(_s)	__builtin_dynamic_object_size(_s, 0)
+#else
+#define	__struct_size(_s)	__builtin_object_size(_s, 0)
+#endif
+
 #endif	/* _LINUXKPI_LINUX_COMPILER_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202509052329.585NT6dF029437>