aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2014-03-21 21:27:29 +0000
committerJeff Johnston <jjohnstn@redhat.com>2014-03-21 21:27:29 +0000
commitb7f5fb36f13aa27b1cd6198af58d11dc674d1b2c (patch)
tree0f366e5734d87ba880a6e0700e88f30c11d2f6fb
parente669b401f702dbcae29b46524091b5c1eb2e7abf (diff)
downloadnewlib-b7f5fb36f13aa27b1cd6198af58d11dc674d1b2c.zip
newlib-b7f5fb36f13aa27b1cd6198af58d11dc674d1b2c.tar.gz
newlib-b7f5fb36f13aa27b1cd6198af58d11dc674d1b2c.tar.bz2
2014-03-21 Maciej W. Rozycki <macro@codesourcery.com>
* libc/stdlib/gd_qnan.h (f_QNAN, d_QNAN0, d_QNAN1): Add MIPS versions. (ld_QNAN0, ld_QNAN1, ld_QNAN2, ld_QNAN3): Don't define for MIPS. (ldus_QNAN0, ldus_QNAN1, ldus_QNAN2, ldus_QNAN3, ldus_QNAN4): Likewise. * libc/stdlib/ldtoa.c (nan113, nan64, nan53, nan24): Add MIPS versions. (enan): Handle legacy MIPS payloads. * libm/common/s_nan.c (nan): Use __builtin_nan if supported by the compiler. * libm/common/sf_nan.c (nanf): Likewise.
-rw-r--r--newlib/ChangeLog14
-rw-r--r--newlib/libc/stdlib/gd_qnan.h20
-rw-r--r--newlib/libc/stdlib/ldtoa.c41
-rw-r--r--newlib/libm/common/s_nan.c4
-rw-r--r--newlib/libm/common/sf_nan.c4
5 files changed, 81 insertions, 2 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 9f28a12..86cac3a 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,17 @@
+2014-03-21 Maciej W. Rozycki <macro@codesourcery.com>
+
+ * libc/stdlib/gd_qnan.h (f_QNAN, d_QNAN0, d_QNAN1): Add MIPS
+ versions.
+ (ld_QNAN0, ld_QNAN1, ld_QNAN2, ld_QNAN3): Don't define for MIPS.
+ (ldus_QNAN0, ldus_QNAN1, ldus_QNAN2, ldus_QNAN3, ldus_QNAN4):
+ Likewise.
+ * libc/stdlib/ldtoa.c (nan113, nan64, nan53, nan24): Add MIPS
+ versions.
+ (enan): Handle legacy MIPS payloads.
+ * libm/common/s_nan.c (nan): Use __builtin_nan if supported by
+ the compiler.
+ * libm/common/sf_nan.c (nanf): Likewise.
+
2014-03-21 Sabrina Ni <sabrinanitw@gmail.com>
* libc/machine/nds32/configure: Regenerated.
diff --git a/newlib/libc/stdlib/gd_qnan.h b/newlib/libc/stdlib/gd_qnan.h
index 68f16cd..b775f82 100644
--- a/newlib/libc/stdlib/gd_qnan.h
+++ b/newlib/libc/stdlib/gd_qnan.h
@@ -1,5 +1,6 @@
#ifdef __IEEE_BIG_ENDIAN
+#if !defined(__mips)
#define f_QNAN 0x7fc00000
#define d_QNAN0 0x7ff80000
#define d_QNAN1 0x0
@@ -12,9 +13,19 @@
#define ldus_QNAN2 0x0
#define ldus_QNAN3 0x0
#define ldus_QNAN4 0x0
+#elif defined(__mips_nan2008)
+#define f_QNAN 0x7fc00000
+#define d_QNAN0 0x7ff80000
+#define d_QNAN1 0x0
+#else
+#define f_QNAN 0x7fbfffff
+#define d_QNAN0 0x7ff7ffff
+#define d_QNAN1 0xffffffff
+#endif
#elif defined(__IEEE_LITTLE_ENDIAN)
+#if !defined(__mips)
#define f_QNAN 0xffc00000
#define d_QNAN0 0x0
#define d_QNAN1 0xfff80000
@@ -27,6 +38,15 @@
#define ldus_QNAN2 0x0
#define ldus_QNAN3 0xc000
#define ldus_QNAN4 0xffff
+#elif defined(__mips_nan2008)
+#define f_QNAN 0x7fc00000
+#define d_QNAN0 0x0
+#define d_QNAN1 0x7ff80000
+#else
+#define f_QNAN 0x7fbfffff
+#define d_QNAN0 0xffffffff
+#define d_QNAN1 0x7ff7ffff
+#endif
#else
#error IEEE endian not defined
diff --git a/newlib/libc/stdlib/ldtoa.c b/newlib/libc/stdlib/ldtoa.c
index b13ac69..76b4638 100644
--- a/newlib/libc/stdlib/ldtoa.c
+++ b/newlib/libc/stdlib/ldtoa.c
@@ -3679,16 +3679,40 @@ emdnorm( num, 0, 0, ln, 0, ldp );
/* NaN bit patterns
*/
#ifdef MIEEE
+#if !defined(__mips)
static _CONST unsigned short nan113[8] = {
0x7fff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff};
-static _CONST unsigned short nan64[6] = {0x7fff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff};
+static _CONST unsigned short nan64[6] = {
+ 0x7fff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff};
static _CONST unsigned short nan53[4] = {0x7fff, 0xffff, 0xffff, 0xffff};
static _CONST unsigned short nan24[2] = {0x7fff, 0xffff};
+#elif defined(__mips_nan2008) /* __mips */
+static _CONST unsigned short nan113[8] = {0x7fff, 0x8000, 0, 0, 0, 0, 0, 0};
+static _CONST unsigned short nan64[6] = {0x7fff, 0xc000, 0, 0, 0, 0};
+static _CONST unsigned short nan53[4] = {0x7ff8, 0, 0, 0};
+static _CONST unsigned short nan24[2] = {0x7fc0, 0};
+#else /* __mips && !__mips_nan2008 */
+static _CONST unsigned short nan113[8] = {
+ 0x7fff, 0x7fff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff};
+static _CONST unsigned short nan64[6] = {
+ 0x7fff, 0xbfff, 0xffff, 0xffff, 0xffff, 0xffff};
+static _CONST unsigned short nan53[4] = {0x7ff7, 0xffff, 0xffff, 0xffff};
+static _CONST unsigned short nan24[2] = {0x7fbf, 0xffff};
+#endif /* __mips && !__mips_nan2008 */
#else /* !MIEEE */
+#if !defined(__mips) || defined(__mips_nan2008)
static _CONST unsigned short nan113[8] = {0, 0, 0, 0, 0, 0, 0x8000, 0x7fff};
static _CONST unsigned short nan64[6] = {0, 0, 0, 0, 0xc000, 0x7fff};
static _CONST unsigned short nan53[4] = {0, 0, 0, 0x7ff8};
static _CONST unsigned short nan24[2] = {0, 0x7fc0};
+#else /* __mips && !__mips_nan2008 */
+static _CONST unsigned short nan113[8] = {
+ 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x7fff, 0x7fff};
+static _CONST unsigned short nan64[6] = {
+ 0xffff, 0xffff, 0xffff, 0xffff, 0xbfff, 0x7fff};
+static _CONST unsigned short nan53[4] = {0xffff, 0xffff, 0xffff, 0x7ff7};
+static _CONST unsigned short nan24[2] = {0xffff, 0x7fbf};
+#endif /* __mips && !__mips_nan2008 */
#endif /* !MIEEE */
@@ -3721,9 +3745,15 @@ switch( size )
break;
case NBITS:
+#if !defined(__mips) || defined(__mips_nan2008)
for( i=0; i<NE-2; i++ )
*nan++ = 0;
*nan++ = 0xc000;
+#else /* __mips && !__mips_nan2008 */
+ for( i=0; i<NE-2; i++ )
+ *nan++ = 0xffff;
+ *nan++ = 0xbfff;
+#endif /* __mips && !__mips_nan2008 */
*nan++ = 0x7fff;
return;
@@ -3731,9 +3761,16 @@ switch( size )
*nan++ = 0;
*nan++ = 0x7fff;
*nan++ = 0;
+#if !defined(__mips) || defined(__mips_nan2008)
*nan++ = 0xc000;
- for( i=4; i<NI; i++ )
+ for( i=4; i<NI-1; i++ )
*nan++ = 0;
+#else /* __mips && !__mips_nan2008 */
+ *nan++ = 0xbfff;
+ for( i=4; i<NI-1; i++ )
+ *nan++ = 0xffff;
+#endif /* __mips && !__mips_nan2008 */
+ *nan++ = 0;
return;
#endif
default:
diff --git a/newlib/libm/common/s_nan.c b/newlib/libm/common/s_nan.c
index 7ff4ef7..ba0bb0a 100644
--- a/newlib/libm/common/s_nan.c
+++ b/newlib/libm/common/s_nan.c
@@ -41,7 +41,11 @@ QUICKREF
{
double x;
+#if __GNUC_PREREQ (3, 3)
+ x = __builtin_nan("");
+#else
INSERT_WORDS(x,0x7ff80000,0);
+#endif
return x;
}
diff --git a/newlib/libm/common/sf_nan.c b/newlib/libm/common/sf_nan.c
index 831f3f7..8f0e1a8 100644
--- a/newlib/libm/common/sf_nan.c
+++ b/newlib/libm/common/sf_nan.c
@@ -9,7 +9,11 @@
{
float x;
+#if __GNUC_PREREQ (3, 3)
+ x = __builtin_nanf("");
+#else
SET_FLOAT_WORD(x,0x7fc00000);
+#endif
return x;
}