xref: /freebsd/lib/libc/i386/gen/flt_rounds.c (revision 22cf89c938886d14f5796fc49f9f020c23ea8eaf)
1 /*
2  * Written by J.T. Conklin, Apr 10, 1995
3  * Public domain.
4  */
5 
6 #include <sys/cdefs.h>
7 #include <float.h>
8 
9 static const int map[] = {
10 	1,	/* round to nearest */
11 	3,	/* round to zero */
12 	2,	/* round to negative infinity */
13 	0	/* round to positive infinity */
14 };
15 
16 int
17 __flt_rounds(void)
18 {
19 	int x;
20 
21 	__asm("fnstcw %0" : "=m" (x));
22         return (map[(x >> 10) & 0x03]);
23 }
24