xref: /minix3/lib/libc/arch/ia64/gen/flt_rounds.c (revision 2fe8fb192fe7e8720e3e7a77f928da545e872a6a)
1*2fe8fb19SBen Gras /*
2*2fe8fb19SBen Gras  * Written by J.T. Conklin, Apr 10, 1995
3*2fe8fb19SBen Gras  * Public domain.
4*2fe8fb19SBen Gras  */
5*2fe8fb19SBen Gras 
6*2fe8fb19SBen Gras #include <sys/cdefs.h>
7*2fe8fb19SBen Gras /* __FBSDID("$FreeBSD: src/lib/libc/ia64/gen/flt_rounds.c,v 1.1 2004/07/19 08:17:24 das Exp $"); */
8*2fe8fb19SBen Gras 
9*2fe8fb19SBen Gras #include <float.h>
10*2fe8fb19SBen Gras 
11*2fe8fb19SBen Gras static const int map[] = {
12*2fe8fb19SBen Gras 	1,	/* round to nearest */
13*2fe8fb19SBen Gras 	3,	/* round to zero */
14*2fe8fb19SBen Gras 	2,	/* round to negative infinity */
15*2fe8fb19SBen Gras 	0	/* round to positive infinity */
16*2fe8fb19SBen Gras };
17*2fe8fb19SBen Gras 
18*2fe8fb19SBen Gras int
__flt_rounds(void)19*2fe8fb19SBen Gras __flt_rounds(void)
20*2fe8fb19SBen Gras {
21*2fe8fb19SBen Gras 	int x;
22*2fe8fb19SBen Gras 
23*2fe8fb19SBen Gras 	__asm("mov %0=ar.fpsr" : "=r" (x));
24*2fe8fb19SBen Gras         return (map[(x >> 10) & 0x03]);
25*2fe8fb19SBen Gras }
26