From 6175f5a92a3a312be8142de7390d92df1d05bd75 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Mon, 24 Apr 2017 18:59:05 +0300 Subject: [PATCH] 8007 want sys/stddef.h for offsetof and container_of macros (fix container_of visibility) Reviewed by: Igor Kozhukhov Reviewed by: Adam Stevko Reviewed by: Joshua M. Clulow Approved by: Joshua M. Clulow --- usr/src/uts/common/sys/stddef.h | 8 ++++++++ 1 file changed, 8 insertions(+) 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 -- 2.11.4.GIT