Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / classes / gadgets / gradientslider / Debug.h
blob46aa22b1fde1485b87c84a344f995452745d24f9
1 #ifndef DEBUG_H
2 #define DEBUG_H
3 /*
4 ** $VER: Debug.h 2.1 (19.10.97)
5 **
6 ** Copyright (C) 1995,96,97 Bernardo Innocenti. All rights reserved.
7 **
8 ** Use 4 chars wide TABs to read this file
9 **
10 ** Some handy debug macros which are automatically excluded when the
11 ** DEBUG preprocessor sysmbol is not defined. To make debug executables,
12 ** link with debug.lib or any module containing the kprintf() function.
14 ** Here is a short description of the macros defined below:
16 ** ILLEGAL
17 ** Output an inline "ILLEGAL" 68K opcode, which will
18 ** be interpreted as a breakpoint by most debuggers.
20 ** DBPRINTF
21 ** Output a formatted string to the debug console. This
22 ** macro uses the debug.lib kprintf() function by default.
24 ** ASSERT(x)
25 ** Do nothing if the expression <x> evalutates to a
26 ** non-zero value, output a debug message otherwise.
28 ** ASSERT_VALID(x)
29 ** Checks if the expression <x> points to a valid
30 ** memory location, and outputs a debug message
31 ** otherwise. A NULL pointer is considered VALID.
33 ** ASSERT_VALIDNO0(x)
34 ** Checks if the expression <x> points to a valid
35 ** memory location, and outputs a debug message
36 ** otherwise. A NULL pointer is considered INVALID.
38 ** DB(x)
39 ** Compile the expression <x> when making a debug
40 ** executable, leave it out otherwise.
43 #ifdef DEBUG
45 /* Needed for TypeOfMem() */
46 #ifndef PROTO_EXEC_H
47 #include <proto/exec.h>
48 #endif /* PROTO_EXEC_H */
50 #if defined(__SASC)
52 extern void __builtin_emit (int);
53 #define ILLEGAL __builtin_emit(0x4AFC)
54 STDARGS extern void kprintf (const char *, ...);
56 #elif defined(__GNUC__)
58 /* Currently, there is no kprintf() function in libamiga.a */
59 #define kprintf printf
61 /* GCC doesn't accept asm statemnts in the middle of an
62 * expression such as "a ? b : asm(something)".
64 #define ILLEGAL illegal()
65 static inline int illegal(void) { asm ("illegal"); return 0; }
66 extern void STDARGS FORMATCALL(printf,1,2) kprintf (const char *, ...);
68 #else
69 #error Please add compiler specific definitions for your compiler
70 #endif
72 #if defined(__SASC) || defined (__GNUC__)
74 /* common definitions for ASSERT and DB macros */
76 #define DBPRINTF kprintf
78 #define ASSERT(x) ( (x) ? 0 : \
79 ( DBPRINTF ("\x07%s, %ld: assertion failed: " #x "\n", \
80 __FILE__, __LINE__) , ILLEGAL ) );
82 #define ASSERT_VALID(x) ( ((((APTR)(x)) == NULL) || \
83 (((LONG)(x) > 1024) && TypeOfMem ((APTR)(x)))) ? 0 : \
84 ( DBPRINTF ("\x07%s, %ld: bad address: " #x " = $%lx\n", \
85 __FILE__, __LINE__, (APTR)(x)) , ILLEGAL ) );
87 #define ASSERT_VALIDNO0(x) ( (((LONG)(x) > 1024) && \
88 TypeOfMem ((APTR)(x))) ? 0 : \
89 ( DBPRINTF ("\x07%s, %ld: bad address: " #x " = $%lx\n", \
90 __FILE__, __LINE__, (APTR)(x)) , ILLEGAL ) );
92 #define DB(x) x
93 #endif
95 #else
96 #define ASSERT_VALID(x)
97 #define ASSERT_VALIDNO0(x)
98 #define ASSERT(x)
99 #define DB(x)
100 #endif /* DEBUG */
102 #endif /* !DEBUG_H */