1 /* $NetBSD: sigfpe.c,v 1.1 2009/02/17 19:05:22 christos Exp $ */
4 #include <sys/ucontext.h>
18 sigfpe(int signo
, siginfo_t
*info
, void *ptr
)
21 printf("%d %p %p\n", signo
, info
, ptr
);
23 printf("si_signo=%d\n", info
->si_signo
);
24 printf("si_errno=%d\n", info
->si_errno
);
25 printf("si_code=%d\n", info
->si_code
);
26 printf("si_value.sival_int=%d\n", info
->si_value
.sival_int
);
29 ucontext_t
*ctx
= ptr
;
31 mcontext_t
*mc
= &ctx
->uc_mcontext
;
32 printf("uc_flags 0x%x\n", ctx
->uc_flags
);
33 printf("uc_link %p\n", ctx
->uc_link
);
34 for (i
= 0; i
< sizeof(ctx
->uc_sigmask
.__bits
) /
35 sizeof(ctx
->uc_sigmask
.__bits
[0]); i
++)
36 printf("uc_sigmask[%d] 0x%x\n", i
,
37 ctx
->uc_sigmask
.__bits
[i
]);
38 printf("uc_stack %p %lu 0x%x\n", ctx
->uc_stack
.ss_sp
,
39 (unsigned long)ctx
->uc_stack
.ss_size
,
40 ctx
->uc_stack
.ss_flags
);
41 for (i
= 0; i
< sizeof(mc
->__gregs
)/sizeof(mc
->__gregs
[0]); i
++)
42 printf("uc_mcontext.greg[%d] 0x%x\n", i
,
47 assert(info
->si_signo
== SIGFPE
);
48 assert(info
->si_code
== FPE_FLTDIV
);
49 assert(info
->si_errno
== 0);
56 double d
= strtod("0", NULL
);
58 sa
.sa_flags
= SA_SIGINFO
;
59 sa
.sa_sigaction
= sigfpe
;
60 sigemptyset(&sa
.sa_mask
);
61 sigaction(SIGFPE
, &sa
, NULL
);
63 fpsetmask(FP_X_INV
|FP_X_DZ
|FP_X_OFL
|FP_X_UFL
|FP_X_IMP
);
65 printf("%g\n", 1 / d
);