43 #define TIMEOUT_CODE (128+14)
46 #define STRINGIFY_SECOND_STAGE(symbol) #symbol
50 #define STRINGIFY(symbol) STRINGIFY_SECOND_STAGE(symbol)
53 #define abort() pips_stop(internal_error_log, -1, "abort() called")
54 #define exit(code) pips_stop(user_error_log, code, "exit(%d) called", code)
59 # if defined(CURRENT_FUNCTION)
60 # undef CURRENT_FUNCTION
63 #define pips_unknown_function "Unknown Function Name"
65 # if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
66 # define CURRENT_FUNCTION __func__
68 # if defined(__GNUC__)
69 # define CURRENT_FUNCTION __FUNCTION__
71 # define CURRENT_FUNCTION pips_unknown_function
88 #define pips_debug(level, format, args...) \
91 fprintf(stderr, "[%s] " format, CURRENT_FUNCTION, ##args); \
95 #define pips_user_warning(format, args...) \
96 pips_user_warning_func(CURRENT_FUNCTION, __FILE__, __LINE__, format, ##args)
98 #define pips_user_error(format, args...) \
99 pips_user_error_func(CURRENT_FUNCTION, __FILE__, __LINE__, format, ##args)
101 #define pips_user_irrecoverable_error(format, args...) \
102 pips_user_irrecoverable_error_func(CURRENT_FUNCTION, __FILE__, __LINE__, \
106 #define pips_internal_error(format, args...) \
107 pips_internal_error_func(CURRENT_FUNCTION, __FILE__ , __LINE__, \
110 #define pips_log(args...) \
111 pips_log_func(CURRENT_FUNCTION, __FILE__, __LINE__, ##args)
113 #define pips_stop(args...) \
114 pips_stop_func(CURRENT_FUNCTION, __FILE__, __LINE__, ##args)
116 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
118 #define pips_debug(level, ...) \
121 pips_debug_func(level, CURRENT_FUNCTION, __VA_ARGS__); \
124 #define pips_user_warning(...) \
125 pips_user_warning_func(CURRENT_FUNCTION, __FILE__, __LINE__, __VA_ARGS__)
127 #define pips_user_error(...) \
128 pips_user_error_func(CURRENT_FUNCTION, __FILE__, __LINE__, __VA_ARGS__)
130 #define pips_user_irrecoverable_error(...) \
131 pips_user_irrecoverable_error_func(CURRENT_FUNCTION, __FILE__, __LINE__, \
134 #define pips_internal_error(...) \
135 pips_internal_error_func(CURRENT_FUNCTION, __FILE__ , __LINE__, \
138 #define pips_log(...) \
139 pips_log_func(CURRENT_FUNCTION, __FILE__, __LINE__, __VA_ARGS__)
141 #define pips_stop(...) \
142 pips_log_func(CURRENT_FUNCTION, __FILE__, __LINE__, __VA_ARGS__)
145 #define pips_debug pips_debug_func2
146 #define pips_user_warning pips_user_warning_func2
147 #define pips_user_error pips_user_error_func2
148 #define pips_user_irrecoverable_error pips_user_irrecoverable_error_func2
149 #define pips_internal_error pips_internal_error_func2
150 #define pips_log pips_log_func2
151 #define pips_stop pips_stop_func2
154 #define pips_where(out) \
155 fprintf(out, "[%s] (%s:%d) ", CURRENT_FUNCTION, __FILE__, __LINE__)
157 #define debug_on(env) \
158 debug_on_function(env, CURRENT_FUNCTION, __FILE__, __LINE__)
160 #define debug_off() \
161 debug_off_function(CURRENT_FUNCTION, __FILE__, __LINE__)
166 #define pips_assert(what, predicate)
167 #define pips_user_assert(what, predicate)
168 #define ifdebug(l) if(0)
172 #define pips_assert(what, predicate) \
174 if (!(predicate)) { \
175 pips_internal_error("assertion failed\n\n '%s' not verified\n\n", \
181 #define pips_user_assert(what, predicate) \
183 if (!(predicate)) { \
184 pips_user_error("assertion failed\n\n '%s' not verified\n\n" \
185 "this is a USER ERROR, I guess\n", what); \
189 #define ifdebug(l) if (the_current_debug_level>=(l))
193 #define pips_exit(code, format, args...) \
194 pips_user_warning(format, ##args), exit(code)
198 #define same_string_p(s1, s2) function_same_string_p(s1,s2)
199 #define same_stringn_p(a,b,c) (!strncmp((a),(b),(c)))
203 #define MAXPATHLEN 1024
206 #define PIPS_CATCH(what) \
207 if (push_debug_status(), \
208 setjmp(*push_exception_on_stack(what, __CURRENT_FUNCTION_NAME__, \
209 __FILE__, __LINE__, pop_debug_status)))
212 #define SIGN_EQ(a,b) ((((a)>0 && (b)>0) || ((a)<0 && (b)<0)) ? true : false)
213 #define FORTRAN_DIV(n,d) (SIGN_EQ((n),(d)) ? ABS(n)/ABS(d) : -(ABS(n)/ABS(d)))
214 #define C_DIVISION(n,d) ((n)/(d))
215 #define FORTRAN_MOD(n,m) (SIGN_EQ((n),(m)) ? ABS(n)%ABS(m) : -(ABS(n)%ABS(m)))
216 #define C_MODULO(n,m) ((n)%(m))
225 #define asprintf safe_asprintf
226 #define vasprintf safe_vasprintf
228 #ifndef __has_attribute
229 #define __has_attribute(att) 0
232 #define _UNUSED_ __attribute__((unused))
233 #define _NORETURN_ __attribute__((noreturn))
235 #if __has_attribute(fallthrough)
236 #define _FALLTHROUGH_ __attribute__((fallthrough))
238 #define _FALLTHROUGH_
251 const char *,
const char *,
const int,
const char *, va_list *);
253 const char *,
const char *,
const int,
const char *, ...);
262 #define user_warning(fn, ...) \
263 pips_user_warning_func(fn, __FILE__, __LINE__, __VA_ARGS__)
265 #define user_error(fn, ...) \
266 pips_user_error_func(fn, __FILE__, __LINE__, __VA_ARGS__)
void _NORETURN_ pips_internal_error_func2(const char *,...)
void _NORETURN_ pips_user_irrecoverable_error_func2(const char *,...)
void(* reset_func_t)(void)
void _NORETURN_ pips_user_irrecoverable_error_alist(const char *, const char *, const int, const char *, va_list *)
measurement_type
Measurement type for mem_spy.c.
@ irrecoverable_error_log
void _NORETURN_ pips_internal_error_func(const char *, const char *, const int, const char *,...)
void _NORETURN_ pips_user_error_func(const char *, const char *, const int, const char *,...)
int the_current_debug_level
Debugging functions.
void _NORETURN_ pips_user_error_func2(const char *,...)
void _NORETURN_ pips_stop_func(const char *, const char *, const int, pips_log_t, int, const string,...)
expecititely declare "noreturn" functions...
void _NORETURN_ pips_stop_func2(pips_log_t, int, const string,...)
void _NORETURN_ pips_user_irrecoverable_error_func(const char *, const char *, const int, const char *,...)