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