Date: Fri, 12 Mar 2010 14:30:51 +0200 From: Andriy Gapon <avg@icyb.net.ua> To: Ivan Voras <ivoras@freebsd.org> Cc: freebsd-arch@freebsd.org Subject: Re: likely and unlikely Message-ID: <4B9A33FB.4020108@icyb.net.ua> In-Reply-To: <hndbed$vok$1@dough.gmane.org> References: <hndbed$vok$1@dough.gmane.org>
next in thread | previous in thread | raw e-mail | index | archive | help
on 12/03/2010 14:18 Ivan Voras said the following: > While looking into branch prediction in gcc I found this post describing > the "likely" and "unlikely" macros in Linux: > > http://kerneltrap.org/node/4705 > > In short, they are wrappers for the gcc-specific __builtin_expect for > static branch prediction. > > Grepping around I see it is defined and used locally in several places: > > amd64/include/xen/xen-os.h:#define likely(x) __builtin_expect((x),1) > amd64/include/xen/xen-os.h:#define unlikely(x) __builtin_expect((x),0) > dev/nxge/xge-osdep.h:#define xge_os_unlikely(x) (x) > gnu/fs/xfs/FreeBSD/xfs_compat.h:#define likely(x) > __builtin_expect((x), 1) > gnu/fs/xfs/FreeBSD/xfs_compat.h:#define unlikely(x) > __builtin_expect((x), 0) > i386/include/xen/xen-os.h:#define likely(x) __builtin_expect((x),1) > i386/include/xen/xen-os.h:#define unlikely(x) __builtin_expect((x),0) > sun4v/include/cpu.h:#define likely(x) __builtin_expect((x),1) > sun4v/include/cpu.h:#define unlikely(x) __builtin_expect((x),0) > > Wouldn't it be more convenient to have a single global definition of > them, under #ifdef __GNUC__ for example in sys/stddef.h ? __predict_true/__predict_false -- Andriy Gapon
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4B9A33FB.4020108>