Go to the documentation of this file.
30 #include <sys/types.h>
35 #if defined(__linux__) || defined(__sun) || defined(__APPLE__)
36 typedef unsigned char uchar;
42 #define ICEWING_NAME_D "iceWing"
45 #define IW_TIME_MESSURE
54 #define __FUNCTION__ __FILE__
70 #if !defined(PATH_MAX) && defined(_POSIX_PATH_MAX)
71 #define PATH_MAX _POSIX_PATH_MAX
78 #define IW_TIME_DIFF(t1,t2) (((t1).tv_sec-(t2).tv_sec) * 1000 \
79 + ((t1).tv_usec - (t2).tv_usec) / 1000)
82 #define MIN(a, b) ((a) < (b) ? (a) : (b))
85 #define MAX(a, b) ((a) > (b) ? (a) : (b))
88 #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
91 #define G_PI 3.14159265358979323846
94 #define G_PI_2 1.57079632679489661923
97 #define G_PI_4 0.78539816339744830962
99 #ifndef G_GINT64_FORMAT
100 #define G_GINT64_FORMAT "li"
101 #define GINT64_PRINTTYPE long
103 #define GINT64_PRINTTYPE gint64
107 #define IW_ARG_NO_NUMBER ((void*)G_MININT)
113 #define iw_error_1(a1) iw_error_x (__FUNCTION__,__LINE__,a1)
114 #define iw_error_2(a1,a2) iw_error_x (__FUNCTION__,__LINE__,a1,a2)
115 #define iw_error_3(a1,a2,a3) iw_error_x (__FUNCTION__,__LINE__,a1,a2,a3)
116 #define iw_error_4(a1,a2,a3,a4) iw_error_x (__FUNCTION__,__LINE__,a1,a2,a3,a4)
117 #define iw_error_5(a1,a2,a3,a4,a5) iw_error_x (__FUNCTION__,__LINE__,a1,a2,a3,a4,a5)
118 #define iw_error_6(a1,a2,a3,a4,a5,a6) iw_error_x (__FUNCTION__,__LINE__,a1,a2,a3,a4,a5,a6)
119 #define iw_warning_1(a1) iw_warning_x (__FUNCTION__,__LINE__,a1)
120 #define iw_warning_2(a1,a2) iw_warning_x (__FUNCTION__,__LINE__,a1,a2)
121 #define iw_warning_3(a1,a2,a3) iw_warning_x (__FUNCTION__,__LINE__,a1,a2,a3)
122 #define iw_warning_4(a1,a2,a3,a4) iw_warning_x (__FUNCTION__,__LINE__,a1,a2,a3,a4)
123 #define iw_warning_5(a1,a2,a3,a4,a5) iw_warning_x (__FUNCTION__,__LINE__,a1,a2,a3,a4,a5)
124 #define iw_warning_6(a1,a2,a3,a4,a5,a6) iw_warning_x (__FUNCTION__,__LINE__,a1,a2,a3,a4,a5,a6)
126 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
127 # define iw_error(...) iw_error_x (__FUNCTION__,__LINE__,__VA_ARGS__)
128 # define iw_warning(...) iw_warning_x (__FUNCTION__,__LINE__,__VA_ARGS__)
129 # define iw_error_errno(...) iw_error_errno_x (__FUNCTION__,__LINE__,__VA_ARGS__)
130 # define iw_warning_errno(...) iw_warning_errno_x (__FUNCTION__,__LINE__,__VA_ARGS__)
131 #elif defined(__GNUC__)
132 # define iw_error(format...) iw_error_x (__FUNCTION__,__LINE__,format)
133 # define iw_warning(format...) iw_warning_x (__FUNCTION__,__LINE__,format)
134 # define iw_error_errno(format...) iw_error_errno_x (__FUNCTION__,__LINE__,format)
135 # define iw_warning_errno(format...) iw_warning_errno_x (__FUNCTION__,__LINE__,format)
137 void iw_error (
const char* str, ...);
145 # define iw_debug_1(t,a1) iw_debug_x (t,__FUNCTION__,__LINE__,a1)
146 # define iw_debug_2(t,a1,a2) iw_debug_x (t,__FUNCTION__,__LINE__,a1,a2)
147 # define iw_debug_3(t,a1,a2,a3) iw_debug_x (t,__FUNCTION__,__LINE__,a1,a2,a3)
148 # define iw_debug_4(t,a1,a2,a3,a4) iw_debug_x (t,__FUNCTION__,__LINE__,a1,a2,a3,a4)
149 # define iw_debug_5(t,a1,a2,a3,a4,a5) iw_debug_x (t,__FUNCTION__,__LINE__,a1,a2,a3,a4,a5)
150 # define iw_debug_6(t,a1,a2,a3,a4,a5,a6) iw_debug_x (t,__FUNCTION__,__LINE__,a1,a2,a3,a4,a5,a6)
151 # define iw_debug_7(t,a1,a2,a3,a4,a5,a6,a7) \
152 iw_debug_x (t,__FUNCTION__,__LINE__,a1,a2,a3,a4,a5,a6,a7)
153 # define iw_debug_8(t,a1,a2,a3,a4,a5,a6,a7,a8) \
154 iw_debug_x (t,__FUNCTION__,__LINE__,a1,a2,a3,a4,a5,a6,a7,a8)
155 # define iw_debug_9(t,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
156 iw_debug_x (t,__FUNCTION__,__LINE__,a1,a2,a3,a4,a5,a6,a7,a8,a9)
157 # define iw_debug_10(t,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
158 iw_debug_x (t,__FUNCTION__,__LINE__,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
159 # define iw_assert_1(ex,a1) ((ex) ? (void)0 : iw_error_1(a1))
160 # define iw_assert_2(ex,a1,a2) ((ex) ? (void)0 : iw_error_2(a1,a2))
161 # define iw_assert_3(ex,a1,a2,a3) ((ex) ? (void)0 : iw_error_3(a1,a2,a3))
162 # define iw_assert_4(ex,a1,a2,a3,a4) ((ex) ? (void)0 : iw_error_4(a1,a2,a3,a4))
163 # define iw_assert_5(ex,a1,a2,a3,a4,a5) ((ex) ? (void)0 : iw_error_5(a1,a2,a3,a4,a5))
165 # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
166 # define iw_debug(t,...) iw_debug_x (t,__FUNCTION__,__LINE__,__VA_ARGS__)
167 # define iw_assert(ex,...) ((ex) ? (void)0 : iw_error(__VA_ARGS__))
168 # elif defined(__GNUC__)
169 # define iw_debug(t,format...) iw_debug_x (t,__FUNCTION__,__LINE__,format)
170 # define iw_assert(ex,format...) ((ex) ? (void)0 : iw_error(format))
172 void iw_debug (
int level,
const char* str, ...);
173 void iw_assert (
long expression,
const char* str, ...);
178 # define iw_debug_1(t,a1)
179 # define iw_debug_2(t,a1,a2)
180 # define iw_debug_3(t,a1,a2,a3)
181 # define iw_debug_4(t,a1,a2,a3,a4)
182 # define iw_debug_5(t,a1,a2,a3,a4,a5)
183 # define iw_debug_6(t,a1,a2,a3,a4,a5,a6)
184 # define iw_debug_7(t,a1,a2,a3,a4,a5,a6,a7)
185 # define iw_debug_8(t,a1,a2,a3,a4,a5,a6,a7,a8)
186 # define iw_debug_9(t,a1,a2,a3,a4,a5,a6,a7,a8,a9)
187 # define iw_debug_10(t,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
188 # define iw_assert_1(ex,a1)
189 # define iw_assert_2(ex,a1,a2)
190 # define iw_assert_3(ex,a1,a2,a3)
191 # define iw_assert_4(ex,a1,a2,a3,a4)
192 # define iw_assert_5(ex,a1,a2,a3,a4,a5)
194 # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
195 # define iw_debug(t,...)
196 # define iw_assert(ex,...)
197 # elif defined(__GNUC__)
198 # define iw_debug(t,format...)
199 # define iw_assert(ex,format...)
201 static inline void iw_debug (
int level,
const char* str, ...) {}
202 static inline void iw_assert (
long expression,
const char* str, ...) {}
212 void*
iw_malloc (
size_t size,
const char *err);
213 void*
iw_malloc0 (
size_t size,
const char *err);
214 void*
iw_realloc (
void *ptr,
size_t size,
const char *err);
246 char iw_parse_args (
int argc,
char **argv,
int *nr,
void **arg,
247 const char *pattern);
255 BOOL iw_load_args (
char *args,
int argc,
char **argv,
int *nargc,
char ***nargv);
268 #ifdef IW_TIME_MESSURE
269 #define iw_time_add_static(number,name) \
270 static int number = -1; \
271 if (number<0) number = iw_time_add (name);
273 #define iw_time_add_static2(number,name,number2,name2) \
274 static int number = -1, number2 = -1; \
276 number = iw_time_add (name); \
277 number2 = iw_time_add (name2); \
280 #define iw_time_add_static3(number,name,number2,name2,number3,name3) \
281 static int number = -1, number2 = -1, number3 = -1; \
283 number = iw_time_add (name); \
284 number2 = iw_time_add (name2); \
285 number3 = iw_time_add (name3); \
328 # define iw_time_add_static(number,name)
329 # define iw_time_add_static2(number,name,number2,name2)
330 # define iw_time_add_static3(number,name,number2,name2,number3,name3)
331 # define iw_time_add(name) ((void)0)
332 # define iw_time_set_enabled(enabled)
333 # define iw_time_init_all()
334 # define iw_time_init()
335 # define iw_time_start(nr)
336 # define iw_time_stop(nr,show) ((void)0)
337 # define iw_time_show()
344 void iw_error_x (
const char *proc,
int line,
const char* str, ...)
350 void iw_warning_x (const
char *proc,
int line, const
char* str, ...)
377 int iw_debug_get_level (
void);
383 void iw_debug_x (
int level,
const char *proc,
int line,
const char* str, ...)