changeset 13732:41e535b56aae

2044 Move container_of and ARRAY_SIZE to sys/sysmacros.h Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Dan McDonald <danmcd@nexenta.com>
author Alexey Zaytsev <alexey.zaytsev@nexenta.com>
date Mon, 18 Jun 2012 21:48:00 -0400
parents 35bcb68f2175
children d48dc87999aa
files usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3_impl.h usr/src/uts/common/sys/sysmacros.h
diffstat 2 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3_impl.h	Mon Jun 18 21:47:58 2012 -0400
+++ b/usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3_impl.h	Mon Jun 18 21:48:00 2012 -0400
@@ -20,6 +20,7 @@
  */
 /*
  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef _RDSV3_IMPL_H
@@ -120,9 +121,6 @@
 
 #define	jiffies	100
 #define	HZ	(drv_hztousec(1))
-#define	container_of(m, s, name)			\
-	(void *)((uintptr_t)(m) - (uintptr_t)offsetof(s, name))
-#define	ARRAY_SIZE(x)	(sizeof (x) / sizeof (x[0]))
 /* setting this to PAGESIZE throws build errors */
 #define	PAGE_SIZE	4096 /* xxx - fix this */
 #define	BITS_PER_LONG	(sizeof (unsigned long) * 8)
--- a/usr/src/uts/common/sys/sysmacros.h	Mon Jun 18 21:47:58 2012 -0400
+++ b/usr/src/uts/common/sys/sysmacros.h	Mon Jun 18 21:48:00 2012 -0400
@@ -25,6 +25,8 @@
 /*
  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright 2011, 2012 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef _SYS_SYSMACROS_H
@@ -364,12 +366,18 @@
 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
 #endif  /* _BIT_FIELDS_LTOH */
 
-#if defined(_KERNEL) && !defined(_KMEMUSER) && !defined(offsetof)
+/* avoid any possibility of clashing with <stddef.h> version */
+#if defined(_KERNEL) && !defined(_KMEMUSER)
 
-/* avoid any possibility of clashing with <stddef.h> version */
+#if !defined(offsetof)
+#define	offsetof(s, m)	((size_t)(&(((s *)0)->m)))
+#endif /* !offsetof */
 
-#define	offsetof(s, m)	((size_t)(&(((s *)0)->m)))
-#endif
+#define	container_of(m, s, name)			\
+	(void *)((uintptr_t)(m) - (uintptr_t)offsetof(s, name))
+
+#define	ARRAY_SIZE(x)	(sizeof (x) / sizeof (x[0]))
+#endif /* _KERNEL, !_KMEMUSER */
 
 #ifdef	__cplusplus
 }