51 return "overflow_error exception";
53 return "simplex_arithmetic_error exception";
55 return "user_exception_error exception";
57 return "parser_exception_error exception";
59 return "timeout_error exception";
61 return "all exceptions mask";
63 return "unknown or mixed exception";
95 unsigned int *poe,
unsigned int * pse,
unsigned int *pme)
135 char const *
function;
148 #define MAX_STACKED_CONTEXTS 64
165 fprintf(stderr,
"exception callbacks already defined! (%p, %p)\n",
190 "%d: [%s:%d in %s (%d)]\n",
207 #define exception_debug_message(type) \
208 fprintf(stderr, "%s[%s:%d %s (%d)/%d]\n", \
209 type, file, line, function, what, exception_index)
211 #define exception_debug_trace(type) \
212 if (linear_exception_debug_mode) \
213 exception_debug_message(type);
215 #ifdef push_exception_on_stack
216 #undef push_exception_on_stack
225 const char *
function,
234 fprintf(stderr,
"exception stack overflow\n");
256 const char *
function,
264 #if !defined(same_string_p)
265 #define same_string_p(s1, s2) (strcmp((s1),(s2))==0)
268 #ifdef pop_exception_from_stack
269 #undef pop_exception_from_stack
279 const char *
function,
288 fprintf(stderr,
"exception stack underflow\n");
305 "exception stack mismatch at depth=%d:\n"
306 " CATCH: %s:%d in %s (%d)\n"
307 " UNCATCH: %s:%d in %s (%d)\n",
313 file,
line,
function, what);
322 const char *
function,
329 #ifdef throw_exception
330 #undef throw_exception
341 const char *
function,
366 fprintf(stderr,
"---->[%s:%d %s (%d)/%d]\n",
375 fprintf(stderr,
"exception %d/%d: %s(%s:%d) -> %s(%s:%d)\n",
377 function, file,
line,
393 "exception not found in stack:\n"
394 "an exception was THROWN without a matching CATCH\n");
407 const char *
function,
415 #define throw_exception linear_throw_exception
420 unsigned int verbose_exceptions,
448 char*
env = getenv(
"LINEAR_USE_GMP");
449 return env && atoi(
env) != 0;
462 fprintf(stderr,
"linear was compiled without GMP support\n");
466 return with_gmp && req_gmp;
507 #define TIMEOUT_MAX_STACK_SIZE 10
520 fprintf(stderr,
"timeout[%d] after %ds from %s (\"%s\":%d)\n", toidx,
540 const unsigned int delay,
541 const char * funcname,
542 const char * filename,
545 time_t now = time(NULL);
559 signal(SIGALRM, timeout_handler);
565 char * val = getenv(
env);
577 const char * funcname,
578 const char * filename,
596 time_t now = time(NULL);
602 signal(SIGALRM, SIG_DFL);
612 timeout_handler(SIGALRM);
614 signal(SIGALRM, timeout_handler);
621 const char * funcname,
622 const char * filename,
static void push(list l)
it is pushed in reverse order to preserve the depth first view.
linear_exception_t
Global constants to designate exceptions.
@ simplex_arithmetic_error
@ any_exception_error
catch all
void(* exception_callback_t)(char const *, char const *, int const)
void(* timeout_callback_f)(int, const char *, const char *, int)
callback for timeout expecting: delay, function, file, lineno
linear_exception_t the_last_just_thrown_exception
void set_exception_callbacks(exception_callback_t, exception_callback_t)
int linear_number_of_exception_thrown
void linear_initialize_exception_stack(unsigned int, exception_callback_t, exception_callback_t)
jmp_buf * linear_push_exception_on_stack(const int, const char *, const char *, const int)
jmp_buf * push_exception_on_stack(const int, const char *, const char *, const int)
void dump_exception_stack(void)
void pop_exception_from_stack(const int, const char *, const char *, const int)
void dump_exception_stack_to_file(FILE *)
void linear_throw_exception(const int, const char *, const char *, const int)
char const * get_exception_name(const linear_exception_t)
void linear_pop_exception_from_stack(const int, const char *, const char *, const int)
static pipsmake_callback_handler_type callback
void linear_get_error_counts(unsigned int *poe, unsigned int *pse, unsigned int *pme)
return various errors counts through unsigned int pointer overflow, simplex & misc (aka others) NULL ...
static unsigned int misc_error_count
void linear_reset_error_counters(void)
reset linear counters
static timeout_t timeouts[TIMEOUT_MAX_STACK_SIZE]
static unsigned int simplex_error_count
static bool linear_exception_debug_mode
whether to run in debug mode (that is to trace catch/uncatch/throw)
bool linear_require_gmp(void)
whether linear is asked to use gmp if possible (env variable)
void pop_timeout_env(const char *env, const char *funcname, const char *filename, const int lineno)
static unsigned int linear_exception_verbose
static unsigned int overflow_error_count
static exception_callback_t pop_callback
static void linear_record_exception(const linear_exception_t exception)
#define exception_debug_trace(type)
bool push_timeout_env(const char *env, const char *funcname, const char *filename, const int lineno)
static bool warned_if_inconsistent_gmp
char const * __attribute__((weak))
This can be overrided in the PolyLib.
int linear_assertion_result
errors.c
#define exception_debug_message(type)
bool linear_use_gmp(void)
whether linear is to use gmp
static exception_callback_t push_callback
callbacks...
void push_timeout(const unsigned int delay, const char *funcname, const char *filename, const int lineno)
#define MAX_STACKED_CONTEXTS
exception stack.
static timeout_callback_f timeout_callback
a stack of timeouts is kept.
#define same_string_p(s1, s2)
void set_timeout_callback(timeout_callback_f callback)
static int exception_index
#define TIMEOUT_MAX_STACK_SIZE
unsigned int linear_error_count(void)
return number of linear errors may be used as a test after a reset to know whether new errors occured...
void pop_timeout(__attribute__((unused)) const char *funcname, __attribute__((unused)) const char *filename, __attribute__((unused)) const int lineno)
static linear_exception_holder exception_stack[MAX_STACKED_CONTEXTS]
static int env2int(const char *env)
bool linear_with_gmp(void)
whether linear can use gmp (i.e.
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
static int line
FLEX_SCANNER.
A structure for the exception stack.
hold a timeout prescription