MDL SDK API nvidia_logo_transpbg.gif Up
config.h
Go to the documentation of this file.
1/***************************************************************************************************
2 * Copyright 2022 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 "2022"
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
186#elif defined(__GNUC__) && defined(__clang__) // #elif defined(__clang__)
187
188#ifndef MI_SKIP_COMPILER_VERSION_CHECK
189#if !defined(MI_COMPILER_CLANG)
190#define MI_COMPILER_CLANG __clang__
191#endif // !defined(MI_COMPILER_CLANG)
192
193#if !defined(MI_COMPILER_GCC)
194#define MI_COMPILER_GCC __GNUC__
195#endif // !defined(MI_COMPILER_GCC)
196#endif // MI_SKIP_COMPILER_VERSION_CHECK
197
198#elif defined(__GNUC__) && !defined(__ICC) // #elif defined(__ICC)
199
200#ifndef MI_SKIP_COMPILER_VERSION_CHECK
201#if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 3)))
202#error GNU C++ compiler version is unsupported (smaller than 3.3).
203#endif
204
205#if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4)))
206#warning GNU C++ compiler version is unsupported (smaller than 3.4).
207#endif
208#endif // MI_SKIP_COMPILER_VERSION_CHECK
209
210#if !defined(MI_COMPILER_GCC)
211#define MI_COMPILER_GCC __GNUC__
212#endif // !defined(MI_COMPILER_GCC)
213
214#endif // defined(__GNUC__)
215
216// Compiler detection end
217
218// Processor architecture detection start
219
220#if defined(_M_IX86) || defined(__i386__) || defined(__x86_64__) || defined(_M_X64)
221
222#if !defined(MI_ARCH_X86)
223#define MI_ARCH_X86
224#endif // !defined(MI_ARCH_X86)
225
226#if (defined(__x86_64__) || defined(_M_X64) ) && !defined(MI_ARCH_X86_64)
227#define MI_ARCH_X86_64
228#endif // defined(__x86_64__) && !defined(MI_ARCH_X86_64)
229
230#if !defined(MI_ARCH_LITTLE_ENDIAN)
231#define MI_ARCH_LITTLE_ENDIAN
232#endif // !defined(MI_ARCH_LITTLE_ENDIAN)
233
234#elif defined(__sparcv9) // defined(_M_IX86) || defined(__i386__)
235
236#if ! defined( MI_ARCH_SPARC_64)
237#define MI_ARCH_SPARC_64
238#endif // !defined( MI_ARCH_SPARC_64)
239
240#if !defined(MI_ARCH_BIG_ENDIAN)
241#define MI_ARCH_BIG_ENDIAN
242#endif // !defined(MI_ARCH_BIG_ENDIAN)
243
244#elif defined(__powerpc64__)
245
246#if !defined(MI_ARCH_POWERPC_64)
247#define MI_ARCH_POWERPC_64
248#endif // !defined( MI_ARCH_POWERPC_64)
249
250#if !defined(__LITTLE_ENDIAN__)
251#error Architecture POWERPC_64 is only supported in little endian mode.
252#endif
253
254#if !defined(MI_ARCH_LITTLE_ENDIAN)
255#define MI_ARCH_LITTLE_ENDIAN
256#endif // !defined(MI_ARCH_LITTLE_ENDIAN)
257
258#elif defined(__aarch64__) || defined(_M_ARM64)
259
260#if !defined(MI_ARCH_ARM_64)
261#define MI_ARCH_ARM_64
262#endif // !defined( MI_ARCH_ARM_64)
263
264#if !defined(__AARCH64EL__) && !defined(_M_ARM64) // windows implies little endian mode for now
265#error Architecture ARM_64 is only supported in little endian mode.
266#endif
267
268#if !defined(MI_ARCH_LITTLE_ENDIAN)
269#define MI_ARCH_LITTLE_ENDIAN
270#endif // !defined(MI_ARCH_LITTLE_ENDIAN)
271
272#endif
273
274#if defined(MI_ARCH_X86_64) \
275 || defined(MI_ARCH_SPARC_64) \
276 || defined(MI_ARCH_POWERPC_64) \
277 || defined(MI_ARCH_ARM_64)
278#define MI_ARCH_64BIT
279#endif // defined(MI_ARCH_X86_64) ...
280
281// Check that we detected one architecture
282#if ! defined(MI_ARCH_BIG_ENDIAN) && ! defined(MI_ARCH_LITTLE_ENDIAN)
283#error Architecture unknown, neither big-endian nor little-endian detected.
284#endif
285
286// Processor architecture detection end
287
299#if defined(__cplusplus) && !defined(MI_FORCE_INLINE)
300# if defined(_MSC_VER) /* Microsoft Visual C++ */
301# define MI_FORCE_INLINE __forceinline
302# elif defined(__GNUC__) /* GNU C/C++ Compiler */
303# if defined(DEBUG)
304 /* Known bug in some g++ compiler versions: forced inlining produces
305 * buggy code when compiling without optimization.
306 */
307# define MI_FORCE_INLINE inline
308# else
309# define MI_FORCE_INLINE __attribute__ ((always_inline)) inline
310# endif
311# else
312# define MI_FORCE_INLINE inline
313# endif
314#endif
315
316#ifdef __CUDACC__
317#define MI_HOST_DEVICE_INLINE __host__ __device__ __forceinline__
318#ifndef MI_DEVICE_INLINE
319#define MI_DEVICE_INLINE __device__ __forceinline__
320#endif
321#else
322#ifdef __cplusplus
323#define MI_HOST_DEVICE_INLINE MI_FORCE_INLINE
324#ifndef MI_DEVICE_INLINE
325#define MI_DEVICE_INLINE MI_FORCE_INLINE
326#endif
327#else
328#define MI_HOST_DEVICE_INLINE
329#ifndef MI_DEVICE_INLINE
330#define MI_DEVICE_INLINE
331#endif
332#endif
333#endif
334
335#ifdef MI_PLATFORM_WINDOWS
337#define MI_BASE_DLL_FILE_EXT ".dll"
338#else
340#define MI_BASE_DLL_FILE_EXT ".so"
341#endif
342
343#if (__cplusplus >= 201103L)
345#define MI_CXX_FEATURE_RVALUE_REFERENCES
346#endif
347 // end group mi_base_config
349
350#endif // MI_BASE_CONFIG_H