# common/include/boost/lockfree/detail/branch_hints.hpp

    00001 //  branch hints
    00002 //  Copyright (C) 2007, 2008 Tim Blechmann
    00003 //
    00004 //  Distributed under the Boost Software License, Version 1.0. (See
    00005 //  accompanying file LICENSE_1_0.txt or copy at
    00006 //  http://www.boost.org/LICENSE_1_0.txt)
    00007
    00008 //  Disclaimer: Not a Boost library.
    00009
    00010 #ifndef BOOST_LOCKFREE_BRANCH_HINTS_HPP_INCLUDED
    00011 #define BOOST_LOCKFREE_BRANCH_HINTS_HPP_INCLUDED
    00012
    00013 namespace boost
    00014 {
    00015 namespace lockfree
    00016 {
    00018     inline bool likely(bool expr)
    00019     {
    00020 #ifdef __GNUC__
    00021         return __builtin_expect(expr, true);
    00022 #else
    00023         return expr;
    00024 #endif
    00025     }
    00026
    00028     inline bool unlikely(bool expr)
    00029     {
    00030 #ifdef __GNUC__
    00031         return __builtin_expect(expr, false);
    00032 #else
    00033         return expr;
    00034 #endif
    00035     }
    00036
    00037 } /* namespace lockfree */
    00038 } /* namespace boost */
    00039
    00040 #endif /* BOOST_LOCKFREE_BRANCH_HINTS_HPP_INCLUDED */