xref: /openbsd-src/lib/libc/arch/m88k/gen/flt_rounds.c (revision af3276d5e32f3e939032c022c530ad02a9ed9a1e)
1*af3276d5Sguenther /*	$OpenBSD: flt_rounds.c,v 1.6 2015/10/27 05:54:49 guenther Exp $	*/
2f0c13142Smiod 
3443998a4Ssmurph /*
4443998a4Ssmurph  * Written by J.T. Conklin, Apr 10, 1995
5443998a4Ssmurph  * Public domain.
6443998a4Ssmurph  */
7443998a4Ssmurph 
8443998a4Ssmurph #include <sys/types.h>
9fba30992Sderaadt #include <float.h>
10443998a4Ssmurph 
11443998a4Ssmurph /*
12443998a4Ssmurph  * Ported to 88k (Nivas Madhur)
13443998a4Ssmurph  */
14443998a4Ssmurph 
15443998a4Ssmurph static const int map[] = {
16f0c13142Smiod 	1,	/* round to nearest */
17f0c13142Smiod 	0,	/* round to zero */
18f0c13142Smiod 	3,	/* round to negative infinity */
19f0c13142Smiod 	2	/* round to positive infinity */
20443998a4Ssmurph };
21443998a4Ssmurph 
22443998a4Ssmurph int
__flt_rounds()23443998a4Ssmurph __flt_rounds()
24443998a4Ssmurph {
25443998a4Ssmurph 	int x;
26443998a4Ssmurph 
270b514a07Smiod 	__asm__("fldcr %0, %%fcr63" : "=r" (x));
28443998a4Ssmurph 	return map[(x >> 14) & 0x03];
29443998a4Ssmurph }
30*af3276d5Sguenther DEF_STRONG(__flt_rounds);
31