2 #include <fpu_control.h>
11 /* Circumvent bad assembly in system header, so Clang doesn't complain */
13 #define _FPU_SETCW(cw) __asm__ __volatile__ ("sfpc %0" : : "d" (cw))
15 #define _FPU_GETCW(cw) __asm__ __volatile__ ("efpc %0" : "=d" (cw))
17 void handle_SIG(int sig
)
23 asm volatile ("":: "f" (d
));
24 printf("Got signal %d\n", sig
);
26 printf("SIGSEGV, exiting...\n");
31 void handle_rt_SIG(int sig
, siginfo_t
*info
, void *uc
)
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
);
43 printf("SIGSEGV, exiting...\n");
52 double d1
,d2
,d3
,d4
,d5
;
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
);
64 kill(getpid(), SIGUSR1
);
65 printf("floating point is now: %f %f %f %f %f\n", d1
, d2
, d3
, d4
, d5
);
69 printf("fpc= %d\n", fpc
);
71 printf("Good Bye!\n");
72 // a = (char *) 0x12345678;