Date: Fri, 15 May 2015 12:34:46 -0500 From: Pedro Giffuni <pfg@FreeBSD.org> To: Tijl Coosemans <tijl@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r282907 - head/sys/sys Message-ID: <55562E36.1000304@FreeBSD.org> In-Reply-To: <20150515123327.45621037@kalimero.tijl.coosemans.org> References: <201505141549.t4EFnnQg094250@svn.freebsd.org> <20150515123327.45621037@kalimero.tijl.coosemans.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?55562E36.1000304>