Commit | Line | Data |
---|---|---|
05ecdcef SS |
1 | /* |
2 | * Written by J.T. Conklin, Apr 10, 1995 | |
3 | * Public domain. | |
6ff43c94 PA |
4 | * |
5 | * $FreeBSD: head/lib/libc/amd64/gen/flt_rounds.c 132383 2004-07-19 08:17:25Z das $ | |
05ecdcef SS |
6 | */ |
7 | ||
05ecdcef SS |
8 | #include <float.h> |
9 | ||
10 | static const int map[] = { | |
11 | 1, /* round to nearest */ | |
12 | 3, /* round to zero */ | |
13 | 2, /* round to negative infinity */ | |
14 | 0 /* round to positive infinity */ | |
15 | }; | |
16 | ||
17 | int | |
18 | __flt_rounds(void) | |
19 | { | |
20 | int x; | |
21 | ||
6ff43c94 | 22 | /* Assume that the x87 and the SSE unit agree on the rounding mode. */ |
05ecdcef | 23 | __asm("fnstcw %0" : "=m" (x)); |
6ff43c94 | 24 | return (map[(x >> 10) & 0x03]); |
05ecdcef | 25 | } |