Module Name: src Committed By: tsutsui Date: Mon Jun 6 12:02:26 UTC 2011
Modified Files: src/gnu/dist/gcc4/gcc/config/m68k: fpgnulib.c Log Message: Pull the following revision from upstream to provide __unordsf2() and other missing softfloat functions: --- Revision 108487 2005-12-13 Paul Brook <p...@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. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/gnu/dist/gcc4/gcc/config/m68k/fpgnulib.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/gnu/dist/gcc4/gcc/config/m68k/fpgnulib.c diff -u src/gnu/dist/gcc4/gcc/config/m68k/fpgnulib.c:1.2 src/gnu/dist/gcc4/gcc/config/m68k/fpgnulib.c:1.3 --- src/gnu/dist/gcc4/gcc/config/m68k/fpgnulib.c:1.2 Thu May 19 03:18:01 2011 +++ src/gnu/dist/gcc4/gcc/config/m68k/fpgnulib.c Mon Jun 6 12:02:26 2011 @@ -105,6 +105,69 @@ #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 @@ 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 @@ 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 __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 @@ 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)