BibleTime
macros.h
Go to the documentation of this file.
1 /*********
2 *
3 * In the name of the Father, and of the Son, and of the Holy Spirit.
4 *
5 * This file is part of BibleTime's source code, https://bibletime.info/
6 *
7 * Copyright 1999-2021 by the BibleTime developers.
8 * The BibleTime source code is licensed under the GNU General Public License
9 * version 2.0.
10 *
11 **********/
12 
13 #pragma once
14 
15 /**
16  \file macros.h
17  \brief This file is for listing reusable macros used in the BibleTime source code.
18 */
19 
20 
21 /**
22  \def LIKELY(c)
23  \brief Gives the compiler a hint that the given conditional is likely to
24  evaluate to true.
25 
26  This helps GCC to generate code which is optimized in respect to branch
27  prediction.
28 */
29 
30 /**
31  \def UNLIKELY(c)
32  \brief Gives the compiler a hint that the given conditional is likely to
33  evaluate to false.
34 
35  This helps GCC to generate code which is optimized in respect to branch
36  prediction.
37 */
38 
39 #ifdef __GNUC__
40  #define LIKELY(c) __builtin_expect(!!(c),true)
41  #define UNLIKELY(c) __builtin_expect(!!(c),false)
42 #else
43  #define LIKELY(c) !!(c)
44  #define UNLIKELY(c) !!(c)
45 #endif