mirror of
https://github.com/sigmasternchen/crap-libs
synced 2025-03-15 07:38:56 +00:00
pthread id support + fix
This commit is contained in:
parent
b5958cb270
commit
b882450ac0
1 changed files with 16 additions and 3 deletions
19
try/try.c
19
try/try.c
|
@ -61,6 +61,8 @@ try_t try_pop(void) {
|
|||
}
|
||||
|
||||
void try_push(try_t id) {
|
||||
if (id == NO_TRY_BODY)
|
||||
return;
|
||||
stack[++stack_position] = id;
|
||||
}
|
||||
|
||||
|
@ -93,9 +95,20 @@ void print_backtrace(FILE* file) {
|
|||
void try_throw(try_t id, void* exception) {
|
||||
if (id == NO_TRY_BODY) {
|
||||
exception_t* e = exception;
|
||||
fprintf(stderr, "\nUncaught exception '%s_t' (\"%s\")\n",
|
||||
oop_get_class_name(oop_get_class_from_obj((void*) e)),
|
||||
e->msg);
|
||||
|
||||
#ifdef PTHREAD_SCOPE_SYSTEM
|
||||
// we are in a pthread environment
|
||||
pthread_id_np_t tid;
|
||||
tid = pthread_getthreadid_np();
|
||||
fprintf(stderr, "\nUncaught error %s_t in thread %i\n: %s\n",
|
||||
oop_get_class_name(oop_get_class_from_obj((void*) e)),
|
||||
tid, e->msg);
|
||||
#else
|
||||
fprintf(stderr, "\nUncaught error %s_t: %s\n",
|
||||
oop_get_class_name(oop_get_class_from_obj((void*) e)),
|
||||
e->msg);
|
||||
#endif
|
||||
|
||||
print_backtrace(stderr);
|
||||
} else {
|
||||
trys[id].exception = exception;
|
||||
|
|
Loading…
Reference in a new issue