The Gaudi Framework  v32r2 (46d42edc)
Kernel.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_KERNEL_H
2 #define GAUDIKERNEL_KERNEL_H
3 
4 // Some pragmas to avoid warnings in VisualC
5 #ifdef _WIN32
6 // Disable warning C4786: identifier was truncated to '255' characters in the debug information
7 # pragma warning( disable : 4786 )
8 // Disable warning C4291: no matching operator delete found; memory will not be freed if initialization throws an
9 // exception
10 # pragma warning( disable : 4291 )
11 // Disable warning C4250: inheritance via dominance
12 # pragma warning( disable : 4250 )
13 #endif
14 
15 // Large integer definition depends of the platform
16 #ifndef NO_LONGLONG_TYPEDEF
17 typedef long long int longlong;
18 typedef unsigned long long int ulonglong;
19 #endif
20 
21 #ifndef LONGLONG_MAX
22 # define LONGLONG_MAX 0x7FFFFFFFFFFFFFFFLL
23 #endif
24 #ifndef LONGLONG_MIN
25 # define LONGLONG_MIN 0x8000000000000000LL
26 #endif
27 
28 #ifndef ULONGLONG_MAX
29 # define ULONGLONG_MAX 0xfFFFFFFFFFFFFFFFLL
30 #endif
31 #ifndef ULONGLONG_MIN
32 # define ULONGLONG_MIN 0x0000000000000000LL
33 #endif
34 
35 // ---------------------------------- Symbol visibility macros (begin)
36 // Enabled on in Gaudi v21 mode
37 #if !defined( GAUDI_V20_COMPAT ) || defined( G21_HIDE_SYMBOLS )
38 // These macros will allow selection on exported symbols
39 // taken from http://gcc.gnu.org/wiki/Visibility
40 # if __GNUC__ >= 4 && !defined( __CINT__ )
41 # define GAUDI_HASCLASSVISIBILITY
42 # endif
43 
44 # ifdef _WIN32
45 /*
46 # define GAUDI_IMPORT __declspec(dllimport)
47 # define GAUDI_EXPORT __declspec(dllexport)
48 # define GAUDI_LOCAL
49 */
50 // The symbol visibility is disabled on Win32 because it is not possible to
51 // make coexists the gcc and VC ways.
52 # define GAUDI_IMPORT
53 # define GAUDI_EXPORT
54 # define GAUDI_LOCAL
55 # else
56 # if defined( GAUDI_HASCLASSVISIBILITY )
57 # define GAUDI_IMPORT __attribute__( ( visibility( "default" ) ) )
58 # define GAUDI_EXPORT __attribute__( ( visibility( "default" ) ) )
59 # define GAUDI_LOCAL __attribute__( ( visibility( "hidden" ) ) )
60 # else
61 # define GAUDI_IMPORT
62 # define GAUDI_EXPORT
63 # define GAUDI_LOCAL
64 # endif
65 # endif
66 
67 // Define GAUDI_API for DLL builds
68 # ifdef GAUDI_LINKER_LIBRARY
69 # define GAUDI_API GAUDI_EXPORT
70 # else
71 # define GAUDI_API GAUDI_IMPORT
72 # endif
73 #else
74 // Dummy definitions for the backward compatibility mode.
75 # define GAUDI_API
76 # define GAUDI_IMPORT
77 # define GAUDI_EXPORT
78 # define GAUDI_LOCAL
79 #endif // GAUDI_V20_COMPAT
80 // ---------------------------------- Symbol visibility macros (end)
81 
82 // -------------- LIKELY/UNLIKELY macros (begin)
83 // Use compiler hinting to improve branch prediction for linux
84 // if somebody defined these macros before us, clean up first
85 #if defined( LIKELY )
86 # undef LIKELY
87 #endif
88 #if defined( UNLIKELY )
89 # undef UNLIKELY
90 #endif
91 #if defined( __GNUC__ ) || defined( __clang__ )
92 # define LIKELY( x ) __builtin_expect( ( x ), 1 )
93 # define UNLIKELY( x ) __builtin_expect( ( x ), 0 )
94 #else
95 # define LIKELY( x ) x
96 # define UNLIKELY( x ) x
97 #endif
98 // -------------- LIKELY/UNLIKELY macros (end)
99 
100 // -----------------------------------------------------------------------------
101 // Sanitizer suppressions
102 // Gcc
103 #if defined( __GNUC__ )
104 # if defined( __SANITIZE_ADDRESS__ )
105 # define GAUDI_NO_SANITIZE_ADDRESS __attribute__( ( no_sanitize_address ) )
106 # endif
107 // Note there is no __SANITIZE_MEMORY__ to test for
108 # define GAUDI_NO_SANITIZE_MEMORY __attribute__( ( no_sanitize_memory ) )
109 // Note there is no __SANITIZE_UNDEFINED__ to test for
110 # define GAUDI_NO_SANITIZE_UNDEFINED __attribute__( ( no_sanitize_undefined ) )
111 // Note there is no __SANITIZE_THREAD__ to test for
112 # define GAUDI_NO_SANITIZE_THREAD __attribute__( ( no_sanitize_thread ) )
113 #endif
114 // clang
115 #if defined( __clang__ )
116 # if __has_feature( address_sanitizer )
117 # define GAUDI_NO_SANITIZE_ADDRESS __attribute__( ( no_sanitize( "address" ) ) )
118 # endif
119 # if __has_feature( memory_sanitizer )
120 # define GAUDI_NO_SANITIZE_MEMORY __attribute__( ( no_sanitize( "memory" ) ) )
121 # endif
122 # if __has_feature( undefined_sanitizer )
123 # define GAUDI_NO_SANITIZE_UNDEFINED __attribute__( ( no_sanitize( "undefined" ) ) )
124 # endif
125 # if __has_feature( thread_sanitizer )
126 # define GAUDI_NO_SANITIZE_THREAD __attribute__( ( no_sanitize( "thread" ) ) )
127 # endif
128 #endif
129 // defaults
130 #ifndef GAUDI_NO_SANITIZE_ADDRESS
131 # define GAUDI_NO_SANITIZE_ADDRESS
132 #endif
133 #ifndef GAUDI_NO_SANITIZE_MEMORY
134 # define GAUDI_NO_SANITIZE_MEMORY
135 #endif
136 #ifndef GAUDI_NO_SANITIZE_UNDEFINED
137 # define GAUDI_NO_SANITIZE_UNDEFINED
138 #endif
139 #ifndef GAUDI_NO_SANITIZE_THREAD
140 # define GAUDI_NO_SANITIZE_THREAD
141 #endif
142 // -----------------------------------------------------------------------------
143 
144 // -----------------------------------------------------------------------------
145 // Adds compiler specific hints for loop unrolling.
146 // To use place the macro directly before the loop you wish to unroll. e.g.
147 //
148 // GAUDI_LOOP_UNROLL(N)
149 // for ( std::size_t i = 0; i < N; ++i ) {
150 // // do stuff
151 // }
152 //
153 // Constraints on N are it needs to be something known at compile time.
154 // Gains are most obvious with small fixed size (compile time) loops,
155 // but in principle can be used with any loop.
156 #define GAUDI_DO_PRAGMA( x ) _Pragma( #x )
157 #if defined( __clang__ )
158 # define GAUDI_LOOP_UNROLL( x ) GAUDI_DO_PRAGMA( clang loop unroll_count( x ) )
159 #elif defined( __GNUC__ )
160 # define GAUDI_LOOP_UNROLL( x ) GAUDI_DO_PRAGMA( GCC unroll x )
161 #else
162 # define GAUDI_LOOP_UNROLL( x )
163 #endif
164 // -----------------------------------------------------------------------------
165 
166 #endif // GAUDIKERNEL_KERNEL_H
long long int longlong
Definition: Kernel.h:17
unsigned long long int ulonglong
Definition: Kernel.h:18