From f20e1f624153f79946aaa3a10102a462ce08a247 Mon Sep 17 00:00:00 2001 From: "Bjoern A. Zeeb" Date: Thu, 24 Apr 2025 09:25:21 +0000 Subject: [PATCH] LinuxKPI: add container_of_const() Implement container_of_const() needed for wireless driver updates. Sponsored by: The FreeBSD Foundation Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D49999 (cherry picked from commit 6841b9987e83fdd9a5b05ceafc20811469222d8b) --- 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 449507fcf9c..7210d531b05 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