Skip to content

Commit

Permalink
Linux build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ned14 committed Feb 14, 2025
1 parent 066789b commit 3bc58f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/wg14_signals/thrd_signal_handle_common.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static inline signo_to_sighandler_map_t_itr
signo_to_sighandler_map_t_get(signo_to_sighandler_map_t *map, int idx)
{
signo_to_sighandler_map_t_itr ret;
memset(&ret, 0, sizeof(ret));
if(idx < 0 || idx >= NSIG || map->arr[idx] == WG14_SIGNALS_NULLPTR)
{
ret.data = WG14_SIGNALS_NULLPTR;
Expand All @@ -72,6 +73,7 @@ signo_to_sighandler_map_t_insert(signo_to_sighandler_map_t *map, int idx,
struct sighandler_t *val)
{
signo_to_sighandler_map_t_itr ret;
memset(&ret, 0, sizeof(ret));
if(idx < 0 || idx >= NSIG)
{
ret.data = WG14_SIGNALS_NULLPTR;
Expand Down
17 changes: 9 additions & 8 deletions src/wg14_signals/thrd_signal_handle_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,14 @@ bool WG14_SIGNALS_PREFIX(thrd_signal_raise)(int signo, void *raw_info,
}
struct thrd_signal_global_state_tss_state_t *tss =
thrd_signal_global_tss_state();
jmp_buf old_buf;
memcpy(old_buf, tss->buf, sizeof(old_buf));
tss->buf_count++;
if(setjmp(tss->buf) != 0)
struct thrd_signal_global_state_tss_state_per_frame_t *old = tss->front,
current;
memset(&current, 0, sizeof(current));
current.prev = old;
tss->front = &current;
if(setjmp(current.buf) != 0)
{
memcpy(tss->buf, old_buf, sizeof(old_buf));
tss->buf_count--;
tss->front = old;
return true;
}

Expand Down Expand Up @@ -220,9 +221,9 @@ EXCEPTION_POINTERS *ptrs)
struct thrd_signal_global_state_tss_state_t *tss =
thrd_signal_global_tss_state();
// If there is a most recent thread local handler, resume there instead
if(tss->buf_count > 0)
if(tss->front != WG14_SIGNALS_NULLPTR)
{
longjmp(tss->buf, 1);
longjmp(tss->front.buf, 1);
}
// This will generally end the process
return EXCEPTION_CONTINUE_EXECUTION;
Expand Down

0 comments on commit 3bc58f9

Please sign in to comment.