Date: Thu, 24 Apr 2025 22:14:37 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: 6841b9987e83 - main - LinuxKPI: add container_of_const() Message-ID: <202504242214.53OMEbDM036623@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=6841b9987e83fdd9a5b05ceafc20811469222d8b commit 6841b9987e83fdd9a5b05ceafc20811469222d8b Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2025-04-24 09:25:21 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2025-04-24 22:13:54 +0000 LinuxKPI: add container_of_const() Implement container_of_const() needed for wireless driver updates. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D49999 --- sys/compat/linuxkpi/common/include/linux/container_of.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/container_of.h b/sys/compat/linuxkpi/common/include/linux/container_of.h index 449507fcf9c1..7210d531b055 100644 --- a/sys/compat/linuxkpi/common/include/linux/container_of.h +++ b/sys/compat/linuxkpi/common/include/linux/container_of.h @@ -41,6 +41,14 @@ (type *)((uintptr_t)__p - offsetof(type, member)); \ }) +#define container_of_const(ptr, type, member) \ + _Generic(ptr, \ + const typeof(*(ptr)) *: \ + (const type *)container_of(ptr, type, member), \ + default: \ + container_of(ptr, type, member) \ + ) + #define typeof_member(type, member) __typeof(((type *)0)->member) #endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202504242214.53OMEbDM036623>