[Ocfs2-tools-commits] zab commits r471 - trunk/libocfs2/include

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Dec 9 13:50:45 CST 2004


Author: zab
Date: 2004-12-09 13:50:43 -0600 (Thu, 09 Dec 2004)
New Revision: 471

Modified:
   trunk/libocfs2/include/ocfs2.h
Log:
o add type-paranoid ocfs2_{min,max}


Modified: trunk/libocfs2/include/ocfs2.h
===================================================================
--- trunk/libocfs2/include/ocfs2.h	2004-12-09 19:46:07 UTC (rev 470)
+++ trunk/libocfs2/include/ocfs2.h	2004-12-09 19:50:43 UTC (rev 471)
@@ -590,4 +590,23 @@
 		cgs->cgs_tail_group_bits = cgs->cgs_cpg;
 }
 
+/*
+ * shamelessly lifted from the kernel
+ *
+ * min()/max() macros that also do
+ * strict type-checking.. See the
+ * "unnecessary" pointer comparison.
+ */
+#define ocfs2_min(x,y) ({ \
+	const typeof(x) _x = (x);       \
+	const typeof(y) _y = (y);       \
+	(void) (&_x == &_y);            \
+	_x < _y ? _x : _y; })
+                                                                                
+#define ocfs2_max(x,y) ({ \
+	const typeof(x) _x = (x);       \
+	const typeof(y) _y = (y);       \
+	(void) (&_x == &_y);            \
+	_x > _y ? _x : _y; })
+
 #endif  /* _FILESYS_H */



More information about the Ocfs2-tools-commits mailing list