alsa.audio: add additional read cycle if there is more than 20ms space in buffer
[AROS.git] / external / openurl / cmd / debug.h
blob79b0d8a9b50ebe3b8d0e6a7c1a5fa3143aa8fb45
1 /***************************************************************************
3 openurl.library - universal URL display and browser launcher library
4 Copyright (C) 1998-2005 by Troels Walsted Hansen, et al.
5 Copyright (C) 2005-2013 by openurl.library Open Source Team
7 This library is free software; it has been placed in the public domain
8 and you can freely redistribute it and/or modify it. Please note, however,
9 that some components may be under the LGPL or GPL license.
11 This library 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.
15 openurl.library project: http://sourceforge.net/projects/openurllib/
17 $Id$
19 ***************************************************************************/
21 #ifndef DEBUG_H
22 #define DEBUG_H
24 // first we make sure all previously defined symbols are undefined now so
25 // that no other debug system interferes with ours.
26 #undef ENTER
27 #undef LEAVE
28 #undef RETURN
29 #undef SHOWVALUE
30 #undef SHOWPOINTER
31 #undef SHOWSTRING
32 #undef SHOWMSG
33 #undef STARTCLOCK
34 #undef STOPCLOCK
35 #undef D
36 #undef E
37 #undef W
38 #undef ASSERT
40 #if defined(DEBUG)
42 #ifndef EXEC_TYPES_H
43 #include <exec/types.h>
44 #endif
46 #if defined(__amigaos4__)
47 #include <proto/exec.h>
48 #ifdef __USE_INLINE__
49 #ifdef DebugPrintF
50 #undef DebugPrintF
51 #endif
52 #endif
53 #ifndef kprintf
54 #define kprintf(format, args...) ((struct ExecIFace *)((*(struct ExecBase **)4)->MainInterface))->DebugPrintF(format, ## args)
55 #endif
56 #elif defined(__MORPHOS__)
57 #include <exec/rawfmt.h>
58 #include <proto/exec.h>
59 #define KPutFmt(format, args) VNewRawDoFmt(format, (APTR)RAWFMTFUNC_SERIAL, NULL, args)
60 VOID kprintf(CONST_STRPTR formatString, ...);
61 #else
62 VOID kprintf(CONST_STRPTR formatString, ...);
63 #endif
65 // debug classes
66 #define DBC_CTRACE (1<<0) // call tracing (ENTER/LEAVE etc.)
67 #define DBC_REPORT (1<<1) // reports (SHOWVALUE/SHOWSTRING etc.)
68 #define DBC_ASSERT (1<<2) // asserts (ASSERT)
69 #define DBC_TIMEVAL (1<<3) // time evaluations (STARTCLOCK/STOPCLOCK)
70 #define DBC_DEBUG (1<<4) // debugging output D()
71 #define DBC_ERROR (1<<5) // error output E()
72 #define DBC_WARNING (1<<6) // warning output W()
73 #define DBC_ALL 0xffffffff
75 // debug flags
76 #define DBF_ALWAYS (1<<0)
77 #define DBF_STARTUP (1<<1) // for startup/shutdown events
78 #define DBF_TEMPLATE (1<<2) // template parsing in SmartReadArgs.c
79 #define DBF_ALL 0xffffffff
81 void SetupDebug(void);
83 void _ENTER(unsigned long dclass, const char *file, int line, const char *function);
84 void _LEAVE(unsigned long dclass, const char *file, int line, const char *function);
85 void _RETURN(unsigned long dclass, const char *file, int line, const char *function, unsigned long result);
86 void _SHOWVALUE(unsigned long dclass, unsigned long dflags, unsigned long value, int size, const char *name, const char *file, int line);
87 void _SHOWPOINTER(unsigned long dclass, unsigned long dflags, const void *p, const char *name, const char *file, int line);
88 void _SHOWSTRING(unsigned long dclass, unsigned long dflags, const char *string, const char *name, const char *file, int line);
89 void _SHOWMSG(unsigned long dclass, unsigned long dflags, const char *msg, const char *file, int line);
90 void _DPRINTF(unsigned long dclass, unsigned long dflags, const char *file, int line, const char *format, ...);
92 // Core class information class messages
93 #define ENTER() _ENTER(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__)
94 #define LEAVE() _LEAVE(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__)
95 #define RETURN(r) _RETURN(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__, (long)r)
96 #define SHOWVALUE(f, v) _SHOWVALUE(DBC_REPORT, f, (long)v, sizeof(v), #v, __FILE__, __LINE__)
97 #define SHOWPOINTER(f, p) _SHOWPOINTER(DBC_REPORT, f, p, #p, __FILE__, __LINE__)
98 #define SHOWSTRING(f, s) _SHOWSTRING(DBC_REPORT, f, s, #s, __FILE__, __LINE__)
99 #define SHOWMSG(f, m) _SHOWMSG(DBC_REPORT, f, m, __FILE__, __LINE__)
100 #define D(f, s, vargs...) _DPRINTF(DBC_DEBUG, f, __FILE__, __LINE__, s, ## vargs)
101 #define E(f, s, vargs...) _DPRINTF(DBC_ERROR, f, __FILE__, __LINE__, s, ## vargs)
102 #define W(f, s, vargs...) _DPRINTF(DBC_WARNING, f, __FILE__, __LINE__, s, ## vargs)
103 #define ASSERT(expression) \
104 ((void) \
105 ((expression) ? 0 : \
107 _DPRINTF(DBC_ASSERT, \
108 DBF_ALWAYS, \
109 __FILE__, \
110 __LINE__, \
111 "failed assertion '%s'", \
112 #expression), \
113 abort(), \
119 #else // DEBUG
121 #define ENTER() ((void)0)
122 #define LEAVE() ((void)0)
123 #define RETURN(r) ((void)0)
124 #define SHOWVALUE(f, v) ((void)0)
125 #define SHOWPOINTER(f, p) ((void)0)
126 #define SHOWSTRING(f, s) ((void)0)
127 #define SHOWMSG(f, m) ((void)0)
128 #define D(f, s, vargs...) ((void)0)
129 #define E(f, s, vargs...) ((void)0)
130 #define W(f, s, vargs...) ((void)0)
131 #define ASSERT(expression) ((void)0)
133 #endif // DEBUG
135 #endif // DEBUG_H