Chris@16: // branch hints Chris@16: // Copyright (C) 2007, 2008 Tim Blechmann Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_LOCKFREE_BRANCH_HINTS_HPP_INCLUDED Chris@16: #define BOOST_LOCKFREE_BRANCH_HINTS_HPP_INCLUDED Chris@16: Chris@16: namespace boost { Chris@16: namespace lockfree { Chris@16: namespace detail { Chris@16: /** \brief hint for the branch prediction */ Chris@16: inline bool likely(bool expr) Chris@16: { Chris@16: #ifdef __GNUC__ Chris@16: return __builtin_expect(expr, true); Chris@16: #else Chris@16: return expr; Chris@16: #endif Chris@16: } Chris@16: Chris@16: /** \brief hint for the branch prediction */ Chris@16: inline bool unlikely(bool expr) Chris@16: { Chris@16: #ifdef __GNUC__ Chris@16: return __builtin_expect(expr, false); Chris@16: #else Chris@16: return expr; Chris@16: #endif Chris@16: } Chris@16: Chris@16: } /* namespace detail */ Chris@16: } /* namespace lockfree */ Chris@16: } /* namespace boost */ Chris@16: Chris@16: #endif /* BOOST_LOCKFREE_BRANCH_HINTS_HPP_INCLUDED */