summaryrefslogtreecommitdiffstats
path: root/lib/msun/ld128/s_nanl.c
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2007-12-18 23:46:32 +0000
committerdas <das@FreeBSD.org>2007-12-18 23:46:32 +0000
commitac3245defa5b1bb36c29b4ae9702115677ac6d14 (patch)
treecc7d3c6c65e458a5e66bc120ecd32455cdc17f95 /lib/msun/ld128/s_nanl.c
parent17d5d1f3fcd827013e9f114e95fb1825729aa325 (diff)
downloadFreeBSD-src-ac3245defa5b1bb36c29b4ae9702115677ac6d14.zip
FreeBSD-src-ac3245defa5b1bb36c29b4ae9702115677ac6d14.tar.gz
Since nan() is supposed to work the same as strtod("nan(...)", NULL),
my original implementation made both use the same code. Unfortunately, this meant libm depended on a vendor header at compile time and previously- unexposed vendor bits in libc at runtime. Hence, I just wrote my own version of the relevant vendor routine. As it turns out, mine has a factor of 8 fewer of lines of code, and is a bit more readable anyway. The strtod() and *scanf() routines still use vendor code. Reviewed by: bde
Diffstat (limited to 'lib/msun/ld128/s_nanl.c')
-rw-r--r--lib/msun/ld128/s_nanl.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/msun/ld128/s_nanl.c b/lib/msun/ld128/s_nanl.c
index 6a9bfbf..7b6dc81 100644
--- a/lib/msun/ld128/s_nanl.c
+++ b/lib/msun/ld128/s_nanl.c
@@ -29,19 +29,18 @@
#include <math.h>
#include "fpmath.h"
-#include "../../../contrib/gdtoa/gdtoaimp.h"
+#include "../src/math_private.h"
long double
nanl(const char *s)
{
- static FPI fpi = { 113, -16494, 16271, 1, SI };
+ union {
+ union IEEEl2bits ieee;
+ uint32_t bits[4];
+ } u;
- union IEEEl2bits result;
- ULong bits[2];
- int k;
-
- s--;
- k = hexnan(&s, &fpi, bits);
- ULtoQ((UShort *)&result.e, bits, 16272, k);
- return (result.e);
+ _scan_nan(u.bits, 4, s);
+ u.ieee.bits.exp = 0x7fff;
+ u.ieee.bits.manh |= 1 << 47; /* make it a quiet NaN */
+ return (u.ieee.e);
}
OpenPOWER on IntegriCloud