////// // // ilDIAGS.H - Some common diagnostics stuff... // // $Header: /Include/ilDIAGS.H 9 15/08/97 17:40 Cemsen $ // ////// #ifndef __ilDIAGS_HEADER #define __ilDIAGS_HEADER #ifndef DIAGS #define DIAGS 0 #endif #ifdef NO_PRINTFS #define printf(a...); {/*nothing*/} #else #define printf(a...); printf(a); #endif // -- Diagnostics macros ---------------------------------------------- #if defined(__WATCOMC__) && DIAGS void _DEBUGGER (void); #pragma aux _DEBUGGER = "int 3"; #define _DEBUGGER _DEBUGGER() #define _BREAK_IF(x,because); if (x) _DEBUGGER; #elif defined(_MSC_VER) && DIAGS #define _DEBUGGER __asm int 3; #define _BREAK_IF(x,becuase); if (x) _DEBUGGER; #elif defined(__psx__) && DIAGS #include #include #define _DEBUGGER printf ("DEBUG BREAKPOINT! %s@%d\n", __FILE__, __LINE__); \ PSYQpause (); #define _BREAK_IF(__expr,__because...) \ if (__expr) \ { \ printf ("INTERNAL ERROR (%s@%d)\n", __FILE__, __LINE__); \ printf (__because); \ printf ("\n"); \ pollhost (); \ PSYQpause (); \ } #define _WARN_IF(__expr,__because...) \ if (__expr) \ { \ printf ("WARNING (%s@%d)\n", __FILE__, __LINE__); \ printf (__because); \ printf ("\n"); \ } #define _BREAK_IF_INVALID_PTR(_ptr,__because...) \ { \ u_long p = (u_long)(_ptr); \ if (!(((p >= 0x80010000UL) && (p < 0x80800000UL)) || \ ((p >= 0xA0010000UL) && (p < 0xA0800000UL)) || \ ((p >= 0x00010000UL) && (p < 0x00800000UL)) || \ ((p >= 0x1f800000UL) && (p < 0x1f800400UL)) \ ) ) \ { \ printf ("INVALID POINTER (%s@%d) (" #_ptr "=%08lx)\n", __FILE__, __LINE__, p); \ printf (__because); \ printf ("\n"); \ pollhost (); \ PSYQpause (); \ } \ } #define CALL_POLLHOST pollhost (); #else // Not diagnostics (or unknown compiler) #if DIAGS #error Unknown compiler #endif #define _DEBUGGER { /*nothing*/ } #ifdef __GNUC__ #define CALL_POLLHOST { /*nothing*/ } #define _WARN_IF(x,because...); { /*nothing*/ } #define _BREAK_IF(x,because...); { /*nothing*/ } #define _BREAK_IF_INVALID_PTR(x,because...); { /*nothing*/ } #else #define CALL_POLLHOST { /*nothing*/ } #define _WARN_IF(x,y); { /*nothing*/ } #define _BREAK_IF(x,y); { /*nothing*/ } #define _BREAK_IF_INVALID_PTR(x,y); { /*nothing*/ } #endif #endif #endif // _ilDIAGS_HEADER