]> rtime.felk.cvut.cz Git - frescor/fosa.git/blobdiff - src_aquosa/fosa_long_jump.c
Small changes and bugfixes in signal handling, mutexes and condition variables.
[frescor/fosa.git] / src_aquosa / fosa_long_jump.c
index 30e350e96d949fb166e67766ac7037d1f8826848..e784bf9961e02c1647dc909ce62bf15ef5109fe5 100644 (file)
@@ -103,7 +103,7 @@ int fosa_long_jump_save_context(fosa_long_jump_context_t *context)
        if (context == NULL)
                return FOSA_EINVAL;
 
-       sigsetjmp(*context, 1);
+       context->setjmp_retvalue = sigsetjmp(context->setjmp_context, 1);
 
        return 0;
 }
@@ -132,7 +132,12 @@ int fosa_long_jump_save_context(fosa_long_jump_context_t *context)
 int fosa_long_jump_was_performed(const fosa_long_jump_context_t *context,
                                 int *jumped)
 {
-       return FOSA_EINVAL;
+       if (context == NULL)
+               return FOSA_EINVAL;
+
+       *jumped = context->setjmp_retvalue != 0;
+
+       return 0;
 }
 
 /** 
@@ -143,7 +148,7 @@ void __long_jump_handler(int n, siginfo_t *info, void *c)
        fosa_long_jump_context_t *context =
                (fosa_long_jump_context_t*) info->si_ptr;
 
-       siglongjmp(*context, 1);
+       siglongjmp(context->setjmp_context, -1);
 }
 
 /**
@@ -194,6 +199,7 @@ int fosa_long_jump_install_handler(fosa_signal_t *signal,
        int ret;
        struct sigaction sa_long_jump;
 
+       signal = FOSA_LONG_JUMP_SIGNAL;
        sa_long_jump.sa_handler = NULL;
        sa_long_jump.sa_sigaction = __long_jump_handler;
        sigemptyset(&sa_long_jump.sa_mask);