1 /* FPU state corruption test. This used to be able to crash the kernel. */
7 #include <machine/fpu.h>
16 static void use_fpu(int n
)
18 state
+= (double) n
* 0.5;
21 static void crashed(int sig
)
26 static void handler(int sig
, int code
, struct sigcontext
*sc
)
28 memset(&sc
->sc_fpu_state
, count
, sizeof(sc
->sc_fpu_state
));
38 signal(SIGUSR1
, (void (*)(int)) handler
);
40 /* Initialize the FPU state. This state is inherited, too. */
43 for (count
= 0; count
<= 255; count
++) {
51 signal(SIGFPE
, crashed
);
53 /* Load bad state into the kernel. */
54 if (kill(getpid(), SIGUSR1
)) e(2);
56 /* Let the kernel restore the state. */
62 /* We cannot tell exactly whether what happened is correct or
63 * not -- certainly not in a platform-independent way. However,
64 * if the whole system keeps running, that's good enough.
70 if (state
<= 1.4 || state
>= 1.6) e(3);