124 return "overflow_error exception";
126 return "simplex_arithmetic_error exception";
128 return "user_exception_error exception";
130 return "parser_exception_error exception";
132 return "timeout_error exception";
134 return "all exceptions mask";
136 return "unknown or mixed exception";
166#define MAX_STACKED_CONTEXTS 64
172#ifdef THREAD_SAFE_POLYLIB
176static pthread_once_t once_control = PTHREAD_ONCE_INIT;
177static pthread_key_t mt_key;
179#define exception_index (exception_stack[MAX_STACKED_CONTEXTS].what)
189static void free_local_stack(
void *es) {
191 assert(pthread_setspecific(mt_key, NULL) == 0);
193static void init_multithreaded_stacks(
void) {
194 pthread_key_create(&mt_key, free_local_stack);
208#ifdef THREAD_SAFE_POLYLIB
209 assert(pthread_once(&once_control, init_multithreaded_stacks) == 0);
225 fprintf(stderr,
"exception callbacks already defined! (%p, %p)\n",
242#ifdef THREAD_SAFE_POLYLIB
248 fprintf(f,
"[dump_exception_stack_to_file] size=%d\n",
exception_index);
259#define exception_debug_message(type) \
260 fprintf(stderr, "%s[%s:%d %s (%s)/%d]\n", type, file, line, function, \
261 get_exception_name(what), exception_index)
263#define exception_debug_trace(type) \
264 if (linear_exception_debug_mode) { \
265 exception_debug_message(type); \
271 const char *file,
int line) {
272#ifdef THREAD_SAFE_POLYLIB
273 assert(pthread_once(&once_control, init_multithreaded_stacks) == 0);
283 fprintf(stderr,
"exception stack overflow\n");
301#if !defined(same_string_p)
302#define same_string_p(s1, s2) (strcmp((s1), (s2)) == 0)
310#ifdef THREAD_SAFE_POLYLIB
311 assert(pthread_once(&once_control, init_multithreaded_stacks) == 0);
321 fprintf(stderr,
"exception stack underflow\n");
337 "exception stack mismatch at depth=%d:\n"
338 " CATCH: %s:%d in %s (%d)\n"
339 " UNCATCH: %s:%d in %s (%d)\n",
355#ifdef THREAD_SAFE_POLYLIB
356 assert(pthread_once(&once_control, init_multithreaded_stacks) == 0);
383 fprintf(stderr,
"exception %d/%d: %s(%s:%d) -> %s(%s:%d)\n", what,
394 fprintf(stderr,
"exception not found in stack:\n"
395 "an exception was THROWN without a proper matching CATCH\n");
void(* exception_callback_t)(const char *, const char *, int)
static int linear_exception_debug_mode
void linear_initialize_exception_stack(unsigned int verbose_exceptions, exception_callback_t push, exception_callback_t pop)
void dump_exception_stack()
unsigned int user_exception_error
void throw_exception(int what, const char *function, const char *file, int line)
int linear_number_of_exception_thrown
unsigned int parser_exception_error
unsigned int simplex_arithmetic_error
unsigned int timeout_error
static unsigned int linear_exception_verbose
unsigned int any_exception_error
void dump_exception_stack_to_file(FILE *f)
static exception_callback_t pop_callback
void free_exception_stack()
#define exception_debug_trace(type)
#define exception_debug_message(type)
void set_exception_callbacks(exception_callback_t push, exception_callback_t pop)
static exception_callback_t push_callback
unsigned int the_last_just_thrown_exception
const char * get_exception_name(unsigned int exception)
#define MAX_STACKED_CONTEXTS
#define same_string_p(s1, s2)
static int exception_index
static linear_exception_holder exception_stack[MAX_STACKED_CONTEXTS]
Vincent's patch to enable POSIX multithreading.
void pop_exception_from_stack(int what, const char *function, const char *file, int line)
unsigned int overflow_error
jmp_buf * push_exception_on_stack(int what, const char *function, const char *file, int line)