From c7f24e49db47aec2008b072bb6fb9b6dddc36797 Mon Sep 17 00:00:00 2001 From: Ashish Chaudhari Date: Wed, 5 Aug 2015 23:14:54 -0500 Subject: uhd: Removed dependency on boost/lockfree --- host/include/uhd/utils/soft_register.hpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/utils/soft_register.hpp b/host/include/uhd/utils/soft_register.hpp index f28b2aa2a..9c407cd74 100644 --- a/host/include/uhd/utils/soft_register.hpp +++ b/host/include/uhd/utils/soft_register.hpp @@ -28,7 +28,6 @@ #include #include #include -#include //================================================================== // Soft Register Definition @@ -39,6 +38,28 @@ namespace uhd { +//TODO: These hints were added to boost 1.53. + +/** \brief hint for the branch prediction */ +inline bool likely(bool expr) +{ +#ifdef __GNUC__ + return __builtin_expect(expr, true); +#else + return expr; +#endif + } + +/** \brief hint for the branch prediction */ +inline bool unlikely(bool expr) +{ +#ifdef __GNUC__ + return __builtin_expect(expr, false); +#else + return expr; +#endif +} + /* A register field is defined as a tuple of the mask and the shift. * It can be used to make read-modify-write operations more convenient * For efficiency reasons, it is recommended to always use a constant @@ -62,7 +83,7 @@ namespace soft_reg_field { //Behavior for the left shit operation is undefined in C++ //if the shift amount is >= bitwidth of the datatype //So we treat that as a special case with a branch predicition hint - if (boost::lockfree::detail::likely((sizeof(data_t)*8) != width(field))) + if (likely((sizeof(data_t)*8) != width(field))) return ((ONE<