FreeBSD: add file descriptor tracking for _umtx_op
[valgrind.git] / none / tests / s390x / test_sig.c
blobb24dbbe106d6df5c3aef6f92106194ca44e0e7e3
1 #include <features.h>
2 #include <fpu_control.h>
3 #include <signal.h>
4 #include <sys/types.h>
5 #include <signal.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <ucontext.h>
9 #include <unistd.h>
11 /* Circumvent bad assembly in system header, so Clang doesn't complain */
12 #undef _FPU_SETCW
13 #define _FPU_SETCW(cw) __asm__ __volatile__ ("sfpc %0" : : "d" (cw))
14 #undef _FPU_GETCW
15 #define _FPU_GETCW(cw) __asm__ __volatile__ ("efpc %0" : "=d" (cw))
17 void handle_SIG(int sig)
19 double d;
21 _FPU_SETCW(0);
22 d = 7;
23 asm volatile ("":: "f" (d));
24 printf("Got signal %d\n", sig);
25 if (sig == SIGSEGV) {
26 printf("SIGSEGV, exiting...\n");
27 exit(0);
31 void handle_rt_SIG(int sig, siginfo_t *info, void *uc)
33 double d;
35 _FPU_SETCW(0);
36 d = 8;
37 asm volatile ("":: "f" (d));
38 printf("Got signal %d\n", sig);
39 printf("si_signo: %d\n", info->si_signo);
40 printf("si_errno: %d\n", info->si_errno);
41 printf("si_code: %d\n", info->si_code);
42 if (sig == SIGSEGV) {
43 printf("SIGSEGV, exiting...\n");
44 exit(0);
48 int main(void)
50 // char *a;
51 struct sigaction sa;
52 double d1,d2,d3,d4,d5;
54 _FPU_SETCW(1);
55 d1 = d2 = d3 = d4 = d5 = 1;
56 sa.sa_sigaction=handle_rt_SIG;
57 sa.sa_flags =SA_SIGINFO;
58 sigemptyset(&sa.sa_mask);
59 sigaction(SIGALRM, &sa, NULL);
60 signal(SIGUSR1, handle_SIG);
61 signal(SIGSEGV, handle_SIG);
62 kill(getpid(), SIGALRM);
63 printf("One!\n");
64 kill(getpid(), SIGUSR1);
65 printf("floating point is now: %f %f %f %f %f\n", d1, d2, d3, d4, d5);
67 int fpc;
68 _FPU_GETCW(fpc);
69 printf("fpc= %d\n", fpc);
71 printf("Good Bye!\n");
72 // a = (char *) 0x12345678;
73 // *a = 1;
74 exit(0);