1 |
cebix |
1.1 |
/* |
2 |
|
|
* debug.h - Debugging utilities |
3 |
|
|
* |
4 |
cebix |
1.4 |
* Basilisk II (C) 1997-2001 Christian Bauer |
5 |
cebix |
1.1 |
* |
6 |
|
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#ifndef DEBUG_H |
22 |
|
|
#define DEBUG_H |
23 |
|
|
|
24 |
|
|
#if defined(WIN32) |
25 |
|
|
|
26 |
|
|
// Windows debugging goes where it's supposed to go |
27 |
|
|
#include <stdio.h> |
28 |
|
|
#include <stdarg.h> |
29 |
|
|
#include <time.h> |
30 |
|
|
#include <sys/types.h> |
31 |
|
|
#include <sys/timeb.h> |
32 |
|
|
|
33 |
|
|
static void inline _cdecl winbug( char *s, ...) |
34 |
|
|
{ |
35 |
cebix |
1.2 |
va_list vargs; |
36 |
cebix |
1.1 |
char msg[1024], date[50], hours[50]; |
37 |
cebix |
1.2 |
struct _timeb tstruct; |
38 |
cebix |
1.1 |
|
39 |
|
|
_ftime( &tstruct ); |
40 |
|
|
_strtime( hours ); |
41 |
|
|
_strdate( date ); |
42 |
cebix |
1.2 |
sprintf( msg, "B2: %s %s:%03u ", date, hours, tstruct.millitm ); |
43 |
cebix |
1.1 |
|
44 |
|
|
va_start( vargs, s ); |
45 |
cebix |
1.2 |
vsprintf( &msg[strlen(msg)], s, vargs ); |
46 |
cebix |
1.1 |
va_end( vargs ); |
47 |
|
|
|
48 |
|
|
OutputDebugString(msg); |
49 |
|
|
} |
50 |
|
|
#define bug winbug |
51 |
|
|
|
52 |
|
|
#elif defined(AMIGA) |
53 |
|
|
|
54 |
|
|
// Amiga debugging info goes to serial port (or sushi) |
55 |
|
|
#ifdef __cplusplus |
56 |
|
|
extern "C" { |
57 |
|
|
#endif |
58 |
|
|
extern void kprintf(const char *, ...); |
59 |
|
|
#ifdef __cplusplus |
60 |
|
|
} |
61 |
|
|
#endif |
62 |
|
|
#define bug kprintf |
63 |
|
|
|
64 |
|
|
#else |
65 |
|
|
|
66 |
|
|
// Other systems just print it to stdout |
67 |
|
|
#include <stdio.h> |
68 |
|
|
#define bug printf |
69 |
|
|
|
70 |
|
|
#endif |
71 |
|
|
|
72 |
|
|
#if DEBUG |
73 |
|
|
#define D(x) (x); |
74 |
|
|
#else |
75 |
|
|
#define D(x) ; |
76 |
|
|
#endif |
77 |
|
|
|
78 |
|
|
#endif |