Pull the following revision from upstream to provide __unordsf2() and

other missing softfloat functions:
---
Revision 108487
2005-12-13  Paul Brook  <paul@codesourcery.com>
	* config/m68k/fpgnulib.c (__unordsf2, __unorddf2, __unordxf2,
	__floatunsidf, __floatunsisf, __floatunsixf): New functions.
---

Fixes link errors of sources that refer isnan() on m68000.

Note this file is not GPLed.
This commit is contained in:
tsutsui 2011-06-06 12:02:26 +00:00
parent 0f31b40708
commit 078de69e1f
1 changed files with 96 additions and 0 deletions

View File

@ -105,6 +105,69 @@ union long_double_long
#ifndef EXTFLOAT
int
__unordsf2(float a, float b)
{
union float_long fl;
fl.f = a;
if (EXP(fl.l) == EXP(~0u) && (MANT(fl.l) & ~HIDDEN) != 0)
return 1;
fl.f = b;
if (EXP(fl.l) == EXP(~0u) && (MANT(fl.l) & ~HIDDEN) != 0)
return 1;
return 0;
}
int
__unorddf2(double a, double b)
{
union double_long dl;
dl.d = a;
if (EXPD(dl) == EXPDMASK
&& ((dl.l.upper & MANTDMASK) != 0 || dl.l.lower != 0))
return 1;
dl.d = b;
if (EXPD(dl) == EXPDMASK
&& ((dl.l.upper & MANTDMASK) != 0 || dl.l.lower != 0))
return 1;
return 0;
}
/* convert unsigned int to double */
double
__floatunsidf (unsigned long a1)
{
long exp = 32 + EXCESSD;
union double_long dl;
if (!a1)
{
dl.l.upper = dl.l.lower = 0;
return dl.d;
}
while (a1 < 0x2000000L)
{
a1 <<= 4;
exp -= 4;
}
while (a1 < 0x80000000L)
{
a1 <<= 1;
exp--;
}
/* pack up and go home */
dl.l.upper = exp << 20L;
dl.l.upper |= (a1 >> 11L) & ~HIDDEND;
dl.l.lower = a1 << 21L;
return dl.d;
}
/* convert int to double */
double
__floatsidf (long a1)
@ -151,6 +214,14 @@ __floatsidf (long a1)
return dl.d;
}
/* convert unsigned int to float */
float
__floatunsisf (unsigned long l)
{
double foo = __floatunsidf (l);
return foo;
}
/* convert int to float */
float
__floatsisf (long l)
@ -292,6 +363,7 @@ __fixsfsi (float a1)
We assume all numbers are normalized, don't do any rounding, etc. */
/* Prototypes for the above in case we use them. */
double __floatunsidf (unsigned long);
double __floatsidf (long);
float __floatsisf (long);
double __extendsfdf2 (float);
@ -300,6 +372,22 @@ long __fixdfsi (double);
long __fixsfsi (float);
int __cmpdf2 (double, double);
int
__unordxf2(long double a, long double b)
{
union long_double_long ldl;
ldl.ld = a;
if (EXPX(ldl) == EXPXMASK
&& ((ldl.l.middle & MANTXMASK) != 0 || ldl.l.lower != 0))
return 1;
ldl.ld = b;
if (EXPX(ldl) == EXPXMASK
&& ((ldl.l.middle & MANTXMASK) != 0 || ldl.l.lower != 0))
return 1;
return 0;
}
/* convert double to long double */
long double
__extenddfxf2 (double d)
@ -382,6 +470,14 @@ __floatsixf (long l)
return foo;
}
/* convert an unsigned int to a long double */
long double
__floatunsixf (unsigned long l)
{
double foo = __floatunsidf (l);
return foo;
}
/* convert a long double to an int */
long
__fixxfsi (long double ld)