/* $OpenBSD: toint.c,v 1.4 2003/09/02 23:52:17 david Exp $ */ /* Written by Michael Shalayeff, 2003, Public domain. */ #include #include #include #include #include static void sigfpe(int sig, siginfo_t *si, void *v) { char buf[132]; if (si) { snprintf(buf, sizeof(buf), "sigfpe: addr=%p, code=%d\n", si->si_addr, si->si_code); write(1, buf, strlen(buf)); } _exit(1); } static int toint(double d) { return (int)d; } int main(int argc, char *argv[]) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = sigfpe; sa.sa_flags = SA_SIGINFO; sigaction(SIGFPE, &sa, NULL); if (toint(8.6) != 8) exit(1); exit(0); }