xref: /openbsd-src/regress/lib/libm/rint/rint.c (revision db3296cf5c1dd9058ceecc3a29fe4aaa0bd26000)
1 /*	$OpenBSD: rint.c,v 1.3 2003/07/31 21:48:04 deraadt Exp $	*/
2 
3 /*	Written by Michael Shalayeff, 2003,  Public domain.	*/
4 
5 #include <stdio.h>
6 #include <signal.h>
7 #include <unistd.h>
8 #include <math.h>
9 
10 static void
11 sigfpe(int sig, siginfo_t *si, void *v)
12 {
13 	char buf[132];
14 
15 	if (si) {
16 		snprintf(buf, sizeof(buf), "sigfpe: addr=%p, code=%d\n",
17 		    si->si_addr, si->si_code);
18 		write(1, buf, strlen(buf));
19 	}
20 	_exit(1);
21 }
22 
23 int
24 main(int argc, char *argv[])
25 {
26 	struct sigaction sa;
27 
28 	memset(&sa, 0, sizeof(sa));
29 	sa.sa_sigaction = sigfpe;
30 	sa.sa_flags = SA_SIGINFO;
31 	sigaction(SIGFPE, &sa, NULL);
32 
33 	if (rint(8.6) != 9.)
34 		exit(1);
35 
36 	exit(0);
37 }
38