bump to -rc12
[gnucap-felix.git] / include / io_trace.h
blob5ec55a9c09d9c20c25cb759291eaba26f9107643
1 /*$Id: io_trace.h 2016.08.11 $ -*- C++ -*-
2 * Copyright (C) 2001 Albert Davis,
3 * 2015,16 Felix Salfelder
4 * Author: Albert Davis <aldavis@gnu.org>, Felix Salfelder
6 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3, or (at your option)
11 * any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 *------------------------------------------------------------------
23 * trace macros for model debugging
25 //testing=trivial 2006.07.17
26 #include <iostream>
28 /* allow multiple inclusions with different DO_TRACE */
29 #undef trace_line
30 #undef trace
31 #undef trace0
32 #undef trace1
33 #undef trace2
34 #undef trace3
35 #undef trace4
36 #undef trace5
37 #undef trace6
38 #undef trace7
39 #undef trace8
40 #undef untested
41 #undef itested
42 #undef unreachable
43 #undef incomplete
44 /*--------------------------------------------------------------------------*/
46 #ifndef hashpointer_
47 # define hashpointer_
48 #include <stdint.h> // intptr_t
50 class hp{
51 intptr_t p;
52 public:
53 hp(const void* x){
54 p = (intptr_t)x %30011;
56 operator int(){
57 return static_cast<int>(p);
61 #endif
62 /*--------------------------------------------------------------------------*/
63 #ifdef DO_TRACE
65 #ifdef __cplusplus
67 #define trace_line() (std::cerr << "@@#\n@#@:" \
68 << __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n" )
69 #define trace0(s) ( std::cerr << "@#@" << (s) << "\n")
70 #define trace1(s,x) ( \
71 std::cerr << "@#@" << (s) << " " << #x << "=" << (x) \
72 << "\n" )
73 #define trace2(s,x,y) ( \
74 std::cerr << "@#@" << (s) << " " << #x << "=" << (x) \
75 << " " << #y << "=" << (y) \
76 << "\n" )
77 #define trace3(s,x,y,z) ( \
78 std::cerr << "@#@" << (s) << " " << #x << "=" << (x) \
79 << " " << #y << "=" << (y) \
80 << " " << #z << "=" << (z) \
81 << "\n" )
82 #define trace4(s,w,x,y,z) ( \
83 std::cerr << "@#@" << (s) << " " << #w << "=" << (w) \
84 << " " << #x << "=" << (x) \
85 << " " << #y << "=" << (y) \
86 << " " << #z << "=" << (z) \
87 << "\n" )
88 #define trace5(s,v,w,x,y,z) ( \
89 std::cerr << "@#@" << (s) << " " << #v << "=" << (v) \
90 << " " << #w << "=" << (w) \
91 << " " << #x << "=" << (x) \
92 << " " << #y << "=" << (y) \
93 << " " << #z << "=" << (z) \
94 << "\n" )
95 #define trace6(s,u,v,w,x,y,z) ( \
96 std::cerr << "@#@" << (s) \
97 << " " << #u << "=" << (u) \
98 << " " << #v << "=" << (v) \
99 << " " << #w << "=" << (w) \
100 << " " << #x << "=" << (x) \
101 << " " << #y << "=" << (y) \
102 << " " << #z << "=" << (z) \
103 << "\n" )
104 #define trace7(s,t,u,v,w,x,y,z) ( \
105 std::cerr << "@#@" << (s) \
106 << " " << #t << "=" << (t) \
107 << " " << #u << "=" << (u) \
108 << " " << #v << "=" << (v) \
109 << " " << #w << "=" << (w) \
110 << " " << #x << "=" << (x) \
111 << " " << #y << "=" << (y) \
112 << " " << #z << "=" << (z) \
113 << "\n" )
114 #define trace8(s,r,t,u,v,w,x,y,z) ( \
115 std::cerr << "@#@" << (s) \
116 << " " << #r << "=" << (r) \
117 << " " << #t << "=" << (t) \
118 << " " << #u << "=" << (u) \
119 << " " << #v << "=" << (v) \
120 << " " << #w << "=" << (w) \
121 << " " << #x << "=" << (x) \
122 << " " << #y << "=" << (y) \
123 << " " << #z << "=" << (z) \
124 << "\n" )
126 #else // no __cplusplus
128 #define trace_line() (printf("@@#\n@#@:%s:%u:%s\n", \
129 __FILE__, __LINE__, __func__))
130 #define trace0(s) (printf("@#@%s\n", s))
131 #define trace1(s,x) (printf("@#@%s %s=%g\n", s, #x, (double)(x)))
132 #define trace2(s,x,y) (printf("@#@%s %s=%g %s=%g\n",\
133 s, #x, (double)(x), #y, (double)(y)))
134 #define trace3(s,x,y,z) (printf("@#@%s %s=%g %s=%g %s=%g\n",\
135 s, #x, (double)(x), #y, (double)(y), #z, (double)(z)))
136 #define trace4(s,w,x,y,z)(printf("@#@%s %s=%g %s=%g %s=%g %s=%g\n",\
137 s, #w, (double)(w), #x, (double)(x), #y, (double)(y), #z, (double)(z)))
138 #define trace5(s,v,w,x,y,z)\
139 (printf("@#@%s %s=%g %s=%g %s=%g %s=%g %s=%g\n",\
140 s, #v, (double)(v), #w, (double)(w), #x, (double)(x),\
141 #y, (double)(y), #z, (double)(z)))
143 #endif // __cplusplus
145 #define USE(x) (void)x
146 #else
147 #define USE(x) (1)?(void)(0):(void)(x)
148 #define trace_line()
149 #define trace0(s) USE(s)
150 #define trace1(s,x) (USE(s),USE(x))
151 #define trace2(s,x,y) USE(s);USE(x);USE(y)
152 #define trace3(s,x,y,z) USE(s);USE(x);USE(y);USE(z)
153 #define trace4(s,w,x,y,z) USE(s);USE(w);USE(x);USE(y);USE(z)
154 #define trace5(s,v,w,x,y,z) USE(s);USE(v);USE(w);USE(x);USE(y);USE(z)
155 #define trace6(s,u,v,w,x,y,z) USE(s);USE(u);USE(v);USE(w);USE(x);USE(y);USE(z)
156 #define trace7(s,t,u,v,w,x,y,z) USE(s);USE(t);USE(u);USE(v);USE(w);USE(x);USE(y);USE(z)
157 #define trace8(r,s,t,u,v,w,x,y,z) USE(r);USE(s);USE(t);USE(u);USE(v);USE(w);USE(x);USE(y);USE(z)
158 #endif
160 #ifdef __cplusplus
162 #define unreachable() ( \
163 std::cerr << "@@#\n@@@\nunreachable:" \
164 << __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n" )
166 #define incomplete() ( \
167 std::cerr << "@@#\n@@@\nincomplete:" \
168 << __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n" )
170 #else // no __cplusplus
172 #define unreachable() (fprintf(stderr,"@@#\n@@@unreachable:%s:%u:%s\n", \
173 __FILE__, __LINE__, __func__))
175 #define incomplete() (fprintf(stderr,"@@#\n@@@incomplete:%s:%u:%s\n", \
176 __FILE__, __LINE__, __func__))
178 #endif // __cplusplus
180 #ifdef TRACE_UNTESTED
182 #ifdef __cplusplus
184 #define untested() ( std::cerr << "@@#\n@@@:"<< __FILE__ << ":"<< __LINE__ \
185 <<":" << __func__ << "\n" )
186 #define untested1(s,x) ( std::cerr << "@@#\n@@@:"<< __FILE__ << ":"<< __LINE__ \
187 <<":" << __func__ << ": " << s << " " << #x << "=" << (x) << "\n" )
188 #define untested2(s,x,y) ( std::cerr << "@@#\n@@@:"<< __FILE__ << ":"<< __LINE__ \
189 <<":" << __func__ << ": " << s << " " << #x << "=" << (x) << ", "\
190 << #y << "=" << (y) << "\n" )
191 #define untested3(s,x,y,z) ( std::cerr << "@@#\n@@@:"<< __FILE__ << ":"<< __LINE__ \
192 <<":" << __func__ << ": " << s << " " << #x << "=" << (x) << ", "\
193 << #y << "=" << (y) << ", " \
194 << #z << "=" << (z) << "\n" )
196 #else // no __cplusplus
198 #define untested() (fprintf(stderr,"@@#\n@@@:%s:%u:%s\n", \
199 __FILE__, __LINE__, __func__))
201 #endif // __cplusplus
203 #else
204 #define untested()
205 #define untested1(s,x)
206 #define untested2(s,x,y)
207 #define untested3(s,x,y,z)
208 #endif
210 #ifdef TRACE_ITESTED
212 #ifdef __cplusplus
214 #define itested() ( std::cerr << "@@#\n@@@:" \
215 << __FILE__ << ":" << __LINE__ << ":" << __func__ << "\n" )
217 #else // no __cplusplus
219 #define itested() (fprintf(stderr,"@@#\n@@@:%s:%u:%s\n", \
220 __FILE__, __LINE__, __func__))
221 #endif // __cplusplus
223 #else
224 #define itested()
225 #endif
228 /*--------------------------------------------------------------------------*/
229 /*--------------------------------------------------------------------------*/
230 /*--------------------------------------------------------------------------*/
231 // vim:ts=8:sw=2:noet: