⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 900-nios2.patch

📁 這是一個實時嵌入式作業系統 實作了MCS51 ARM等MCU
💻 PATCH
📖 第 1 页 / 共 5 页
字号:
+#endif /* L_sf_to_df */++#if defined(L_sf_to_tf) && defined(TMODES)+TFtype+sf_to_tf (SFtype arg_a)+{+  fp_number_type in;+  FLO_union_type au;++  au.value = arg_a;+  unpack_d (&au, &in);++  return __make_tp (in.class, in.sign, in.normal_exp,+		    ((UTItype) in.fraction.ll) << F_T_BITOFF);+}+#endif /* L_sf_to_df */++#endif /* ! FLOAT_ONLY */+#endif /* FLOAT */++#ifndef FLOAT++extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);++#if defined(L_make_df)+DFtype+__make_dp (fp_class_type class, unsigned int sign, int exp, UDItype frac)+{+  fp_number_type in;++  in.class = class;+  in.sign = sign;+  in.normal_exp = exp;+  in.fraction.ll = frac;+  return pack_d (&in);+}+#endif /* L_make_df */++#if defined(L_df_to_sf)+SFtype+df_to_sf (DFtype arg_a)+{+  fp_number_type in;+  USItype sffrac;+  FLO_union_type au;++  au.value = arg_a;+  unpack_d (&au, &in);++  sffrac = in.fraction.ll >> F_D_BITOFF;++  /* We set the lowest guard bit in SFFRAC if we discarded any non+     zero bits.  */+  if ((in.fraction.ll & (((USItype) 1 << F_D_BITOFF) - 1)) != 0)+    sffrac |= 1;++  return __make_fp (in.class, in.sign, in.normal_exp, sffrac);+}+#endif /* L_df_to_sf */++#if defined(L_df_to_tf) && defined(TMODES) \+    && !defined(FLOAT) && !defined(TFLOAT)+TFtype+df_to_tf (DFtype arg_a)+{+  fp_number_type in;+  FLO_union_type au;++  au.value = arg_a;+  unpack_d (&au, &in);++  return __make_tp (in.class, in.sign, in.normal_exp,+		    ((UTItype) in.fraction.ll) << D_T_BITOFF);+}+#endif /* L_sf_to_df */++#ifdef TFLOAT+#if defined(L_make_tf)+TFtype+__make_tp(fp_class_type class,+	     unsigned int sign,+	     int exp, +	     UTItype frac)+{+  fp_number_type in;++  in.class = class;+  in.sign = sign;+  in.normal_exp = exp;+  in.fraction.ll = frac;+  return pack_d (&in);+}+#endif /* L_make_tf */++#if defined(L_tf_to_df)+DFtype+tf_to_df (TFtype arg_a)+{+  fp_number_type in;+  UDItype sffrac;+  FLO_union_type au;++  au.value = arg_a;+  unpack_d (&au, &in);++  sffrac = in.fraction.ll >> D_T_BITOFF;++  /* We set the lowest guard bit in SFFRAC if we discarded any non+     zero bits.  */+  if ((in.fraction.ll & (((UTItype) 1 << D_T_BITOFF) - 1)) != 0)+    sffrac |= 1;++  return __make_dp (in.class, in.sign, in.normal_exp, sffrac);+}+#endif /* L_tf_to_df */++#if defined(L_tf_to_sf)+SFtype+tf_to_sf (TFtype arg_a)+{+  fp_number_type in;+  USItype sffrac;+  FLO_union_type au;++  au.value = arg_a;+  unpack_d (&au, &in);++  sffrac = in.fraction.ll >> F_T_BITOFF;++  /* We set the lowest guard bit in SFFRAC if we discarded any non+     zero bits.  */+  if ((in.fraction.ll & (((UTItype) 1 << F_T_BITOFF) - 1)) != 0)+    sffrac |= 1;++  return __make_fp (in.class, in.sign, in.normal_exp, sffrac);+}+#endif /* L_tf_to_sf */+#endif /* TFLOAT */++#endif /* ! FLOAT */+#endif /* !EXTENDED_FLOAT_STUBS */--- gcc-3.4.3/gcc/config/nios2/nios2-fp-bit.c+++ gcc-3.4.3-nios2/gcc/config/nios2/nios2-fp-bit.c@@ -0,0 +1,1652 @@+#define FLOAT+/* This is a software floating point library which can be used+   for targets without hardware floating point. +   Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004+   Free Software Foundation, Inc.++This file is free software; you can redistribute it and/or modify it+under the terms of the GNU General Public License as published by the+Free Software Foundation; either version 2, or (at your option) any+later version.++In addition to the permissions in the GNU General Public License, the+Free Software Foundation gives you unlimited permission to link the+compiled version of this file with other programs, and to distribute+those programs without any restriction coming from the use of this+file.  (The General Public License restrictions do apply in other+respects; for example, they cover modification of the file, and+distribution when not linked into another program.)++This file is distributed in the hope that it will be useful, but+WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU+General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; see the file COPYING.  If not, write to+the Free Software Foundation, 59 Temple Place - Suite 330,+Boston, MA 02111-1307, USA.  */++/* As a special exception, if you link this library with other files,+   some of which are compiled with GCC, to produce an executable,+   this library does not by itself cause the resulting executable+   to be covered by the GNU General Public License.+   This exception does not however invalidate any other reasons why+   the executable file might be covered by the GNU General Public License.  */++/* This implements IEEE 754 format arithmetic, but does not provide a+   mechanism for setting the rounding mode, or for generating or handling+   exceptions.++   The original code by Steve Chamberlain, hacked by Mark Eichin and Jim+   Wilson, all of Cygnus Support.  */++/* The intended way to use this file is to make two copies, add `#define FLOAT'+   to one copy, then compile both copies and add them to libgcc.a.  */++#include "tconfig.h"+#include "coretypes.h"+#include "tm.h"+#include "config/fp-bit.h"++/* The following macros can be defined to change the behavior of this file:+   FLOAT: Implement a `float', aka SFmode, fp library.  If this is not+     defined, then this file implements a `double', aka DFmode, fp library.+   FLOAT_ONLY: Used with FLOAT, to implement a `float' only library, i.e.+     don't include float->double conversion which requires the double library.+     This is useful only for machines which can't support doubles, e.g. some+     8-bit processors.+   CMPtype: Specify the type that floating point compares should return.+     This defaults to SItype, aka int.+   US_SOFTWARE_GOFAST: This makes all entry points use the same names as the+     US Software goFast library.+   _DEBUG_BITFLOAT: This makes debugging the code a little easier, by adding+     two integers to the FLO_union_type.+   NO_DENORMALS: Disable handling of denormals.+   NO_NANS: Disable nan and infinity handling+   SMALL_MACHINE: Useful when operations on QIs and HIs are faster+     than on an SI */++/* We don't currently support extended floats (long doubles) on machines+   without hardware to deal with them.++   These stubs are just to keep the linker from complaining about unresolved+   references which can be pulled in from libio & libstdc++, even if the+   user isn't using long doubles.  However, they may generate an unresolved+   external to abort if abort is not used by the function, and the stubs+   are referenced from within libc, since libgcc goes before and after the+   system library.  */++#ifdef DECLARE_LIBRARY_RENAMES+  DECLARE_LIBRARY_RENAMES+#endif++#ifdef EXTENDED_FLOAT_STUBS+extern void abort (void);+void __extendsfxf2 (void) { abort(); }+void __extenddfxf2 (void) { abort(); }+void __truncxfdf2 (void) { abort(); }+void __truncxfsf2 (void) { abort(); }+void __fixxfsi (void) { abort(); }+void __floatsixf (void) { abort(); }+void __addxf3 (void) { abort(); }+void __subxf3 (void) { abort(); }+void __mulxf3 (void) { abort(); }+void __divxf3 (void) { abort(); }+void __negxf2 (void) { abort(); }+void __eqxf2 (void) { abort(); }+void __nexf2 (void) { abort(); }+void __gtxf2 (void) { abort(); }+void __gexf2 (void) { abort(); }+void __lexf2 (void) { abort(); }+void __ltxf2 (void) { abort(); }++void __extendsftf2 (void) { abort(); }+void __extenddftf2 (void) { abort(); }+void __trunctfdf2 (void) { abort(); }+void __trunctfsf2 (void) { abort(); }+void __fixtfsi (void) { abort(); }+void __floatsitf (void) { abort(); }+void __addtf3 (void) { abort(); }+void __subtf3 (void) { abort(); }+void __multf3 (void) { abort(); }+void __divtf3 (void) { abort(); }+void __negtf2 (void) { abort(); }+void __eqtf2 (void) { abort(); }+void __netf2 (void) { abort(); }+void __gttf2 (void) { abort(); }+void __getf2 (void) { abort(); }+void __letf2 (void) { abort(); }+void __lttf2 (void) { abort(); }+#else	/* !EXTENDED_FLOAT_STUBS, rest of file */++/* IEEE "special" number predicates */++#ifdef NO_NANS++#define nan() 0+#define isnan(x) 0+#define isinf(x) 0+#else++#if   defined L_thenan_sf+const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };+#elif defined L_thenan_df+const fp_number_type __thenan_df = { CLASS_SNAN, 0, 0, {(fractype) 0} };+#elif defined L_thenan_tf+const fp_number_type __thenan_tf = { CLASS_SNAN, 0, 0, {(fractype) 0} };+#elif defined TFLOAT+extern const fp_number_type __thenan_tf;+#elif defined FLOAT+extern const fp_number_type __thenan_sf;+#else+extern const fp_number_type __thenan_df;+#endif++INLINE+static fp_number_type *+nan (void)+{+  /* Discard the const qualifier...  */+#ifdef TFLOAT+  return (fp_number_type *) (& __thenan_tf);+#elif defined FLOAT  +  return (fp_number_type *) (& __thenan_sf);+#else+  return (fp_number_type *) (& __thenan_df);+#endif+}++INLINE+static int+isnan ( fp_number_type *  x)+{+  return x->class == CLASS_SNAN || x->class == CLASS_QNAN;+}++INLINE+static int+isinf ( fp_number_type *  x)+{+  return x->class == CLASS_INFINITY;+}++#endif /* NO_NANS */++INLINE+static int+iszero ( fp_number_type *  x)+{+  return x->class == CLASS_ZERO;+}++INLINE +static void+flip_sign ( fp_number_type *  x)+{+  x->sign = !x->sign;+}++extern FLO_type pack_d ( fp_number_type * );++#if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)+FLO_type+pack_d ( fp_number_type *  src)+{+  FLO_union_type dst;+  fractype fraction = src->fraction.ll;	/* wasn't unsigned before? */+  int sign = src->sign;+  int exp = 0;++  if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && (isnan (src) || isinf (src)))+    {+      /* We can't represent these values accurately.  By using the+	 largest possible magnitude, we guarantee that the conversion+	 of infinity is at least as big as any finite number.  */+      exp = EXPMAX;+      fraction = ((fractype) 1 << FRACBITS) - 1;+    }+  else if (isnan (src))+    {+      exp = EXPMAX;+      if (src->class == CLASS_QNAN || 1)+	{+#ifdef QUIET_NAN_NEGATED+	  fraction |= QUIET_NAN - 1;+#else+	  fraction |= QUIET_NAN;+#endif+	}+    }+  else if (isinf (src))+    {+      exp = EXPMAX;+      fraction = 0;+    }+  else if (iszero (src))+    {+      exp = 0;+      fraction = 0;+    }+  else if (fraction == 0)+    {+      exp = 0;+    }+  else+    {+      if (src->normal_exp < NORMAL_EXPMIN)+	{+#ifdef NO_DENORMALS+	  /* Go straight to a zero representation if denormals are not+ 	     supported.  The denormal handling would be harmless but+ 	     isn't unnecessary.  */+	  exp = 0;+	  fraction = 0;+#else /* NO_DENORMALS */+	  /* This number's exponent is too low to fit into the bits+	     available in the number, so we'll store 0 in the exponent and+	     shift the fraction to the right to make up for it.  */++	  int shift = NORMAL_EXPMIN - src->normal_exp;++	  exp = 0;++	  if (shift > FRAC_NBITS - NGARDS)+	    {+	      /* No point shifting, since it's more that 64 out.  */+	      fraction = 0;+	    }+	  else+	    {+	      int lowbit = (fraction & (((fractype)1 << shift) - 1)) ? 1 : 0;+	      fraction = (fraction >> shift) | lowbit;+	    }+	  if ((fraction & GARDMASK) == GARDMSB)+	    {+	      if ((fraction & (1 << NGARDS)))+		fraction += GARDROUND + 1;+	    }+	  else+	    {+	      /* Add to the guards to round up.  */+	      fraction += GARDROUND;+	    }+	  /* Perhaps the rounding means we now need to change the+             exponent, because the fraction is no longer denormal.  */+	  if (fraction >= IMPLICIT_1)+	    {+	      exp += 1;+	    }+	  fraction >>= NGARDS;+#endif /* NO_DENORMALS */+	}+      else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS)+	       && src->normal_exp > EXPBIAS)+	{+	  exp = EXPMAX;+	  fraction = 0;+	}+      else+	{+	  exp = src->normal_exp + EXPBIAS;+	  if (!ROUND_TOWARDS_ZERO)+	    {+	      /* IF the gard bits are the all zero, but the first, then we're+		 half way between two numbers, choose the one which makes the+		 lsb of the answer 0.  */+	      if ((fraction & GARDMASK) == GARDMSB)+		{+		  if (fraction & (1 << NGARDS))+		    fraction += GARDROUND + 1;+		}+	      else+		{+		  /* Add a one to the guards to round up */+		  fraction += GARDROUND;+		}+	      if (fraction >= IMPLICIT_2)+		{+		  fraction >>= 1;+		  exp += 1;+		}+	    }+	  fraction >>= NGARDS;++	  if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && exp > EXPMAX)+	    {+	      /* Saturate on overflow.  */+	      exp = EXPMAX;+	      fraction = ((fractype) 1 << FRACBITS) - 1;+	    }+	}+    }++  /* We previously used bitfields to store the number, but this doesn't+     handle little/big endian systems conveniently, so use shifts and+     masks */+#ifdef FLOAT_BIT_ORDER_MISMATCH+  dst.bits.fraction = fraction;+  dst.bits.exp = exp;+  dst.bits.sign = sign;+#else+# if defined TFLOAT && defined HALFFRACBITS+ {+   halffractype high, low, unity;+   int lowsign, lowexp;++   unity = (halffractype) 1 << HALFFRACBITS;++   /* Set HIGH to the high double's significand, masking out the implicit 1.+      Set LOW to the low double's full significand.  */+   high = (fraction >> (FRACBITS - HALFFRACBITS)) & (unity - 1);+   low = fraction & (unity * 2 - 1);++   /* Get the initial sign and exponent of the low double.  */+   lowexp = exp - HALFFRACBITS - 1;+   lowsign = sign;++   /* HIGH should be rounded like a normal double, making |LOW| <=+      0.5 ULP of HIGH.  Assume round-to-nearest.  */+   if (exp < EXPMAX)+     if (low > unity || (low == unity && (high & 1) == 1))+       {+	 /* Round HIGH up and adjust LOW to match.  */+	 high++;+	 if (high == unity)+	   {+	     /* May make it infinite, but that's OK.  */+	     high = 0;+	     exp++;+	   }+	 low = unity * 2 - low;+	 lowsign ^= 1;+       }++   high |= (halffractype) exp << HALFFRACBITS;+   high |= (halffractype) sign << (HALFFRACBITS + EXPBITS);++   if (exp == EXPMAX || exp == 0 || low == 0)+     low = 0;+   else+     {+       while (lowexp > 0 && low < unity)+	 {+	   low <<= 1;+	   lowexp--;+	 }++       if (lowexp <= 0)+	 {+	   halffractype roundmsb, round;+	   int shift;++	   shift = 1 - lowexp;+	   roundm

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -