int jmp_used_signals [LONGJMP_NSIG] = {[0 ... (LONGJMP_NSIG - 1)] = 0};
+
int fosa_long_jump_save_context
(fosa_long_jump_context_t * context)
{
context -> jmp_hasexecuted = false;
if (setjmp (context -> jmp_context) == LONGJMP_MAGIC) {
- context -> jmp_hasexecuted = true;
+#ifndef CONFIG_LONGJUMP_FREE_SIGNALS
pthread_sigmask (SIG_SETMASK, &(context -> jmp_sigmask), NULL);
+#endif
+ context -> jmp_hasexecuted = true;
}
return 0;
}
+
int fosa_long_jump_was_performed
(const fosa_long_jump_context_t * context, int * jumped)
{
return 0;
}
+
void jmp_handler (int signo, siginfo_t *info, void *context)
{
fosa_long_jump_context_t *jmp_info = (fosa_long_jump_context_t *) info -> si_value.sival_ptr;
+ sigset_t set;
+
+#ifdef CONFIG_LONGJUMP_FREE_SIGNALS
+ // Restore the signal mask beofre the context save
+ pthread_sigmask (SIG_SETMASK, &(context -> jmp_sigmask), NULL);
+
+ // Free this signal
+ sigemptyset (&set);
+ sigaddset (&set, signo);
+ pthread_sigmask (SIG_BLOCK, &sigmask, NULL);
+
+ pthread_mutex_lock ();
+ jmp_used_signals [signo] = 0;
+ pthread_mutex_unlock ();
+#endif
+
+ // Restore the saved context
longjmp (jmp_info -> jmp_context, LONGJMP_MAGIC);
return;
}
+
int fosa_long_jump_install_handler
(fosa_signal_t *signal, fosa_thread_id_t *handler)
{
return 0;
}
-
#endif /* CONFIG_LONGJUMP */