Main Page Class List Class Members

- Main Page
- User's Guide
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# sdk/lowlevel/include/NvPreprocessor.h

Go to the documentation of this file.

    00001 // This code contains NVIDIA Confidential Information and is disclosed to you
    00002 // under a form of NVIDIA software license agreement provided separately to you.
    00003 //
    00004 // Notice
    00005 // NVIDIA Corporation and its licensors retain all intellectual property and
    00006 // proprietary rights in and to this software and related documentation and
    00007 // any modifications thereto. Any use, reproduction, disclosure, or
    00008 // distribution of this software and related documentation without an express
    00009 // license agreement from NVIDIA Corporation is strictly prohibited.
    00010 //
    00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
    00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
    00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
    00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
    00015 //
    00016 // Information and code furnished is believed to be accurate and reliable.
    00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
    00018 // information or for any infringement of patents or other rights of third parties that may
    00019 // result from its use. No license is granted by implication or otherwise under any patent
    00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
    00021 // This code supersedes and replaces all information previously supplied.
    00022 // NVIDIA Corporation products are not authorized for use as critical
    00023 // components in life support devices or systems without express written approval of
    00024 // NVIDIA Corporation.
    00025 //
    00026 // Copyright (c) 2008-2020 NVIDIA Corporation. All rights reserved.
    00027 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
    00028 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
    00029
    00030 #ifndef NV_NVFOUNDATION_NVPREPROCESSOR_H
    00031 #define NV_NVFOUNDATION_NVPREPROCESSOR_H
    00032
    00033 #include <stddef.h>
    00034
    00039 /*
    00040 The following preprocessor identifiers specify compiler, OS, and architecture.
    00041 All definitions have a value of 1 or 0, use '#if' instead of '#ifdef'.
    00042 */
    00043
    00047 #if defined(_MSC_VER)
    00048 #if _MSC_VER >= 1900
    00049 #define NV_VC 14
    00050 #elif _MSC_VER >= 1800
    00051 #define NV_VC 12
    00052 #elif _MSC_VER >= 1700
    00053 #define NV_VC 11
    00054 #elif _MSC_VER >= 1600
    00055 #define NV_VC 10
    00056 #elif _MSC_VER >= 1500
    00057 #define NV_VC 9
    00058 #else
    00059 #error "Unknown VC version"
    00060 #endif
    00061 #elif defined(__clang__)
    00062 #define NV_CLANG 1
    00063 #elif defined(__SNC__)
    00064 #define NV_SNC 1
    00065 #elif defined(__ghs__)
    00066 #define NV_GHS 1
    00067 #elif defined(__GNUC__) // note: __clang__, __SNC__, or __ghs__ imply __GNUC__
    00068 #define NV_GCC 1
    00069 #else
    00070 #error "Unknown compiler"
    00071 #endif
    00072
    00076 #if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_PARTITION_APP
    00077 #define NV_WINRT 1 // Windows Runtime, either on Windows RT or Windows 8
    00078 #elif defined(XBOXONE) || defined(_XBOX_ONE)
    00079 #define NV_XBOXONE 1
    00080 #elif defined(_WIN64) // note: XBOXONE implies _WIN64
    00081 #define NV_WIN64 1
    00082 #elif defined(_M_PPC)
    00083 #define NV_X360 1
    00084 #elif defined(_WIN32) // note: _M_PPC implies _WIN32
    00085 #define NV_WIN32 1
    00086 #elif defined(__ANDROID__)
    00087 #define NV_ANDROID 1
    00088 #elif defined(__linux__) // note: __ANDROID__ implies __linux__
    00089 #define NV_LINUX 1
    00090 #elif defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
    00091 #define NV_IOS 1
    00092 #elif defined(__APPLE__)
    00093 #define NV_OSX 1
    00094 #elif defined(__CELLOS_LV2__)
    00095 #define NV_PS3 1
    00096 #elif defined(__ORBIS__)
    00097 #define NV_PS4 1
    00098 #elif defined(__SNC__) && defined(__arm__)
    00099 #define NV_PSP2 1
    00100 #elif defined(__ghs__)
    00101 #define NV_WIIU 1
    00102 #else
    00103 #error "Unknown operating system"
    00104 #endif
    00105
    00109 #if defined(__x86_64__) || defined(_M_X64) // ps4 compiler defines _M_X64 without value
    00110 #define NV_X64 1
    00111 #elif defined(__i386__) || defined(_M_IX86)
    00112 #define NV_X86 1
    00113 #elif defined(__arm64__) || defined(__aarch64__)
    00114 #define NV_A64 1
    00115 #elif defined(__arm__) || defined(_M_ARM)
    00116 #define NV_ARM 1
    00117 #elif defined(__SPU__)
    00118 #define NV_SPU 1
    00119 #elif defined(__ppc__) || defined(_M_PPC) || defined(__CELLOS_LV2__)
    00120 #define NV_PPC 1
    00121 #else
    00122 #error "Unknown architecture"
    00123 #endif
    00124
    00128 #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)
    00129 #define NV_SSE2 1
    00130 #endif
    00131 #if defined(_M_ARM) || defined(__ARM_NEON__)
    00132 #define NV_NEON 1
    00133 #endif
    00134 #if defined(_M_PPC) || defined(__CELLOS_LV2__)
    00135 #define NV_VMX 1
    00136 #endif
    00137
    00141 #ifndef NV_VC
    00142 #define NV_VC 0
    00143 #endif
    00144 #ifndef NV_CLANG
    00145 #define NV_CLANG 0
    00146 #endif
    00147 #ifndef NV_SNC
    00148 #define NV_SNC 0
    00149 #endif
    00150 #ifndef NV_GHS
    00151 #define NV_GHS 0
    00152 #endif
    00153 #ifndef NV_GCC
    00154 #define NV_GCC 0
    00155 #endif
    00156 #ifndef NV_WINRT
    00157 #define NV_WINRT 0
    00158 #endif
    00159 #ifndef NV_XBOXONE
    00160 #define NV_XBOXONE 0
    00161 #endif
    00162 #ifndef NV_WIN64
    00163 #define NV_WIN64 0
    00164 #endif
    00165 #ifndef NV_X360
    00166 #define NV_X360 0
    00167 #endif
    00168 #ifndef NV_WIN32
    00169 #define NV_WIN32 0
    00170 #endif
    00171 #ifndef NV_ANDROID
    00172 #define NV_ANDROID 0
    00173 #endif
    00174 #ifndef NV_LINUX
    00175 #define NV_LINUX 0
    00176 #endif
    00177 #ifndef NV_IOS
    00178 #define NV_IOS 0
    00179 #endif
    00180 #ifndef NV_OSX
    00181 #define NV_OSX 0
    00182 #endif
    00183 #ifndef NV_PS3
    00184 #define NV_PS3 0
    00185 #endif
    00186 #ifndef NV_PS4
    00187 #define NV_PS4 0
    00188 #endif
    00189 #ifndef NV_PSP2
    00190 #define NV_PSP2 0
    00191 #endif
    00192 #ifndef NV_WIIU
    00193 #define NV_WIIU 0
    00194 #endif
    00195 #ifndef NV_X64
    00196 #define NV_X64 0
    00197 #endif
    00198 #ifndef NV_X86
    00199 #define NV_X86 0
    00200 #endif
    00201 #ifndef NV_A64
    00202 #define NV_A64 0
    00203 #endif
    00204 #ifndef NV_ARM
    00205 #define NV_ARM 0
    00206 #endif
    00207 #ifndef NV_SPU
    00208 #define NV_SPU 0
    00209 #endif
    00210 #ifndef NV_PPC
    00211 #define NV_PPC 0
    00212 #endif
    00213 #ifndef NV_SSE2
    00214 #define NV_SSE2 0
    00215 #endif
    00216 #ifndef NV_NEON
    00217 #define NV_NEON 0
    00218 #endif
    00219 #ifndef NV_VMX
    00220 #define NV_VMX 0
    00221 #endif
    00222
    00223 /*
    00224 define anything not defined through the command line to 0
    00225 */
    00226 #ifndef NV_DEBUG
    00227 #define NV_DEBUG 0
    00228 #endif
    00229 #ifndef NV_CHECKED
    00230 #define NV_CHECKED 0
    00231 #endif
    00232 #ifndef NV_PROFILE
    00233 #define NV_PROFILE 0
    00234 #endif
    00235 #ifndef NV_NVTX
    00236 #define NV_NVTX 0
    00237 #endif
    00238 #ifndef NV_DOXYGEN
    00239 #define NV_DOXYGEN 0
    00240 #endif
    00241
    00245 // compiler
    00246 #define NV_GCC_FAMILY (NV_CLANG || NV_SNC || NV_GHS || NV_GCC)
    00247 // os
    00248 #define NV_WINDOWS_FAMILY (NV_WINRT || NV_WIN32 || NV_WIN64)
    00249 #define NV_MICROSOFT_FAMILY (NV_XBOXONE || NV_X360 || NV_WINDOWS_FAMILY)
    00250 #define NV_LINUX_FAMILY (NV_LINUX || NV_ANDROID)
    00251 #define NV_APPLE_FAMILY (NV_IOS || NV_OSX)                  // equivalent to #if __APPLE__
    00252 #define NV_UNIX_FAMILY (NV_LINUX_FAMILY || NV_APPLE_FAMILY) // shortcut for unix/posix platforms
    00253 // architecture
    00254 #define NV_INTEL_FAMILY (NV_X64 || NV_X86)
    00255 #define NV_ARM_FAMILY (NV_ARM || NV_A64)
    00256 #define NV_P64_FAMILY (NV_X64 || NV_A64) // shortcut for 64-bit architectures
    00257
    00258 // shortcut for PS3 PPU
    00259 #define NV_PPU (NV_PS3&& NV_PPC)
    00260
    00264 #ifndef NV_ENABLE_ASSERTS
    00265 #if NV_DEBUG && !defined(__CUDACC__)
    00266 #define NV_ENABLE_ASSERTS 1
    00267 #else
    00268 #define NV_ENABLE_ASSERTS 0
    00269 #endif
    00270 #endif
    00271
    00275 #ifndef NV_C_EXPORT
    00276 #if NV_WINDOWS_FAMILY || NV_LINUX || NV_PS4 || NV_XBOXONE
    00277 #define NV_C_EXPORT extern "C"
    00278 #else
    00279 #define NV_C_EXPORT
    00280 #endif
    00281 #endif
    00282
    00283 #if NV_UNIX_FAMILY && __GNUC__ >= 4
    00284 #define NV_UNIX_EXPORT __attribute__((visibility("default")))
    00285 #else
    00286 #define NV_UNIX_EXPORT
    00287 #endif
    00288
    00289 #if NV_WINDOWS_FAMILY
    00290 #define NV_DLL_EXPORT __declspec(dllexport)
    00291 #define NV_DLL_IMPORT __declspec(dllimport)
    00292 #else
    00293 #define NV_DLL_EXPORT NV_UNIX_EXPORT
    00294 #define NV_DLL_IMPORT
    00295 #endif
    00296
    00306 #if NV_WINDOWS_FAMILY && !NV_ARM_FAMILY || NV_WINRT
    00307 #ifndef NV_FOUNDATION_DLL
    00308 #define NV_FOUNDATION_API NV_DLL_IMPORT
    00309 #elif NV_FOUNDATION_DLL
    00310 #define NV_FOUNDATION_API NV_DLL_EXPORT
    00311 #endif
    00312 #elif NV_UNIX_FAMILY
    00313 #ifdef NV_FOUNDATION_DLL
    00314 #define NV_FOUNDATION_API NV_UNIX_EXPORT
    00315 #endif
    00316 #endif
    00317
    00318 #ifndef NV_FOUNDATION_API
    00319 #define NV_FOUNDATION_API
    00320 #endif
    00321
    00325 #ifndef NV_CALL_CONV
    00326 #if NV_MICROSOFT_FAMILY
    00327 #define NV_CALL_CONV __cdecl
    00328 #else
    00329 #define NV_CALL_CONV
    00330 #endif
    00331 #endif
    00332
    00336 #if NV_VC
    00337 #define NV_PUSH_PACK_DEFAULT __pragma(pack(push, 8))
    00338 #define NV_POP_PACK __pragma(pack(pop))
    00339 #elif NV_GCC_FAMILY && !NV_SPU
    00340 #define NV_PUSH_PACK_DEFAULT _Pragma("pack(push, 8)")
    00341 #define NV_POP_PACK _Pragma("pack(pop)")
    00342 #else
    00343 #define NV_PUSH_PACK_DEFAULT
    00344 #define NV_POP_PACK
    00345 #endif
    00346
    00350 #define NV_INLINE inline
    00351 #if NV_MICROSOFT_FAMILY
    00352 #pragma inline_depth(255)
    00353 #endif
    00354
    00358 #if NV_VC
    00359 #define NV_FORCE_INLINE __forceinline
    00360 #elif NV_LINUX // Workaround; Fedora Core 3 do not agree with force inline and NvcPool
    00361 #define NV_FORCE_INLINE inline
    00362 #elif NV_GCC_FAMILY
    00363 #define NV_FORCE_INLINE inline __attribute__((always_inline))
    00364 #else
    00365 #define NV_FORCE_INLINE inline
    00366 #endif
    00367
    00371 #if NV_MICROSOFT_FAMILY
    00372 #define NV_NOINLINE __declspec(noinline)
    00373 #elif NV_GCC_FAMILY
    00374 #define NV_NOINLINE __attribute__((noinline))
    00375 #else
    00376 #define NV_NOINLINE
    00377 #endif
    00378
    00382 #if defined(__CUDACC__)
    00383 #define NV_RESTRICT __restrict__
    00384 #else
    00385 #define NV_RESTRICT __restrict
    00386 #endif
    00387
    00391 #if NV_MICROSOFT_FAMILY
    00392 #define NV_NOALIAS __declspec(noalias)
    00393 #else
    00394 #define NV_NOALIAS
    00395 #endif
    00396
    00408 #ifndef NV_ALIGN
    00409 #if NV_MICROSOFT_FAMILY
    00410 #define NV_ALIGN(alignment, decl) __declspec(align(alignment)) decl
    00411 #define NV_ALIGN_PREFIX(alignment) __declspec(align(alignment))
    00412 #define NV_ALIGN_SUFFIX(alignment)
    00413 #elif NV_GCC_FAMILY
    00414 #define NV_ALIGN(alignment, decl) decl __attribute__((aligned(alignment)))
    00415 #define NV_ALIGN_PREFIX(alignment)
    00416 #define NV_ALIGN_SUFFIX(alignment) __attribute__((aligned(alignment)))
    00417 #else
    00418 #define NV_ALIGN(alignment, decl)
    00419 #define NV_ALIGN_PREFIX(alignment)
    00420 #define NV_ALIGN_SUFFIX(alignment)
    00421 #endif
    00422 #endif
    00423
    00434 #define NV_DEPRECATED
    00435
    00440 // static assert
    00441 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) || defined(__ORBIS__)
    00442 #define NV_COMPILE_TIME_ASSERT(exp) typedef char NvCompileTimeAssert_Dummy[(exp) ? 1 : -1] __attribute__((unused))
    00443 #else
    00444 #define NV_COMPILE_TIME_ASSERT(exp) typedef char NvCompileTimeAssert_Dummy[(exp) ? 1 : -1]
    00445 #endif
    00446
    00447 #if NV_GCC_FAMILY && !NV_SNC && !NV_GHS
    00448 #define NV_OFFSET_OF(X, Y) __builtin_offsetof(X, Y)
    00449 #else
    00450 #define NV_OFFSET_OF(X, Y) offsetof(X, Y)
    00451 #endif
    00452
    00453 #define NV_OFFSETOF_BASE 0x100 // casting the null ptr takes a special-case code path, which we don't want
    00454 #define NV_OFFSET_OF_RT(Class, Member)                                                                                 \
    00455     (reinterpret_cast<size_t>(&reinterpret_cast<Class*>(NV_OFFSETOF_BASE)->Member) - size_t(NV_OFFSETOF_BASE))
    00456
    00457 // check that exactly one of NDEBUG and _DEBUG is defined
    00458 #if !defined(NDEBUG) ^ defined(_DEBUG)
    00459 #error Exactly one of NDEBUG and _DEBUG needs to be defined!
    00460 #endif
    00461
    00462 // make sure NV_CHECKED is defined in all _DEBUG configurations as well
    00463 #if !defined(NV_CHECKED) && defined(NV_DEBUG)
    00464 #error NV_CHECKED must be defined when NV_DEBUG is defined
    00465 #endif
    00466
    00467 #ifdef __CUDACC__
    00468 #define NV_CUDA_CALLABLE __host__ __device__
    00469 #else
    00470 #define NV_CUDA_CALLABLE
    00471 #endif
    00472
    00473 // avoid unreferenced parameter warning
    00474 // preferred solution: omit the parameter's name from the declaration
    00475 template <class T>
    00476 NV_CUDA_CALLABLE NV_INLINE void NV_UNUSED(T const&)
    00477 {
    00478 }
    00479
    00480 // Ensure that the application hasn't tweaked the pack value to less than 8, which would break
    00481 // matching between the API headers and the binaries
    00482 // This assert works on win32/win64/360/ps3, but may need further specialization on other platforms.
    00483 // Some GCC compilers need the compiler flag -malign-double to be set.
    00484 // Apparently the apple-clang-llvm compiler doesn't support malign-double.
    00485 #if NV_PS4 || NV_APPLE_FAMILY
    00486 struct NvPackValidation
    00487 {
    00488     char _;
    00489     long a;
    00490 };
    00491 #elif NV_ANDROID
    00492 struct NvPackValidation
    00493 {
    00494     char _;
    00495     double a;
    00496 };
    00497 #else
    00498 struct NvPackValidation
    00499 {
    00500     char _;
    00501     long long a;
    00502 };
    00503 #endif
    00504 #if !NV_APPLE_FAMILY
    00505 NV_COMPILE_TIME_ASSERT(NV_OFFSET_OF(NvPackValidation, a) == 8);
    00506 #endif
    00507
    00508 // use in a cpp file to suppress LNK4221
    00509 #if NV_VC
    00510 #define NV_DUMMY_SYMBOL                                                                                                \
    00511     namespace                                                                                                          \
    00512     {                                                                                                                  \
    00513     char NvDummySymbol;                                                                                                \
    00514     }
    00515 #else
    00516 #define NV_DUMMY_SYMBOL
    00517 #endif
    00518
    00519 #if NV_GCC_FAMILY && !NV_GHS
    00520 #define NV_WEAK_SYMBOL __attribute__((weak)) // this is to support SIMD constant merging in template specialization
    00521 #else
    00522 #define NV_WEAK_SYMBOL
    00523 #endif
    00524
    00525 // Macro for avoiding default assignment and copy, because doing this by inheritance can increase class size on some
    00526 // platforms.
    00527 #define NV_NOCOPY(Class)                                                                                               \
    00528     \
    00529 protected:                                                                                                             \
    00530     Class(const Class&);                                                                                               \
    00531     Class& operator=(const Class&);
    00532
    00533 #define NV_STRINGIZE_HELPER(X) #X
    00534 #define NV_STRINGIZE(X) NV_STRINGIZE_HELPER(X)
    00535
    00536 #define NV_CONCAT_HELPER(X, Y) X##Y
    00537 #define NV_CONCAT(X, Y) NV_CONCAT_HELPER(X, Y)
    00538
    00540 #endif // #ifndef NV_NVFOUNDATION_NVPREPROCESSOR_H

Copyright © 2015-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com