Test initialisation of MUIA_List_AdjustWidth and MUIA_List_AdjustHeight, and
[AROS.git] / workbench / libs / codesets / src / debug.h
blob3831176ad0f85c24191c189b86f3059d55c21551
1 /***************************************************************************
3 codesets.library - Amiga shared library for handling different codesets
4 Copyright (C) 2001-2005 by Alfonso [alfie] Ranieri <alforan@tin.it>.
5 Copyright (C) 2005-2014 codesets.library Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 codesets.library project: http://sourceforge.net/projects/codesetslib/
19 $Id$
21 ***************************************************************************/
23 #ifndef DEBUG_H
24 #define DEBUG_H
26 // first we make sure all previously defined symbols are undefined now so
27 // that no other debug system interferes with ours.
28 #undef ENTER
29 #undef LEAVE
30 #undef RETURN
31 #undef SHOWVALUE
32 #undef SHOWPOINTER
33 #undef SHOWSTRING
34 #undef SHOWMSG
35 #undef STARTCLOCK
36 #undef STOPCLOCK
37 #undef D
38 #undef E
39 #undef W
40 #undef ASSERT
42 #if defined(DEBUG)
44 #include <stdarg.h>
46 // debug classes
47 #define DBC_CTRACE (1<<0) // call tracing (ENTER/LEAVE etc.)
48 #define DBC_REPORT (1<<1) // reports (SHOWVALUE/SHOWSTRING etc.)
49 #define DBC_ASSERT (1<<2) // asserts (ASSERT)
50 #define DBC_TIMEVAL (1<<3) // time evaluations (STARTCLOCK/STOPCLOCK)
51 #define DBC_DEBUG (1<<4) // debugging output D()
52 #define DBC_ERROR (1<<5) // error output E()
53 #define DBC_WARNING (1<<6) // warning output W()
54 #define DBC_ALL 0xffffffff
56 // debug flags
57 #define DBF_ALWAYS (1<<0)
58 #define DBF_STARTUP (1<<1) // for startup/shutdown events
59 #define DBF_UTF (1<<2) // for the UTF conversion routines.
60 #define DBF_ALL 0xffffffff
62 void InitDebug(void);
63 void SetupDebug(void);
65 void _ENTER(unsigned long dclass, const char *file, int line, const char *function);
66 void _LEAVE(unsigned long dclass, const char *file, int line, const char *function);
67 void _RETURN(unsigned long dclass, const char *file, int line, const char *function, unsigned long result);
68 void _SHOWVALUE(unsigned long dclass, unsigned long dflags, unsigned long value, int size, const char *name, const char *file, int line);
69 void _SHOWPOINTER(unsigned long dclass, unsigned long dflags, const void *p, const char *name, const char *file, int line);
70 void _SHOWSTRING(unsigned long dclass, unsigned long dflags, const char *string, const char *name, const char *file, int line);
71 void _SHOWMSG(unsigned long dclass, unsigned long dflags, const char *msg, const char *file, int line);
72 void _DPRINTF(unsigned long dclass, unsigned long dflags, const char *file, int line, const char *format, ...);
74 // Core class information class messages
75 #define ENTER() _ENTER(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__)
76 #define LEAVE() _LEAVE(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__)
77 #define RETURN(r) _RETURN(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__, (long)r)
78 #define SHOWVALUE(f, v) _SHOWVALUE(DBC_REPORT, f, (long)v, sizeof(v), #v, __FILE__, __LINE__)
79 #define SHOWPOINTER(f, p) _SHOWPOINTER(DBC_REPORT, f, p, #p, __FILE__, __LINE__)
80 #define SHOWSTRING(f, s) _SHOWSTRING(DBC_REPORT, f, s, #s, __FILE__, __LINE__)
81 #define SHOWMSG(f, m) _SHOWMSG(DBC_REPORT, f, m, __FILE__, __LINE__)
82 #define D(f, s, vargs...) _DPRINTF(DBC_DEBUG, f, __FILE__, __LINE__, s, ## vargs)
83 #define E(f, s, vargs...) _DPRINTF(DBC_ERROR, f, __FILE__, __LINE__, s, ## vargs)
84 #define W(f, s, vargs...) _DPRINTF(DBC_WARNING, f, __FILE__, __LINE__, s, ## vargs)
85 #define ASSERT(expression) \
86 ((void) \
87 ((expression) ? 0 : \
88 ( \
89 _DPRINTF(DBC_ASSERT, \
90 DBF_ALWAYS, \
91 __FILE__, \
92 __LINE__, \
93 "failed assertion '%s'", \
94 #expression), \
95 abort(), \
96 0 \
97 ) \
98 ) \
101 #else // DEBUG
103 #define ENTER() ((void)0)
104 #define LEAVE() ((void)0)
105 #define RETURN(r) ((void)0)
106 #define SHOWVALUE(f, v) ((void)0)
107 #define SHOWPOINTER(f, p) ((void)0)
108 #define SHOWSTRING(f, s) ((void)0)
109 #define SHOWMSG(f, m) ((void)0)
110 #define D(f, s, vargs...) ((void)0)
111 #define E(f, s, vargs...) ((void)0)
112 #define W(f, s, vargs...) ((void)0)
113 #define ASSERT(expression) ((void)0)
115 #endif // DEBUG
117 #endif // DEBUG_H