From 6d29f0e40597d851738b1ceacef8116d1f7bd33a Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Fri, 16 Oct 2015 15:50:33 +0300 Subject: [PATCH] UAVCAN_LIKELY(), UAVCAN_UNLIKELY() --- libuavcan/include/uavcan/build_config.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libuavcan/include/uavcan/build_config.hpp b/libuavcan/include/uavcan/build_config.hpp index fedea852b7..c1ee6dc1e0 100644 --- a/libuavcan/include/uavcan/build_config.hpp +++ b/libuavcan/include/uavcan/build_config.hpp @@ -167,6 +167,22 @@ # endif #endif +#ifndef UAVCAN_LIKELY +# if __GNUC__ +# define UAVCAN_LIKELY(x) __builtin_expect(!!(x), true) +# else +# define UAVCAN_LIKELY(x) (x) +# endif +#endif + +#ifndef UAVCAN_UNLIKELY +# if __GNUC__ +# define UAVCAN_UNLIKELY(x) __builtin_expect(!!(x), false) +# else +# define UAVCAN_UNLIKELY(x) (x) +# endif +#endif + namespace uavcan { /**