Add 436413 Warn about realloc of size zero to NEWS
[valgrind.git] / memcheck / tests / solaris / context_stack_die.c
blobdd2ba43f5c41eb46604b7a6a7f3fcadd96b5373b
1 /* Test that the stack correctly dies after a setcontext(2) call. */
3 #include <assert.h>
4 #include <signal.h>
5 #include <stdio.h>
6 #include <ucontext.h>
8 static volatile int *sp;
10 static void sighandler(int sig, siginfo_t *sip, void *arg)
12 ucontext_t *ucp = (ucontext_t *) arg;
13 sp = (int *) &ucp->uc_mcontext.gregs[0];
16 int main(void)
18 struct sigaction sa;
19 /* Always-null value that is used to prevent any possible compiler
20 optimizations. */
21 volatile int zero = 0;
23 /* Setup a signal handler. */
24 sa.sa_sigaction = sighandler;
25 sa.sa_flags = SA_SIGINFO;
26 if (sigfillset(&sa.sa_mask)) {
27 perror("sigfillset");
28 return 1;
30 if (sigaction(SIGUSR1, &sa, NULL)) {
31 perror("sigaction");
32 return 1;
35 /* Raise a signal. */
36 raise(SIGUSR1);
38 /* Value pointed by sp should be at this point uninitialized. */
39 if (*sp && zero)
40 assert(0);
42 return 0;