summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2017-04-24 18:59:05 +0300
committerJoshua M. Clulow <josh@sysmgr.org>2017-04-26 03:44:35 -0700
commit6175f5a92a3a312be8142de7390d92df1d05bd75 (patch)
treefc93ec24a619c75fee78e2b6dcc0fea07f01c1ef /usr/src
parent8e1c282f21a1ca9422d0f1c9922b6679bb245185 (diff)
downloadillumos-joyent-6175f5a92a3a312be8142de7390d92df1d05bd75.tar.gz
8007 want sys/stddef.h for offsetof and container_of macros (fix container_of visibility)
Reviewed by: Igor Kozhukhov <igor@dilos.org> Reviewed by: Adam Stevko <adam.stevko@gmail.com> Reviewed by: Joshua M. Clulow <josh@sysmgr.org> Approved by: Joshua M. Clulow <josh@sysmgr.org>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/uts/common/sys/stddef.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/usr/src/uts/common/sys/stddef.h b/usr/src/uts/common/sys/stddef.h
index 9dc9736241..a0bd1f83a1 100644
--- a/usr/src/uts/common/sys/stddef.h
+++ b/usr/src/uts/common/sys/stddef.h
@@ -37,8 +37,16 @@ extern "C" {
#endif /* !offsetof */
#if !defined(container_of)
+
+/*
+ * We must not expose container_of() to userland, but we want it
+ * to be available for early boot and for the kernel.
+ */
+#if ((defined(_KERNEL) || defined(_FAKE_KERNEL)) && !defined(_KMEMUSER)) || \
+ (defined(_BOOT) && defined(_KMEMUSER))
#define container_of(m, s, name) \
(void *)((uintptr_t)(m) - (uintptr_t)offsetof(s, name))
+#endif
#endif /* !container_of */
#ifdef __cplusplus