Material Definition Language API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
config.h
Go to the documentation of this file.
1 /***************************************************************************************************
2  * Copyright 2020 NVIDIA Corporation. All rights reserved.
3  **************************************************************************************************/
8 
9 #ifndef MI_BASE_CONFIG_H
10 #define MI_BASE_CONFIG_H
11 
22 // The current copyright year string.
23 #define MI_COPYRIGHT_YEARS_STRING "2020"
24 
25 // The NVIDIA company name string for copyrights etc.
26 #define MI_COPYRIGHT_COMPANY_STRING "NVIDIA Corporation"
27 
28 // The NVIDIA copyright string.
29 #define MI_COPYRIGHT_COPYRIGHT_STRING \
30 "Copyright " MI_COPYRIGHT_YEARS_STRING \
31 " " MI_COPYRIGHT_COMPANY_STRING ". All rights reserved."
32 
33 // The NVIDIA copyright string if only portions are covered.
34 #define MI_COPYRIGHT_PORTIONS_STRING \
35 "Portions " MI_COPYRIGHT_COPYRIGHT_STRING
36 
37 
38 // The preprocessor defines MI_DLL_EXPORT and MI_DLL_LOCAL provide access to
39 // the compiler-dependent declaration directives for managing symbol
40 // visibility. The default for any symbol is to be invisible unless specified
41 // otherwise. Visibility concerns shared libraries, mostly, which means that
42 // every symbol you'd like to be accessible when building a DLL must be
43 // declared as MI_DLL_EXPORT. The syntax is as follows:
44 //
45 // MI_DLL_EXPORT void visible_function();
46 //
47 // class MI_DLL_EXPORT visible_class
48 // {
49 // public:
50 // visible_class(); /* these functions have external linkage */
51 // ~visible_class();
52 // void do_stuff();
53 //
54 // private:
55 // MI_DLL_LOCAL do_invisible_stuff(); /* no external linkage */
56 // };
57 //
58 // On Windows, the preprocessor symbol MI_DLL_BUILD must be defined while
59 // compiling the shared object. Other platforms typically don't need that
60 // define, but it won't hurt either, so it should probably be defined anyway.
61 // The GCC compiler needs the command line switch "-fvisibility=hidden" for
62 // these declarations to take any effect.
63 //
64 // A general introduction to the topic can be found in Ulrich Drepper's paper
65 // "How To Write Shared Libraries" <http://people.redhat.com/~drepper/> and on
66 // the GCC web site <http://gcc.gnu.org/wiki/Visibility>.
67 
68 #ifdef _WIN32
69 # ifdef MI_DLL_BUILD
70 # define MI_DLL_EXPORT __declspec(dllexport)
71 # else
72 # define MI_DLL_EXPORT __declspec(dllimport)
73 # endif
74 # define MI_DLL_LOCAL
75 #elif defined(__GNUC__) && !defined(__ICC)
76 # define MI_DLL_EXPORT __attribute__ ((visibility("default")))
77 # define MI_DLL_LOCAL __attribute__ ((visibility("hidden")))
78 #else
79 # define MI_DLL_EXPORT
80 # define MI_DLL_LOCAL
81 #endif
82 
85 #define MI_BASE_JOIN( X, Y ) MI_BASE_DO_JOIN( X, Y )
86 #define MI_BASE_DO_JOIN( X, Y ) MI_BASE_DO_JOIN2(X,Y)
87 #define MI_BASE_DO_JOIN2( X, Y ) X##Y
88 
90 #define MI_BASE_STRINGIZE( X ) MI_BASE_DO_STRINGIZE( X )
91 #define MI_BASE_DO_STRINGIZE( X ) MI_BASE_DO_STRINGIZE2(X)
92 #define MI_BASE_DO_STRINGIZE2( X ) #X
93 
97 #define MI_PREVENT_MACRO_EXPAND
98 
99 // Platform detection start
100 
101 #if defined(_WIN32)
102 
103 #if !defined(MI_PLATFORM_WINDOWS)
104 #define MI_PLATFORM_WINDOWS
105 #endif // !defined(MI_PLATFORM_WINDOWS)
106 
107 #if defined(_WIN64)
108 
109 #if !defined(MI_PLATFORM_WIN64)
110 #define MI_PLATFORM_WIN64
111 #endif // !defined(MI_PLATFORM_WIN64)
112 
113 #else // defined(_WIN64)
114 
115 #if !defined(MI_PLATFORM_WIN32)
116 #define MI_PLATFORM_WIN32
117 #endif // !defined(MI_PLATFORM_WIN32)
118 
119 #endif // defined(_WIN64)
120 
121 #elif defined(__APPLE__) // defined(_WIN32)
122 
123 #if !defined(MI_PLATFORM_MACOSX)
124 #define MI_PLATFORM_MACOSX
125 #endif // !defined(MI_PLATFORM_MACOSX)
126 
127 #elif defined(__unix__) // defined(__APPLE__)
128 
129 #if !defined(MI_PLATFORM_UNIX)
130 #define MI_PLATFORM_UNIX
131 #endif // !defined(MI_PLATFORM_UNIX)
132 
133 #if defined(__x86_64__)
134 
135 #if !defined(MI_PLATFORM_UNIX64)
136 #define MI_PLATFORM_UNIX64
137 #endif // !defined(MI_PLATFORM_UNIX64)
138 
139 #else // defined(__x86_64__)
140 
141 #if !defined(MI_PLATFORM_UNIX32)
142 #define MI_PLATFORM_UNIX32
143 #endif // !defined(MI_PLATFORM_UNIX32)
144 
145 #endif // defined(__x86_64__)
146 
147 #if defined(__linux__)
148 
149 #if !defined(MI_PLATFORM_LINUX)
150 #define MI_PLATFORM_LINUX
151 #endif // !defined(MI_PLATFORM_LINUX)
152 
153 #endif // defined(__linux__)
154 
155 #endif // defined(__unix__)
156 
157 // Platform detection end
158 
159 // Compiler detection start
160 
161 #if defined(_MSC_VER)
162 
163 #ifndef MI_SKIP_COMPILER_VERSION_CHECK
164 #if (_MSC_VER < 1400)
165 #error Microsoft Visual C++ compiler version is unsupported (smaller than 1400).
166 #endif
167 #endif // MI_SKIP_COMPILER_VERSION_CHECK
168 
169 #if !defined(MI_COMPILER_MSC)
170 #define MI_COMPILER_MSC _MSC_VER
171 #endif // !defined(MI_COMPILER_MSC)
172 
173 #elif defined(__ICC) // defined(_MSC_VER)
174 
175 #ifndef MI_SKIP_COMPILER_VERSION_CHECK
176 #if (__ICC < 900)
177 #error Intel C++ compiler version is unsupported (smaller than 900).
178 #endif
179 #endif // MI_SKIP_COMPILER_VERSION_CHECK
180 
181 #if !defined(MI_COMPILER_ICC)
182 #define MI_COMPILER_ICC __ICC
183 #endif // !defined(MI_COMPILER_ICC)
184 
185 #elif defined(__GNUC__) && !defined(__ICC) // #elif defined(__ICC)
186 
187 #ifndef MI_SKIP_COMPILER_VERSION_CHECK
188 #if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 3)))
189 #error GNU C++ compiler version is unsupported (smaller than 3.3).
190 #endif
191 
192 #if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4)))
193 #warning GNU C++ compiler version is unsupported (smaller than 3.4).
194 #endif
195 #endif // MI_SKIP_COMPILER_VERSION_CHECK
196 
197 #if !defined(MI_COMPILER_GCC)
198 #define MI_COMPILER_GCC __GNUC__
199 #endif // !defined(MI_COMPILER_GCC)
200 
201 #endif // defined(__GNUC__)
202 
203 // Compiler detection end
204 
205 // Processor architecture detection start
206 
207 #if defined(_M_IX86) || defined(__i386__) || defined(__x86_64__) || defined(_M_X64)
208 
209 #if !defined(MI_ARCH_X86)
210 #define MI_ARCH_X86
211 #endif // !defined(MI_ARCH_X86)
212 
213 #if (defined(__x86_64__) || defined(_M_X64) ) && !defined(MI_ARCH_X86_64)
214 #define MI_ARCH_X86_64
215 #endif // defined(__x86_64__) && !defined(MI_ARCH_X86_64)
216 
217 #if !defined(MI_ARCH_LITTLE_ENDIAN)
218 #define MI_ARCH_LITTLE_ENDIAN
219 #endif // !defined(MI_ARCH_LITTLE_ENDIAN)
220 
221 #elif defined(__sparcv9) // defined(_M_IX86) || defined(__i386__)
222 
223 #if ! defined( MI_ARCH_SPARC_64)
224 #define MI_ARCH_SPARC_64
225 #endif // !defined( MI_ARCH_SPARC_64)
226 
227 #if !defined(MI_ARCH_BIG_ENDIAN)
228 #define MI_ARCH_BIG_ENDIAN
229 #endif // !defined(MI_ARCH_BIG_ENDIAN)
230 
231 #elif defined(__powerpc64__)
232 
233 #if !defined(MI_ARCH_POWERPC_64)
234 #define MI_ARCH_POWERPC_64
235 #endif // !defined( MI_ARCH_POWERPC_64)
236 
237 #if !defined(__LITTLE_ENDIAN__)
238 #error Architecture POWERPC_64 is only supported in little endian mode.
239 #endif
240 
241 #if !defined(MI_ARCH_LITTLE_ENDIAN)
242 #define MI_ARCH_LITTLE_ENDIAN
243 #endif // !defined(MI_ARCH_LITTLE_ENDIAN)
244 
245 #elif defined(__aarch64__)
246 
247 #if !defined(MI_ARCH_ARM_64)
248 #define MI_ARCH_ARM_64
249 #endif // !defined( MI_ARCH_ARM_64)
250 
251 #if !defined(__AARCH64EL__)
252 #error Architecture ARM_64 is only supported in little endian mode.
253 #endif
254 
255 #if !defined(MI_ARCH_LITTLE_ENDIAN)
256 #define MI_ARCH_LITTLE_ENDIAN
257 #endif // !defined(MI_ARCH_LITTLE_ENDIAN)
258 
259 #endif
260 
261 #if defined(MI_ARCH_X86_64) || defined(MI_ARCH_SPARC_64) || defined(MI_ARCH_POWERPC_64) || defined(MI_ARCH_ARM_64)
262 #define MI_ARCH_64BIT
263 #endif // defined(MI_ARCH_X86_64) ...
264 
265 // Check that we detected one architecture
266 #if ! defined(MI_ARCH_BIG_ENDIAN) && ! defined(MI_ARCH_LITTLE_ENDIAN)
267 #error Architecture unknown, neither big-endian nor little-endian detected.
268 #endif
269 
270 // Processor architecture detection end
271 
283 #if defined(__cplusplus) && !defined(MI_FORCE_INLINE)
284 # if defined(_MSC_VER) /* Microsoft Visual C++ */
285 # define MI_FORCE_INLINE __forceinline
286 # elif defined(__GNUC__) /* GNU C/C++ Compiler */
287 # if defined(DEBUG)
288  /* Known bug in some g++ compiler versions: forced inlining produces
289  * buggy code when compiling without optimization.
290  */
291 # define MI_FORCE_INLINE inline
292 # else
293 # define MI_FORCE_INLINE __attribute__ ((always_inline)) inline
294 # endif
295 # else
296 # define MI_FORCE_INLINE inline
297 # endif
298 #endif
299 
300 
301 #ifdef MI_PLATFORM_WINDOWS
302 #define MI_BASE_DLL_FILE_EXT ".dll"
304 #else
305 #define MI_BASE_DLL_FILE_EXT ".so"
307 #endif
308 
309 #if (__cplusplus >= 201103L)
310 #define MI_CXX_FEATURE_RVALUE_REFERENCES
312 #endif
313  // end group mi_base_config
315 
316 #endif // MI_BASE_CONFIG_H