diff options
Diffstat (limited to 'none/tests/solaris/context_link2.c')
-rw-r--r-- | none/tests/solaris/context_link2.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/none/tests/solaris/context_link2.c b/none/tests/solaris/context_link2.c new file mode 100644 index 000000000..9d64b6b5e --- /dev/null +++ b/none/tests/solaris/context_link2.c @@ -0,0 +1,48 @@ +/* Test of correct simulation for uc->uc_link in a signal handler. */ + +#include <assert.h> +#include <signal.h> +#include <stdio.h> +#include <ucontext.h> + +static void sighandler(int sig, siginfo_t *sip, ucontext_t *ucp) +{ + ucontext_t uc2; + + /* Current uc_link value has to be equal to ucp. */ + getcontext(&uc2); + assert(uc2.uc_link == ucp); +} + +int main(void) +{ + ucontext_t uc; + struct sigaction sa; + + /* Current uc_link value has to be NULL. */ + if (getcontext(&uc)) { + perror("getcontext"); + return 1; + } + assert(!uc.uc_link); + + sa.sa_handler = sighandler; + sa.sa_flags = SA_SIGINFO; + if (sigfillset(&sa.sa_mask)) { + perror("sigfillset"); + return 1; + } + if (sigaction(SIGUSR1, &sa, NULL)) { + perror("sigaction"); + return 1; + } + + raise(SIGUSR1); + + /* Current uc_link value has to be NULL. */ + getcontext(&uc); + assert(!uc.uc_link); + + return 0; +} + |