]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - lib/libc/amd64/gen/flt_rounds.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / lib / libc / amd64 / gen / flt_rounds.c
1 /*
2  * Written by J.T. Conklin, Apr 10, 1995
3  * Public domain.
4  */
5
6 #include <sys/cdefs.h>
7 __FBSDID("$FreeBSD$");
8
9 #include <float.h>
10
11 static const int map[] = {
12         1,      /* round to nearest */
13         3,      /* round to zero */
14         2,      /* round to negative infinity */
15         0       /* round to positive infinity */
16 };
17
18 int
19 __flt_rounds(void)
20 {
21         int x;
22
23         /* Assume that the x87 and the SSE unit agree on the rounding mode. */
24         __asm("fnstcw %0" : "=m" (x));
25         return (map[(x >> 10) & 0x03]);
26 }