Date: Fri, 12 Mar 2010 13:18:29 +0100 From: Ivan Voras <ivoras@freebsd.org> To: freebsd-arch@freebsd.org Subject: likely and unlikely Message-ID: <hndbed$vok$1@dough.gmane.org>
next in thread | raw e-mail | index | archive | help
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 ?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?hndbed$vok$1>