From a2fa213c272897e8ea3af1710403685b9d168ba9 Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Fri, 29 Sep 2023 12:56:28 +0200 Subject: [PATCH] added set_thread_flags + EXC_KILL --- src/gc.c | 6 ++++++ src/hl.h | 1 + src/std/error.c | 2 ++ 3 files changed, 9 insertions(+) diff --git a/src/gc.c b/src/gc.c index edfb3b992..ca97fe602 100644 --- a/src/gc.c +++ b/src/gc.c @@ -1288,6 +1288,11 @@ HL_API void hl_gc_set_flags( int f ) { gc_flags = f; } +HL_API void hl_set_thread_flags( int flags, int mask ) { + hl_thread_info *t = hl_get_thread(); + t->flags = (t->flags & ~mask) | flags; +} + HL_API void hl_gc_profile( bool b ) { if( b ) gc_flags |= GC_PROFILE; @@ -1419,3 +1424,4 @@ DEFINE_PRIM(_I32, gc_get_flags, _NO_ARG); DEFINE_PRIM(_VOID, gc_set_flags, _I32); DEFINE_PRIM(_DYN, debug_call, _I32 _DYN); DEFINE_PRIM(_VOID, blocking, _BOOL); +DEFINE_PRIM(_VOID, set_thread_flags, _I32 _I32); diff --git a/src/hl.h b/src/hl.h index 4da7243fe..18717add0 100644 --- a/src/hl.h +++ b/src/hl.h @@ -903,6 +903,7 @@ struct _hl_trap_ctx { #define HL_EXC_IS_THROW 4 #define HL_THREAD_INVISIBLE 16 #define HL_THREAD_PROFILER_PAUSED 32 +#define HL_EXC_KILL 64 #define HL_TREAD_TRACK_SHIFT 16 #define HL_TRACK_ALLOC 1 diff --git a/src/std/error.c b/src/std/error.c index 909f9d524..71d63be23 100644 --- a/src/std/error.c +++ b/src/std/error.c @@ -92,6 +92,8 @@ HL_PRIM void hl_throw( vdynamic *v ) { hl_thread_info *t = hl_get_thread(); hl_trap_ctx *trap = t->trap_current; bool call_handler = false; + if( t->flags & HL_EXC_KILL ) + hl_fatal("Exception Occured"); if( !(t->flags & HL_EXC_RETHROW) ) t->exc_stack_count = capture_stack_func(t->exc_stack_trace, HL_EXC_MAX_STACK); t->exc_value = v;