HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SYS_Inline.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: SYS_Inline.h ( SYS Library, C++)
7  *
8  * COMMENTS: Common definitions to be used with inline functions.
9  *
10  */
11 
12 #ifndef __SYS_Inline__
13 #define __SYS_Inline__
14 
15 #include "SYS_Compiler.h"
16 
17 // For compilers that need templated function specializations to have
18 // storage qualifiers, we need to declare the specializations as static inline.
19 // Otherwise, we'll get linker errors about multiply defined symbols.
20 //
21 // Note that we check for the existence of __clang__ before __GNUC__ because
22 // the Clang compiler also defines __GNUC__ for compatibility reasons.
23 #if defined(__clang__)
24  // Clang compiler. Check this first before _MSC_VER/__GNUC__
25  #define SYS_STATIC_INLINE inline
26 #elif defined(_MSC_VER)
27  // MSVC CL compiler.
28  #define SYS_STATIC_INLINE static inline
29 #elif defined(__GNUC__)
30  // GCC compiler.
31  #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
32  #define SYS_STATIC_INLINE static inline
33  #else
34  #define SYS_STATIC_INLINE inline
35  #endif
36 #endif
37 
38 /// Mark function to be inlined. If this is done, taking the address of such
39 /// a function is not allowed.
40 #if defined(GCC4) || defined(__clang__)
41  #define SYS_FORCE_INLINE __attribute__ ((always_inline)) inline
42 #elif defined(_MSC_VER)
43  #define SYS_FORCE_INLINE __forceinline
44 #else
45  #define SYS_FORCE_INLINE inline
46 #endif
47 
48 #define SYS_STATIC_FORCE_INLINE static SYS_FORCE_INLINE
49 
50 /// GCC prior to 4.4 may trigger a compiler error when using
51 /// SYS_FORCE_INLINE. To eliminate the chance of this error, use
52 /// SYS_SAFE_FOCE_INLINE.
53 #if !defined(__GNUC__) || SYS_IS_GCC_GE(4, 4)
54  #define SYS_SAFE_FORCE_INLINE SYS_FORCE_INLINE
55 #else
56  #define SYS_SAFE_FORCE_INLINE inline
57 #endif
58 
59 /// Mark function as NOT to be inlined.
60 #if defined(GCC3)
61  #define SYS_NO_INLINE __attribute__ ((noinline))
62 #elif defined(_MSC_VER)
63  #define SYS_NO_INLINE __declspec(noinline)
64 #else
65  #define SYS_NO_INLINE
66 #endif
67 
68 #endif // __SYS_Inline__