[svn-commits] fjoe: freebsd/trunk r9165 - /freebsd/trunk/include/dahdi/compat/bsd.h

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Aug 19 02:20:54 CDT 2010


Author: fjoe
Date: Thu Aug 19 02:20:50 2010
New Revision: 9165

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9165
Log:
- Change WARN_ON to expression.
- Add WARN_ON_ONCE implementation.

Modified:
    freebsd/trunk/include/dahdi/compat/bsd.h

Modified: freebsd/trunk/include/dahdi/compat/bsd.h
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/include/dahdi/compat/bsd.h?view=diff&rev=9165&r1=9164&r2=9165
==============================================================================
--- freebsd/trunk/include/dahdi/compat/bsd.h (original)
+++ freebsd/trunk/include/dahdi/compat/bsd.h Thu Aug 19 02:20:50 2010
@@ -314,11 +314,24 @@
 
 #define might_sleep()
 
-#define WARN_ON(cond)					\
-	do {						\
-		if (cond)				\
-			printf("WARN_ON: " #cond "\n");	\
-	} while (0)
+#define WARN_ON(condition)				\
+({							\
+	int __ret_warn_on = !!(condition);		\
+	if (unlikely(__ret_warn_on))			\
+		printf("WARN_ON: " #condition "\n");	\
+	unlikely(__ret_warn_on);			\
+})
+
+#define WARN_ON_ONCE(condition) ({			\
+	static int __warned;				\
+	int __ret_warn_once = !!(condition);		\
+							\
+	if (unlikely(__ret_warn_once))			\
+		if (WARN_ON(!__warned))			\
+			__warned = 1;			\
+	unlikely(__ret_warn_once);			\
+})
+
 #define BUG_ON(cond)					\
 	do {						\
 		if (cond)				\




More information about the svn-commits mailing list