git: 5fc174c52f18 - stable/14 - LinuxKPI: add container_of_const()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 29 Apr 2025 11:42:07 UTC
The branch stable/14 has been updated by bz:
URL: https://cgit.FreeBSD.org/src/commit/?id=5fc174c52f180c289ca3b50308e8689cced18103
commit 5fc174c52f180c289ca3b50308e8689cced18103
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-29 10:49:33 +0000
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 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