1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved.
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #ifndef CR_ERROR_H
|
---|
8 | #define CR_ERROR_H
|
---|
9 |
|
---|
10 | #include <iprt/cdefs.h>
|
---|
11 |
|
---|
12 | #ifdef __cplusplus
|
---|
13 | extern "C" {
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | #ifndef WARN
|
---|
17 | # ifndef IN_RING0
|
---|
18 | # define LOG(_m) do { crDebug _m ; } while (0)
|
---|
19 | # define LOGREL(_m) do { crDebug _m ; } while (0)
|
---|
20 | # define WARN(_m) do { crWarning _m ; AssertMsgFailed(_m); } while (0)
|
---|
21 | # else
|
---|
22 | # define LOG(_m) do { } while (0)
|
---|
23 | # define LOGREL(_m) do { } while (0)
|
---|
24 | # define WARN(_m) do { AssertMsgFailed(_m); } while (0)
|
---|
25 | # endif
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | DECLEXPORT(void) crEnableWarnings(int onOff);
|
---|
29 |
|
---|
30 | DECLEXPORT(void) crDebug(const char *format, ... ) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
31 | DECLEXPORT(void) crDbgCmdPrint(const char *description1, const char *description2, const char *cmd, ...);
|
---|
32 | DECLEXPORT(void) crDbgCmdSymLoadPrint(const char *modName, const void*pvAddress);
|
---|
33 | #if defined(DEBUG_misha) && defined(RT_OS_WINDOWS)
|
---|
34 | typedef void FNCRDEBUG(const char *format, ... ) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
35 | typedef FNCRDEBUG *PFNCRDEBUG;
|
---|
36 | DECLINLINE(PFNCRDEBUG) crGetDebug() {return crDebug;}
|
---|
37 | # define crWarning (RT_BREAKPOINT(), crDebug)
|
---|
38 | #else
|
---|
39 | DECLEXPORT(void) crWarning(const char *format, ... ) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
40 | #endif
|
---|
41 | DECLEXPORT(void) crInfo(const char *format, ... ) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
42 |
|
---|
43 | DECLEXPORT(void) crError(const char *format, ... ) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
44 |
|
---|
45 | /* Throw more info while opengl is not stable */
|
---|
46 | #if defined(DEBUG) || 1
|
---|
47 | # ifdef DEBUG_misha
|
---|
48 | # include <iprt/assert.h>
|
---|
49 | # define CRASSERT Assert
|
---|
50 | /*extern int g_VBoxFbgFBreakDdi;*/
|
---|
51 | # define CR_DDI_PROLOGUE() do { /*if (g_VBoxFbgFBreakDdi) {Assert(0);}*/ } while (0)
|
---|
52 | # else
|
---|
53 | # define CRASSERT( PRED ) ((PRED)?(void)0:crWarning( "Assertion failed: %s=%d, file %s, line %d", #PRED, (int)(intptr_t)(PRED), __FILE__, __LINE__))
|
---|
54 | # define CR_DDI_PROLOGUE() do {} while (0)
|
---|
55 | # endif
|
---|
56 | # define THREADASSERT( PRED ) ((PRED)?(void)0:crError( "Are you trying to run a threaded app ?\nBuild with 'make threadsafe'\nAssertion failed: %s, file %s, line %d", #PRED, __FILE__, __LINE__))
|
---|
57 | #else
|
---|
58 | # define CRASSERT( PRED ) ((void)0)
|
---|
59 | # define THREADASSERT( PRED ) ((void)0)
|
---|
60 | # define CR_DDI_PROLOGUE() do {} while (0)
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | #ifdef __cplusplus
|
---|
64 | }
|
---|
65 | #endif
|
---|
66 |
|
---|
67 | #endif /* CR_ERROR_H */
|
---|