Main Page Class List Class Members

NvBlastAssert.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed to you
2 // under a form of NVIDIA software license agreement provided separately to you.
3 //
4 // Notice
5 // NVIDIA Corporation and its licensors retain all intellectual property and
6 // proprietary rights in and to this software and related documentation and
7 // any modifications thereto. Any use, reproduction, disclosure, or
8 // distribution of this software and related documentation without an express
9 // license agreement from NVIDIA Corporation is strictly prohibited.
10 //
11 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
12 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
13 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
14 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // Information and code furnished is believed to be accurate and reliable.
17 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
18 // information or for any infringement of patents or other rights of third parties that may
19 // result from its use. No license is granted by implication or otherwise under any patent
20 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
21 // This code supersedes and replaces all information previously supplied.
22 // NVIDIA Corporation products are not authorized for use as critical
23 // components in life support devices or systems without express written approval of
24 // NVIDIA Corporation.
25 //
26 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
27
28
29 #ifndef NVBLASTASSERT_H
30 #define NVBLASTASSERT_H
31
32
33 #include "NvBlastPreprocessor.h"
34
35
36 #if !NV_ENABLE_ASSERTS
37 #define NVBLAST_ASSERT(exp) ((void)0)
38 #define NVBLAST_ALWAYS_ASSERT_MESSAGE(message) ((void)0)
39 #define NVBLAST_ASSERT_WITH_MESSAGE(condition, message) ((void)0)
40 #else
41 #if NV_VC
42 #define NVBLAST_CODE_ANALYSIS_ASSUME(exp) \
43 __analysis_assume(!!(exp)) // This macro will be used to get rid of analysis warning messages if a NVBLAST_ASSERT is used
44 // to "guard" illegal mem access, for example.
45 #else
46 #define NVBLAST_CODE_ANALYSIS_ASSUME(exp)
47 #endif
48 #define NVBLAST_ASSERT(exp) \
49 { \
50 static bool _ignore = false; \
51 if (!(exp) && !_ignore) NvBlastAssertHandler(#exp, __FILE__, __LINE__, _ignore); \
52 NVBLAST_CODE_ANALYSIS_ASSUME(exp); \
53 } ((void)0)
54 #define NVBLAST_ALWAYS_ASSERT_MESSAGE(message) \
55 { \
56 static bool _ignore = false; \
57 if(!_ignore) \
58 { \
59 NvBlastAssertHandler(message, __FILE__, __LINE__, _ignore); \
60 } \
61 } ((void)0)
62 #define NVBLAST_ASSERT_WITH_MESSAGE(exp, message) \
63 { \
64 static bool _ignore = false; \
65 if (!(exp) && !_ignore) NvBlastAssertHandler(message, __FILE__, __LINE__, _ignore); \
66 NVBLAST_CODE_ANALYSIS_ASSUME(exp); \
67 } ((void)0)
68 #endif
69
70 #define NVBLAST_ALWAYS_ASSERT() NVBLAST_ASSERT(0)
71
72
73 extern "C"
74 {
75
76 NVBLAST_API void NvBlastAssertHandler(const char* expr, const char* file, int line, bool& ignore);
77
78 } // extern "C"
79
80
81 #endif // #ifndef NVBLASTASSERT_H
NvBlastAssertHandler
NVBLAST_API void NvBlastAssertHandler(const char *expr, const char *file, int line, bool &ignore)
NVBLAST_API
#define NVBLAST_API
Definition: NvBlastPreprocessor.h:37
NvBlastPreprocessor.h