2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
16 * Header for error handling/printing/exiting code
26 #define __noreturn __attribute__ ((noreturn))
27 #define __format __attribute__ ((format (printf, 1, 2)))
33 void warn_printf(char *s);
34 int error_init(void (*func)(char *), char *fmt,...); //init error system, set default message, returns 0=ok
35 void set_exit_message(char *fmt,...); //specify message to print at exit
36 void Warning(char *fmt,...); //print out warning message to user
37 void set_warn_func(void (*f)(char *s));//specifies the function to call with warning messages
38 void clear_warn_func(void (*f)(char *s));//say this function no longer valid
39 void _Assert(int expr,char *expr_text,char *filename,int linenum); //assert func
40 void Error(const char *fmt,...) __noreturn __format; //exit with error code=1, print message
41 void Assert(int expr);
44 #ifndef NDEBUG //macros for debugging
46 /* generate a debug break */
47 #if defined(__clang__)
48 #define Int3() __builtin_debugtrap()
49 #elif defined(__GNUC__) && (defined(__i386__) || defined(__amd64__))
50 #define Int3() ({ asm volatile ("int $3"); })
51 #elif defined __WATCOMC__
52 #pragma aux Int3 = "int 3h";
53 #elif defined _MSC_VER
54 #define Int3() __debugbreak()
55 #elif defined(__APPLE__) || defined(macintosh)
56 #include <CoreServices/CoreServices.h>
57 #define Int3() Debugger()
59 #error Debug break not defined for your compiler or platform.
62 #define Assert(expr) ((expr)?(void)0:(void)_Assert(0,#expr,__FILE__,__LINE__))
65 //#define Error(format, args...) ({ /*Int3();*/ Error(format , ## args); })
66 #elif defined __WATCOMC__
67 //make error do int3, then call func
68 #pragma aux Error aborts = \
72 //#pragma aux Error aborts;
74 // DPH: I'm not going to bother... it's not needed... :-)
78 //make assert do int3 (if expr false), then call func
79 #pragma aux _Assert parm [eax] [edx] [ebx] [ecx] = \
87 #else //macros for real game
90 #pragma aux Error aborts;
92 //Changed Assert and Int3 because I couldn't get the macros to compile -KRB
93 #define Assert(__ignore) ((void)0)
94 //void Assert(int expr);
95 #define Int3() ((void)0)