From 86c293bf54231dee13f45592a39a3f0d0cf19931 Mon Sep 17 00:00:00 2001 From: das Date: Mon, 19 Jul 2004 08:17:25 +0000 Subject: Make FLT_ROUNDS correctly reflect the dynamic rounding mode. --- lib/libc/i386/gen/flt_rounds.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/libc/i386/gen/flt_rounds.c (limited to 'lib/libc/i386/gen/flt_rounds.c') diff --git a/lib/libc/i386/gen/flt_rounds.c b/lib/libc/i386/gen/flt_rounds.c new file mode 100644 index 0000000..16417ff --- /dev/null +++ b/lib/libc/i386/gen/flt_rounds.c @@ -0,0 +1,25 @@ +/* + * Written by J.T. Conklin, Apr 10, 1995 + * Public domain. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +static const int map[] = { + 1, /* round to nearest */ + 3, /* round to zero */ + 2, /* round to negative infinity */ + 0 /* round to positive infinity */ +}; + +int +__flt_rounds(void) +{ + int x; + + __asm("fnstcw %0" : "=m" (x)); + return (map[(x >> 10) & 0x03]); +} -- cgit v1.1