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