pion-net  4.0.9
branch_hints.hpp
1 // branch hints
2 // Copyright (C) 2007, 2008 Tim Blechmann
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 
8 // Disclaimer: Not a Boost library.
9 
10 #ifndef BOOST_LOCKFREE_BRANCH_HINTS_HPP_INCLUDED
11 #define BOOST_LOCKFREE_BRANCH_HINTS_HPP_INCLUDED
12 
13 namespace boost
14 {
15 namespace lockfree
16 {
18  inline bool likely(bool expr)
19  {
20 #ifdef __GNUC__
21  return __builtin_expect(expr, true);
22 #else
23  return expr;
24 #endif
25  }
26 
28  inline bool unlikely(bool expr)
29  {
30 #ifdef __GNUC__
31  return __builtin_expect(expr, false);
32 #else
33  return expr;
34 #endif
35  }
36 
37 } /* namespace lockfree */
38 } /* namespace boost */
39 
40 #endif /* BOOST_LOCKFREE_BRANCH_HINTS_HPP_INCLUDED */