]> icculus.org git repositories - btb/d2x.git/blob - include/dxxerror.h
Added other SDL_(Un)LockAudio statements to protect the audio_mixcallback function
[btb/d2x.git] / include / dxxerror.h
1 /*
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.
12 */
13
14 /*
15  *
16  * Header for error handling/printing/exiting code
17  *
18  */
19
20 #ifndef _ERROR_H
21 #define _ERROR_H
22
23 #include <stdio.h>
24
25 #ifdef __GNUC__
26 #define __noreturn __attribute__ ((noreturn))
27 #define __format __attribute__ ((format (printf, 1, 2)))
28 #else
29 #define __noreturn
30 #define __format
31 #endif
32
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);
42 void Int3(void);
43
44 #ifndef NDEBUG          //macros for debugging
45
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()
58 #else
59 #error Debug break not defined for your compiler or platform.
60 #endif
61
62 #define Assert(expr) ((expr)?(void)0:(void)_Assert(0,#expr,__FILE__,__LINE__))
63
64 #ifdef __GNUC__
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 = \
69         "int    3"      \
70         "jmp Error";
71
72 //#pragma aux Error aborts;
73 #else
74 // DPH: I'm not going to bother... it's not needed... :-)
75 #endif
76
77 #ifdef __WATCOMC__
78 //make assert do int3 (if expr false), then call func
79 #pragma aux _Assert parm [eax] [edx] [ebx] [ecx] = \
80         "test eax,eax"          \
81         "jnz    no_int3"                \
82         "int    3"                              \
83         "no_int3:"                      \
84         "call _Assert";
85 #endif
86
87 #else                                   //macros for real game
88
89 #ifdef __WATCOMC__
90 #pragma aux Error aborts;
91 #endif
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)
96 //void Int3();
97 #endif
98
99 #endif /* _ERROR_H */