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