Turi Create  4.0
branch_hints.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef TURI_UTIL_BRANCH_HINTS_HPP
7 #define TURI_UTIL_BRANCH_HINTS_HPP
8 
9 /**
10  * \ingroup util
11  * Sets a branch as likely.
12  *
13  * \code
14  * if (__likely__(age < 100)) {
15  * ...
16  * } else if (__unlikely__(age >= 100)) {
17  * ...
18  * }
19  * \endcode
20  */
21 #define __likely__(x) __builtin_expect((x),1)
22 
23 /**
24  * \ingroup util
25  * Sets a branch as unlikely.
26  *
27  * \code
28  * if (__likely__(age < 100)) {
29  * ...
30  * } else if (__unlikely__(age >= 100)) {
31  * ...
32  * }
33  * \endcode
34  */
35 #define __unlikely__(x) __builtin_expect((x),0)
36 
37 #endif //TURI_UTIL_BRANCH_HINTS_HPP