aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
inline.h
Go to the documentation of this file.
1
/**
2
*
3
* Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4
* info_at_agrum_dot_org
5
*
6
* This library is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this library. If not, see <http://www.gnu.org/licenses/>.
18
*
19
*/
20
21
22
/**
23
* @file
24
* @brief aGrUM's inline/outline selection
25
*
26
* aGrUM's INLINE is a substitute to the usual C++ inline. It enables compiling
27
* aGrUM with or without inline functions, depending on whether we wish to
28
* debug parts of aGrUM.
29
*
30
* From eigen library, aGrUM proposes now:
31
* INLINE : the compiler has to try to inline
32
* STRONG_INLINE : the compiler has to try harder toinline
33
* ALWAYS_INLINE : the compiler has to inline
34
* NO_INLINE : the compiler should not inline
35
*
36
* @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
37
*/
38
#
ifndef
GUM_INLINE_H
39
#
define
GUM_INLINE_H
40
41
#
ifndef
DOXYGEN_SHOULD_SKIP_THIS
42
43
#
ifndef
GUM_NO_INLINE
44
45
#
define
INLINE
inline
46
47
// ENFORCED_INLINE is a stronger version of the inline, using _forceinline_ on
48
// MSVC, but it still doesn't use GCC's always_inline. This is useful in
49
// (common) situations where MSVC needs forceinline but GCC is still doing fine
50
// with just inline. (from eigen library)
51
#
if
(
defined
_MSC_VER
)
||
(
defined
_INTEL_COMPILER_
)
52
#
define
ENFORCED_INLINE
__forceinline
53
#
else
54
#
define
ENFORCED_INLINE
inline
55
#
endif
56
57
// ALWAYS_INLINE is the strongest, it has the effect of making the function
58
// inline and adding every possible attribute to maximize inlining. This should
59
// only be used when really necessary: in particular, it uses
60
// __attribute__((always_inline)) on GCC, which most of the time is useless and
61
// can severely harm compile times.
62
// @warning with the always_inline attribute, gcc 3.4.x reports the following
63
// compilation error:
64
// Eval.h:91: sorry, unimplemented: inlining failed in call to '...' :
65
// function body not available (from eigen library)
66
#
if
GNUC_AT_LEAST
(
4
,
0
)
67
#
define
ALWAYS_INLINE
__attribute__
(
(
always_inline
)
)
inline
68
#
else
69
#
define
ALWAYS_INLINE
ENFORCED_INLINE
70
#
endif
71
72
#
if
(
defined
__GNUC__
)
73
#
define
NO_INLINE
__attribute__
(
(
noinline
)
)
74
#
elif
(
defined
_MSC_VER
)
75
#
define
NEVER_INLINE
_declspec_
(
noinline
)
76
#
else
77
#
define
NEVER_INLINE
78
#
endif
79
#
else
// GUM_NO_INLINE
80
#
define
INLINE
81
#
define
STRONG_INLINE
82
#
define
ALWAYS_INLINE
83
#
define
NEVER_INLINE
84
#
endif
/* GUM_NO_INLINE */
85
86
#
endif
/* DOXYGEN_SHOULD_SKIP_THIS */
87
88
#
endif
/* GUM_INLINE_H */