Date: Fri, 15 May 2015 12:33:27 +0200 From: Tijl Coosemans <tijl@FreeBSD.org> To: "Pedro F. Giffuni" <pfg@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: <20150515123327.45621037@kalimero.tijl.coosemans.org> In-Reply-To: <201505141549.t4EFnnQg094250@svn.freebsd.org> References: <201505141549.t4EFnnQg094250@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 14 May 2015 15:49:49 +0000 (UTC) "Pedro F. Giffuni" <pfg@FreeBSD.org> wrote: > Author: pfg > Date: Thu May 14 15:49:48 2015 > New Revision: 282907 > URL: https://svnweb.freebsd.org/changeset/base/282907 > > Log: > Add new __unreachable() builtin > > This is one of the few post gcc4.2 builtins that has been implemented by > clang: > > __builtin_unreachable is used to indicate that a specific point in the > program cannot be reached, even if the compiler might otherwise think it > can. This is useful to improve optimization and eliminates certain > warnings. > > Hinted by: NetBSD > Differential Revision: https://reviews.freebsd.org/D2536 > > Modified: > head/sys/sys/cdefs.h > > 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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150515123327.45621037>