1 /******************************************************************************* 2 * tlx/define/likely.hpp 3 * 4 * Part of tlx - http://panthema.net/tlx 5 * 6 * Copyright (C) 2015-2017 Timo Bingmann <tb@panthema.net> 7 * 8 * All rights reserved. Published under the Boost Software License, Version 1.0 9 ******************************************************************************/ 10 11 #ifndef TLX_DEFINE_LIKELY_HEADER 12 #define TLX_DEFINE_LIKELY_HEADER 13 14 namespace tlx { 15 16 //! \addtogroup tlx_define 17 //! \{ 18 19 #if defined(__GNUC__) || defined(__clang__) 20 #define TLX_LIKELY(c) __builtin_expect((c), 1) 21 #define TLX_UNLIKELY(c) __builtin_expect((c), 0) 22 #else 23 #define TLX_LIKELY(c) c 24 #define TLX_UNLIKELY(c) c 25 #endif 26 27 //! \} 28 29 } // namespace tlx 30 31 #endif // !TLX_DEFINE_LIKELY_HEADER 32 33 /******************************************************************************/ 34