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