aGrUM  0.13.2
inline.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN and Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
36 #ifndef GUM_INLINE_H
37 #define GUM_INLINE_H
38 
39 #ifndef DOXYGEN_SHOULD_SKIP_THIS
40 
41 # ifndef GUM_NO_INLINE
42 
43 # define INLINE inline
44 
45 // ENFORCED_INLINE is a stronger version of the inline, using __forceinline on
46 // MSVC, but it still doesn't use GCC's always_inline. This is useful in
47 // (common) situations where MSVC needs forceinline but GCC is still doing fine
48 // with just inline. (from eigen library)
49 # if (defined _MSC_VER) || (defined __INTEL_COMPILER)
50 # define ENFORCED_INLINE __forceinline
51 # else
52 # define ENFORCED_INLINE inline
53 # endif
54 
55 // ALWAYS_INLINE is the strongest, it has the effect of making the function
56 // inline and adding every possible attribute to maximize inlining. This should
57 // only be used when really necessary: in particular, it uses
58 // __attribute__((always_inline)) on GCC, which most of the time is useless and
59 // can severely harm compile times.
60 // FIXME with the always_inline attribute, gcc 3.4.x reports the following
61 // compilation error:
62 // Eval.h:91: sorry, unimplemented: inlining failed in call to '...' :
63 // function body not available (from eigen library)
64 # if GNUC_AT_LEAST(4, 0)
65 # define ALWAYS_INLINE __attribute__((always_inline)) inline
66 # else
67 # define ALWAYS_INLINE ENFORCED_INLINE
68 # endif
69 
70 # if (defined __GNUC__)
71 # define NO_INLINE __attribute__((noinline))
72 # elif (defined _MSC_VER)
73 # define NEVER_INLINE __declspec(noinline)
74 # else
75 # define NEVER_INLINE
76 # endif
77 # else // GUM_NO_INLINE
78 # define INLINE
79 # define STRONG_INLINE
80 # define ALWAYS_INLINE
81 # define NEVER_INLINE
82 # endif /* GUM_NO_INLINE */
83 
84 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
85 
86 #endif /* GUM_INLINE_H */