From b7f5fb36f13aa27b1cd6198af58d11dc674d1b2c Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Fri, 21 Mar 2014 21:27:29 +0000 Subject: 2014-03-21 Maciej W. Rozycki * 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. --- newlib/libc/stdlib/gd_qnan.h | 20 ++++++++++++++++++++ newlib/libc/stdlib/ldtoa.c | 41 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) (limited to 'newlib/libc') diff --git a/newlib/libc/stdlib/gd_qnan.h b/newlib/libc/stdlib/gd_qnan.h index 68f16cd12..b775f82d4 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 b13ac69be..76b4638ff 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