On 05/15/15 05:33, Tijl Coosemans wrote:
Modified: head/sys/sys/cdefs.h
==============================================================================
--- head/sys/sys/cdefs.h        Thu May 14 15:14:03 2015        (r282906)
+++ head/sys/sys/cdefs.h        Thu May 14 15:49:48 2015        (r282907)
@@ -388,6 +388,12 @@
  #define       __alloc_size(x)
  #endif
+#if __has_builtin(__builtin_unreachable) || __GNUC_PREREQ__(4, 6)
+#define        __unreachable() __builtin_unreachable()
+#else
+#define        __unreachable() do {} while (/*CONSTCOND*/0)
__builtin_unreachable() can be used in expressions so I think it's better
to replace do-while with ((void)0).  You can then do things like this:

#define assume(e)  ((e) ? (void)0 : __unreachable())
(like assert(e) but without error)
Looks reasonable, thanks!

FWIW, there was some discussion about having a debugging
macro that warns when such unreachable code is reached.
We are just not sure where such a macro belongs, probably
not in cdefs.

Pedro.
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to