Skip to content

Commit

Permalink
added set_thread_flags + EXC_KILL
Browse files Browse the repository at this point in the history
  • Loading branch information
ncannasse committed Sep 29, 2023
1 parent a053b3a commit a2fa213
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
1 change: 1 addition & 0 deletions src/hl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/std/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a2fa213

Please sign in to comment.