Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/mpg123/src/common/debug.h
4389 views
1
/*
2
Some macros for printing debugging/warning/error messages with location info.
3
4
public domain (or LGPL / GPL, if you like that more;-)
5
generated by debugdef.pl, what was
6
trivially written by Thomas Orgis <[email protected]>
7
8
You decide to define DEBUG or not and write debug("foo") or
9
mdebug("foo: %s", message) and variants with more arguments and this
10
is converted to an elaborate call to fprintf(stderr, ...) that prints your
11
message with a line end attached and with information on where the call
12
occured.
13
*/
14
15
#include "config.h"
16
17
#ifdef ME
18
#define DBGPRFX ME": "
19
#else
20
#define DBGPRFX ""
21
#endif
22
23
#define noop ((void)0)
24
25
#ifdef XDEBUG
26
#define mxdebug(s, ...) mdebug(s, __VA_ARGS__)
27
#define xdebug(s) debug(s)
28
#else
29
#define mxdebug(s, ...) noop
30
#define xdebug(s) noop
31
#endif
32
33
// Used for debugging and warning messages.
34
#include <stdio.h>
35
#define debug_print(t, s, ...) fprintf(stderr, DBGPRFX "[" __FILE__ ":%s():%i] " t ": " s "\n", __func__, __LINE__, __VA_ARGS__)
36
37
#ifdef DEBUG
38
#define mdebug(s, ...) debug_print("debug", s, __VA_ARGS__)
39
#else
40
#define mdebug(s, ...) noop
41
#endif
42
#define debug(s) mdebug("%s", s)
43
44
// Print warning message.
45
#ifndef NO_WARNING
46
#define mwarning(s, ...) debug_print("warning", s, __VA_ARGS__)
47
#else
48
#define mwarning(s, ...)
49
#endif
50
#define warning(s) mwarning("%s", s)
51
52
// Print error message.
53
#ifndef NO_ERRORMSG
54
#define merror(s, ...) debug_print("error", s, __VA_ARGS__)
55
#else
56
#define merror(s, ...) noop
57
#endif
58
#define error(s) merror("%s", s)
59
60
// Print error message and return given value.
61
#ifndef NO_ERETURN
62
#define mereturn(rv, s, ...) do{ debug_print("ereturn", s, __VA_ARGS__); return rv; } while (0)
63
#else
64
#define mereturn(rv, s, ...) return rv
65
#endif
66
#define ereturn(rv, s) mereturn(rv, "%s", s)
67
68
// For old code that had to hardcode the argument number.
69
70
#define debug1(s, a) mdebug(s,a)
71
#define debug2(s, a, b) mdebug(s, a, b)
72
#define debug3(s, a, b, c) mdebug(s, a, b, c)
73
#define debug4(s, a, b, c, d) mdebug(s, a, b, c, d)
74
#define debug5(s, a, b, c, d, e) mdebug(s, a, b, c, d, e)
75
#define debug6(s, a, b, c, d, e, f) mdebug(s, a, b, c, d, e, f)
76
#define debug7(s, a, b, c, d, e, f, g) mdebug(s, a, b, c, d, e, f, g)
77
#define debug8(s, a, b, c, d, e, f, g, h) mdebug(s, a, b, c, d, e, f, g, h)
78
#define debug9(s, a, b, c, d, e, f, g, h, i) mdebug(s, a, b, c, d, e, f, g, h, i)
79
#define debug10(s, a, b, c, d, e, f, g, h, i, j) mdebug(s, a, b, c, d, e, f, g, h, i, j)
80
#define debug11(s, a, b, c, d, e, f, g, h, i, j, k) mdebug(s, a, b, c, d, e, f, g, h, i, j, k)
81
#define debug12(s, a, b, c, d, e, f, g, h, i, j, k, l) mdebug(s, a, b, c, d, e, f, g, h, i, j, k, l)
82
#define debug13(s, a, b, c, d, e, f, g, h, i, j, k, l, m) mdebug(s, a, b, c, d, e, f, g, h, i, j, k, l, m)
83
#define debug14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) mdebug(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
84
#define debug15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) mdebug(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
85
86
#define warning1(s, a) mwarning(s, a)
87
#define warning2(s, a, b) mwarning(s, a, b)
88
#define warning3(s, a, b, c) mwarning(s, a, b, c)
89
#define warning4(s, a, b, c, d) mwarning(s, a, b, c, d)
90
#define warning5(s, a, b, c, d, e) mwarning(s, a, b, c, d, e)
91
#define warning6(s, a, b, c, d, e, f) mwarning(s, a, b, c, d, e, f)
92
#define warning7(s, a, b, c, d, e, f, g) mwarning(s, a, b, c, d, e, f, g)
93
#define warning8(s, a, b, c, d, e, f, g, h) mwarning(s, a, b, c, d, e, f, g, h)
94
#define warning9(s, a, b, c, d, e, f, g, h, i) mwarning(s, a, b, c, d, e, f, g, h, i)
95
#define warning10(s, a, b, c, d, e, f, g, h, i, j) mwarning(s, a, b, c, d, e, f, g, h, i, j)
96
#define warning11(s, a, b, c, d, e, f, g, h, i, j, k) mwarning(s, a, b, c, d, e, f, g, h, i, j, k)
97
#define warning12(s, a, b, c, d, e, f, g, h, i, j, k, l) mwarning(s, a, b, c, d, e, f, g, h, i, j, k, l)
98
#define warning13(s, a, b, c, d, e, f, g, h, i, j, k, l, m) mwarning(s, a, b, c, d, e, f, g, h, i, j, k, l, m)
99
#define warning14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) mwarning(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
100
#define warning15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) mwarning(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
101
102
#define error1(s, a) merror(s, a)
103
#define error2(s, a, b) merror(s, a, b)
104
#define error3(s, a, b, c) merror(s, a, b, c)
105
#define error4(s, a, b, c, d) merror(s, a, b, c, d)
106
#define error5(s, a, b, c, d, e) merror(s, a, b, c, d, e)
107
#define error6(s, a, b, c, d, e, f) merror(s, a, b, c, d, e, f)
108
#define error7(s, a, b, c, d, e, f, g) merror(s, a, b, c, d, e, f, g)
109
#define error8(s, a, b, c, d, e, f, g, h) merror(s, a, b, c, d, e, f, g, h)
110
#define error9(s, a, b, c, d, e, f, g, h, i) merror(s, a, b, c, d, e, f, g, h, i)
111
#define error10(s, a, b, c, d, e, f, g, h, i, j) merror(s, a, b, c, d, e, f, g, h, i, j)
112
#define error11(s, a, b, c, d, e, f, g, h, i, j, k) merror(s, a, b, c, d, e, f, g, h, i, j, k)
113
#define error12(s, a, b, c, d, e, f, g, h, i, j, k, l) merror(s, a, b, c, d, e, f, g, h, i, j, k, l)
114
#define error13(s, a, b, c, d, e, f, g, h, i, j, k, l, m) merror(s, a, b, c, d, e, f, g, h, i, j, k, l, m)
115
#define error14(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) merror(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
116
#define error15(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) merror(s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
117
118
#define ereturn1(rv, s, a) mereturn(rv, s, a)
119
#define ereturn2(rv, s, a, b) mereturn(rv, s, a, b)
120
#define ereturn3(rv, s, a, b, c) mereturn(rv, s, a, b, c)
121
#define ereturn4(rv, s, a, b, c, d) mereturn(rv, s, a, b, c, d)
122
#define ereturn5(rv, s, a, b, c, d, e) mereturn(rv, s, a, b, c, d, e)
123
#define ereturn6(rv, s, a, b, c, d, e, f) mereturn(rv, s, a, b, c, d, e, f)
124
#define ereturn7(rv, s, a, b, c, d, e, f, g) mereturn(rv, s, a, b, c, d, e, f, g)
125
#define ereturn8(rv, s, a, b, c, d, e, f, g, h) mereturn(rv, s, a, b, c, d, e, f, g, h)
126
#define ereturn9(rv, s, a, b, c, d, e, f, g, h, i) mereturn(rv, s, a, b, c, d, e, f, g, h, i)
127
#define ereturn10(rv, s, a, b, c, d, e, f, g, h, i, j) mereturn(rv, s, a, b, c, d, e, f, g, h, i, j)
128
#define ereturn11(rv, s, a, b, c, d, e, f, g, h, i, j, k) mereturn(rv, s, a, b, c, d, e, f, g, h, i, j, k)
129
#define ereturn12(rv, s, a, b, c, d, e, f, g, h, i, j, k, l) mereturn(rv, s, a, b, c, d, e, f, g, h, i, j, k, l)
130
#define ereturn13(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m) mereturn(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m)
131
#define ereturn14(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m, n) mereturn(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
132
#define ereturn15(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) mereturn(rv, s, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
133
134