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 __GNUC__
|
---|
17 | #define NORETURN_PRINTF
|
---|
18 | #define PRINTF
|
---|
19 | #elif defined IN_GUEST
|
---|
20 | #define NORETURN_PRINTF __attribute__ ((__noreturn__,format(printf,1,2)))
|
---|
21 | #define PRINTF __attribute__ ((format(printf,1,2)))
|
---|
22 | #else
|
---|
23 | #define NORETURN_PRINTF
|
---|
24 | #define PRINTF
|
---|
25 | #endif
|
---|
26 |
|
---|
27 | #ifndef WARN
|
---|
28 | # ifndef IN_RING0
|
---|
29 | # define LOG(_m) do { crDebug _m ; } while (0)
|
---|
30 | # define LOGREL(_m) do { crDebug _m ; } while (0)
|
---|
31 | # define WARN(_m) do { crWarning _m ; AssertMsgFailed(_m); } while (0)
|
---|
32 | # else
|
---|
33 | # define LOG(_m) do { } while (0)
|
---|
34 | # define LOGREL(_m) do { } while (0)
|
---|
35 | # define WARN(_m) do { AssertMsgFailed(_m); } while (0)
|
---|
36 | # endif
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | DECLEXPORT(void) crEnableWarnings(int onOff);
|
---|
40 |
|
---|
41 | DECLEXPORT(void) crDebug(const char *format, ... ) PRINTF;
|
---|
42 | DECLEXPORT(void) crDbgCmdPrint(const char *description1, const char *description2, const char *cmd, ...);
|
---|
43 | DECLEXPORT(void) crDbgCmdSymLoadPrint(const char *modName, const void*pvAddress);
|
---|
44 | #if defined(DEBUG_misha) && defined(RT_OS_WINDOWS)
|
---|
45 | typedef void FNCRDEBUG(const char *format, ... ) PRINTF;
|
---|
46 | typedef FNCRDEBUG *PFNCRDEBUG;
|
---|
47 | DECLINLINE(PFNCRDEBUG) crGetDebug() {return crDebug;}
|
---|
48 | # define crWarning (RT_BREAKPOINT(), crDebug)
|
---|
49 | #else
|
---|
50 | DECLEXPORT(void) crWarning(const char *format, ... ) PRINTF;
|
---|
51 | #endif
|
---|
52 | DECLEXPORT(void) crInfo(const char *format, ... ) PRINTF;
|
---|
53 |
|
---|
54 | DECLEXPORT(void) crError(const char *format, ... ) NORETURN_PRINTF;
|
---|
55 |
|
---|
56 | /* Throw more info while opengl is not stable */
|
---|
57 | #if defined(DEBUG) || 1
|
---|
58 | # ifdef DEBUG_misha
|
---|
59 | # include <iprt/assert.h>
|
---|
60 | # define CRASSERT Assert
|
---|
61 | //extern int g_VBoxFbgFBreakDdi;
|
---|
62 | # define CR_DDI_PROLOGUE() do { /*if (g_VBoxFbgFBreakDdi) {Assert(0);}*/ } while (0)
|
---|
63 | # else
|
---|
64 | # define CRASSERT( PRED ) ((PRED)?(void)0:crWarning( "Assertion failed: %s=%d, file %s, line %d", #PRED, (int)(intptr_t)(PRED), __FILE__, __LINE__))
|
---|
65 | # define CR_DDI_PROLOGUE() do {} while (0)
|
---|
66 | # endif
|
---|
67 | # 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__))
|
---|
68 | #else
|
---|
69 | # define CRASSERT( PRED ) ((void)0)
|
---|
70 | # define THREADASSERT( PRED ) ((void)0)
|
---|
71 | # define CR_DDI_PROLOGUE() do {} while (0)
|
---|
72 | #endif
|
---|
73 |
|
---|
74 | #ifdef __cplusplus
|
---|
75 | }
|
---|
76 | #endif
|
---|
77 |
|
---|
78 | #endif /* CR_ERROR_H */
|
---|