This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c/9835: ICE - segfault using -msoft-float with latest mips-elf toolchain


>Number:         9835
>Category:       c
>Synopsis:       Internal Compiler Error (segfault) with -msoft-float for mips-elf toolchain
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 24 17:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Fred Fish
>Release:        3.4 20030224 (experimental)
>Organization:
Intrinsity Inc
>Environment:
System: Linux fred.ninemoons.com 2.4.18-24.8.0 #1 Fri Jan 31 06:51:30 EST 2003 i686 i686 i386 GNU/Linux
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: mips-unknown-elf
configured with: /src/sourceware/gcc/gcc/configure -v --prefix=/usr/local/sourceware --target=mips-elf --enable-gdbtk --disable-multilib --with-gnu-as --with-gnu-ld --with-newlib --enable-languages=c,c++ : (reconfigured) 
>Description:

	Internal compiler error in mips-elf toolchain using -msoft-float.

>How-To-Repeat:

	$ ./cc1 -quiet -O2 floatformat.i
	$ ./cc1 -quiet -O2 -msoft-float floatformat.i
	/tmp/fnf/src/gcc/libiberty/floatformat.c: In function `floatformat_from_double':
	/tmp/fnf/src/gcc/libiberty/floatformat.c:404: internal compiler error: Segmentation fault

-------------- begin floatformat.i -------------
# 1 "/tmp/fnf/src/gcc/libiberty/floatformat.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "/tmp/fnf/src/gcc/libiberty/floatformat.c"
# 20 "/tmp/fnf/src/gcc/libiberty/floatformat.c"
# 1 "/tmp/fnf/src/gcc/include/floatformat.h" 1
# 23 "/tmp/fnf/src/gcc/include/floatformat.h"
# 1 "/tmp/fnf/src/gcc/include/ansidecl.h" 1
# 24 "/tmp/fnf/src/gcc/include/floatformat.h" 2
# 33 "/tmp/fnf/src/gcc/include/floatformat.h"
enum floatformat_byteorders {




  floatformat_little,




  floatformat_big,




  floatformat_littlebyte_bigword

};

enum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no };

struct floatformat
{
  enum floatformat_byteorders byteorder;
  unsigned int totalsize;


  unsigned int sign_start;

  unsigned int exp_start;
  unsigned int exp_len;

  unsigned int exp_bias;



  unsigned int exp_nan;

  unsigned int man_start;
  unsigned int man_len;


  enum floatformat_intbit intbit;


  const char *name;
};



extern const struct floatformat floatformat_ieee_single_big;
extern const struct floatformat floatformat_ieee_single_little;
extern const struct floatformat floatformat_ieee_double_big;
extern const struct floatformat floatformat_ieee_double_little;



extern const struct floatformat floatformat_ieee_double_littlebyte_bigword;



extern const struct floatformat floatformat_i387_ext;
extern const struct floatformat floatformat_m68881_ext;
extern const struct floatformat floatformat_i960_ext;
extern const struct floatformat floatformat_m88110_ext;
extern const struct floatformat floatformat_m88110_harris_ext;
extern const struct floatformat floatformat_arm_ext_big;
extern const struct floatformat floatformat_arm_ext_littlebyte_bigword;

extern const struct floatformat floatformat_ia64_spill_big;
extern const struct floatformat floatformat_ia64_spill_little;
extern const struct floatformat floatformat_ia64_quad_big;
extern const struct floatformat floatformat_ia64_quad_little;





extern void
floatformat_to_double (const struct floatformat *, char *, double *);




extern void
floatformat_from_double (const struct floatformat *, double *, char *);
# 21 "/tmp/fnf/src/gcc/libiberty/floatformat.c" 2
# 1 "/local/intrinsity/mipsisa32-intrinsity-elf/include/math.h" 1 3 4





# 1 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/reent.h" 1 3 4
# 13 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/reent.h" 3 4
# 1 "/local/intrinsity/mipsisa32-intrinsity-elf/include/_ansi.h" 1 3 4
# 15 "/local/intrinsity/mipsisa32-intrinsity-elf/include/_ansi.h" 3 4
# 1 "/local/intrinsity/mipsisa32-intrinsity-elf/include/newlib.h" 1 3 4
# 16 "/local/intrinsity/mipsisa32-intrinsity-elf/include/_ansi.h" 2 3 4
# 1 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/config.h" 1 3 4



# 1 "/local/intrinsity/mipsisa32-intrinsity-elf/include/machine/ieeefp.h" 1 3 4
# 5 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/config.h" 2 3 4
# 17 "/local/intrinsity/mipsisa32-intrinsity-elf/include/_ansi.h" 2 3 4
# 14 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/reent.h" 2 3 4
# 1 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/_types.h" 1 3 4
# 12 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/_types.h" 3 4
typedef long _off_t;
__extension__ typedef long long _off64_t;


typedef int _ssize_t;





# 1 "/usr/local/tmp/fnf/build/gcc/gcc/include/stddef.h" 1 3 4
# 354 "/usr/local/tmp/fnf/build/gcc/gcc/include/stddef.h" 3 4
typedef unsigned int wint_t;
# 23 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/_types.h" 2 3 4


typedef struct
{
  int __count;
  union
  {
    wint_t __wch;
    unsigned char __wchb[4];
  } __value;
} _mbstate_t;

typedef int _flock_t;
# 15 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/reent.h" 2 3 4




typedef unsigned long __ULong;
# 40 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/reent.h" 3 4
struct _Bigint
{
  struct _Bigint *_next;
  int _k, _maxwds, _sign, _wds;
  __ULong _x[1];
};


struct __tm
{
  int __tm_sec;
  int __tm_min;
  int __tm_hour;
  int __tm_mday;
  int __tm_mon;
  int __tm_year;
  int __tm_wday;
  int __tm_yday;
  int __tm_isdst;
};
# 68 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/reent.h" 3 4
struct _atexit {
        struct _atexit *_next;
        int _ind;
        void (*_fns[32])(void);
        void *_fnargs[32];
        __ULong _fntypes;
};
# 91 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/reent.h" 3 4
struct __sbuf {
        unsigned char *_base;
        int _size;
};






typedef long _fpos_t;
# 156 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/reent.h" 3 4
struct __sFILE {
  unsigned char *_p;
  int _r;
  int _w;
  short _flags;
  short _file;
  struct __sbuf _bf;
  int _lbfsize;






  void * _cookie;

  int (*_read) (void * _cookie, char *_buf, int _n);
  int (*_write) (void * _cookie, const char *_buf, int _n);

  _fpos_t (*_seek) (void * _cookie, _fpos_t _offset, int _whence);
  int (*_close) (void * _cookie);


  struct __sbuf _ub;
  unsigned char *_up;
  int _ur;


  unsigned char _ubuf[3];
  unsigned char _nbuf[1];


  struct __sbuf _lb;


  int _blksize;
  int _offset;


  struct _reent *_data;



  _flock_t _lock;

};
# 249 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/reent.h" 3 4
typedef struct __sFILE __FILE;


struct _glue
{
  struct _glue *_next;
  int _niobs;
  __FILE *_iobs;
};
# 280 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/reent.h" 3 4
struct _rand48 {
  unsigned short _seed[3];
  unsigned short _mult[3];
  unsigned short _add;




};
# 532 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/reent.h" 3 4
struct _reent
{
  int _errno;




  __FILE *_stdin, *_stdout, *_stderr;

  int _inc;
  char _emergency[25];

  int _current_category;
  const char *_current_locale;

  int __sdidinit;

  void (*__cleanup) (struct _reent *);


  struct _Bigint *_result;
  int _result_k;
  struct _Bigint *_p5s;
  struct _Bigint **_freelist;


  int _cvtlen;
  char *_cvtbuf;

  union
    {
      struct
        {
          unsigned int _unused_rand;
          char * _strtok_last;
          char _asctime_buf[26];
          struct __tm _localtime_buf;
          int _gamma_signgam;
          __extension__ unsigned long long _rand_next;
          struct _rand48 _r48;
          _mbstate_t _mblen_state;
          _mbstate_t _mbtowc_state;
          _mbstate_t _wctomb_state;
          char _l64a_buf[8];
          char _signal_buf[24];
          int _getdate_err;
          _mbstate_t _mbrlen_state;
          _mbstate_t _mbrtowc_state;
          _mbstate_t _mbsrtowcs_state;
          _mbstate_t _wcrtomb_state;
          _mbstate_t _wcsrtombs_state;
        } _reent;



      struct
        {

          unsigned char * _nextf[30];
          unsigned int _nmalloc[30];
        } _unused;
    } _new;


  struct _atexit *_atexit;
  struct _atexit _atexit0;


  void (**(_sig_func))(int);




  struct _glue __sglue;
  __FILE __sf[3];
};
# 728 "/local/intrinsity/mipsisa32-intrinsity-elf/include/sys/reent.h" 3 4
extern struct _reent *_impure_ptr ;

void _reclaim_reent (struct _reent *);
# 7 "/local/intrinsity/mipsisa32-intrinsity-elf/include/math.h" 2 3 4










union __dmath
{
  __ULong i[2];
  double d;
};




extern const union __dmath __infinity[];
# 35 "/local/intrinsity/mipsisa32-intrinsity-elf/include/math.h" 3 4
extern double atan (double);
extern double cos (double);
extern double sin (double);
extern double tan (double);
extern double tanh (double);
extern double frexp (double, int *);
extern double modf (double, double *);
extern double ceil (double);
extern double fabs (double);
extern double floor (double);






extern double acos (double);
extern double asin (double);
extern double atan2 (double, double);
extern double cosh (double);
extern double sinh (double);
extern double exp (double);
extern double ldexp (double, int);
extern double log (double);
extern double log10 (double);
extern double pow (double, double);
extern double sqrt (double);
extern double fmod (double, double);
# 72 "/local/intrinsity/mipsisa32-intrinsity-elf/include/math.h" 3 4
typedef float float_t;
typedef double double_t;
# 82 "/local/intrinsity/mipsisa32-intrinsity-elf/include/math.h" 3 4
extern int __fpclassifyf (float x);
extern int __fpclassifyd (double x);
# 121 "/local/intrinsity/mipsisa32-intrinsity-elf/include/math.h" 3 4
extern double infinity (void);
extern double nan (void);
extern int isnan (double);
extern int isinf (double);
extern int finite (double);
extern double copysign (double, double);
extern int ilogb (double);

extern double asinh (double);
extern double cbrt (double);
extern double nextafter (double, double);
extern double rint (double);
extern double scalbn (double, int);

extern double exp2 (double);
extern double scalbln (double, long int);
extern double tgamma (double);
extern double nearbyint (double);
extern long int lrint (double);
extern double round (double);
extern long int lround (double);
extern double trunc (double);
extern double remquo (double, double, int *);
extern double copysign (double, double);
extern double fdim (double, double);
extern double fmax (double, double);
extern double fmin (double, double);
extern double fma (double, double, double);
extern void sincos (double, double *, double *);


extern double log1p (double);
extern double expm1 (double);



extern double acosh (double);
extern double atanh (double);
extern double remainder (double, double);
extern double gamma (double);
extern double gamma_r (double, int *);
extern double lgamma (double);
extern double lgamma_r (double, int *);
extern double erf (double);
extern double erfc (double);
extern double y0 (double);
extern double y1 (double);
extern double yn (int, double);
extern double j0 (double);
extern double j1 (double);
extern double jn (int, double);



extern double hypot (double, double);


extern double cabs();
extern double drem (double, double);
# 189 "/local/intrinsity/mipsisa32-intrinsity-elf/include/math.h" 3 4
extern float atanf (float);
extern float cosf (float);
extern float sinf (float);
extern float tanf (float);
extern float tanhf (float);
extern float frexpf (float, int *);
extern float modff (float, float *);
extern float ceilf (float);
extern float fabsf (float);
extern float floorf (float);


extern float acosf (float);
extern float asinf (float);
extern float atan2f (float, float);
extern float coshf (float);
extern float sinhf (float);
extern float expf (float);
extern float ldexpf (float, int);
extern float logf (float);
extern float log10f (float);
extern float powf (float, float);
extern float sqrtf (float);
extern float fmodf (float, float);
# 221 "/local/intrinsity/mipsisa32-intrinsity-elf/include/math.h" 3 4
extern float exp2f (float);
extern float scalblnf (float, long int);
extern float tgammaf (float);
extern float nearbyintf (float);
extern long int lrintf (float);
extern float roundf (float);
extern long int lroundf (float);
extern float truncf (float);
extern float remquof (float, float, int *);
extern float copysignf (float, float);
extern float fdimf (float, float);
extern float fmaxf (float, float);
extern float fminf (float, float);
extern float fmaf (float, float, float);

extern float infinityf (void);
extern float nanf (void);
extern int isnanf (float);
extern int isinff (float);
extern int finitef (float);
extern float copysignf (float, float);
extern int ilogbf (float);

extern float asinhf (float);
extern float cbrtf (float);
extern float nextafterf (float, float);
extern float rintf (float);
extern float scalbnf (float, int);
extern float log1pf (float);
extern float expm1f (float);
extern void sincosf (float, float *, float *);


extern float acoshf (float);
extern float atanhf (float);
extern float remainderf (float, float);
extern float gammaf (float);
extern float gammaf_r (float, int *);
extern float lgammaf (float);
extern float lgammaf_r (float, int *);
extern float erff (float);
extern float erfcf (float);
extern float y0f (float);
extern float y1f (float);
extern float ynf (int, float);
extern float j0f (float);
extern float j1f (float);
extern float jnf (int, float);

extern float hypotf (float, float);

extern float cabsf();
extern float dremf (float, float);






extern int *__signgam (void);
# 290 "/local/intrinsity/mipsisa32-intrinsity-elf/include/math.h" 3 4
struct exception

{
  int type;
  char *name;
  double arg1;
  double arg2;
  double retval;
  int err;
};




extern int matherr (struct exception *e);
# 345 "/local/intrinsity/mipsisa32-intrinsity-elf/include/math.h" 3 4
enum __fdlibm_version
{
  __fdlibm_ieee = -1,
  __fdlibm_svid,
  __fdlibm_xopen,
  __fdlibm_posix
};




extern const enum __fdlibm_version __fdlib_version;
# 365 "/local/intrinsity/mipsisa32-intrinsity-elf/include/math.h" 3 4

# 22 "/tmp/fnf/src/gcc/libiberty/floatformat.c" 2

# 1 "/usr/local/tmp/fnf/build/gcc/gcc/include/stddef.h" 1 3 4
# 151 "/usr/local/tmp/fnf/build/gcc/gcc/include/stddef.h" 3 4
typedef int ptrdiff_t;
# 213 "/usr/local/tmp/fnf/build/gcc/gcc/include/stddef.h" 3 4
typedef unsigned int size_t;
# 325 "/usr/local/tmp/fnf/build/gcc/gcc/include/stddef.h" 3 4
typedef int wchar_t;
# 24 "/tmp/fnf/src/gcc/libiberty/floatformat.c" 2
extern void *memcpy (void *s1, const void *s2, size_t n);
extern void *memset (void *s, int c, size_t n);
# 37 "/tmp/fnf/src/gcc/libiberty/floatformat.c"
const struct floatformat floatformat_ieee_single_big =
{
  floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23,
  floatformat_intbit_no,
  "floatformat_ieee_single_big"
};
const struct floatformat floatformat_ieee_single_little =
{
  floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23,
  floatformat_intbit_no,
  "floatformat_ieee_single_little"
};
const struct floatformat floatformat_ieee_double_big =
{
  floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52,
  floatformat_intbit_no,
  "floatformat_ieee_double_big"
};
const struct floatformat floatformat_ieee_double_little =
{
  floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52,
  floatformat_intbit_no,
  "floatformat_ieee_double_little"
};




const struct floatformat floatformat_ieee_double_littlebyte_bigword =
{
  floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52,
  floatformat_intbit_no,
  "floatformat_ieee_double_littlebyte_bigword"
};

const struct floatformat floatformat_i387_ext =
{
  floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
  floatformat_intbit_yes,
  "floatformat_i387_ext"
};
const struct floatformat floatformat_m68881_ext =
{

  floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64,
  floatformat_intbit_yes,
  "floatformat_m68881_ext"
};
const struct floatformat floatformat_i960_ext =
{

  floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64,
  floatformat_intbit_yes,
  "floatformat_i960_ext"
};
const struct floatformat floatformat_m88110_ext =
{
  floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
  floatformat_intbit_yes,
  "floatformat_m88110_ext"
};
const struct floatformat floatformat_m88110_harris_ext =
{


  floatformat_big,128, 0, 1, 11, 0x3ff, 0x7ff, 12, 52,
  floatformat_intbit_no,
  "floatformat_m88110_ext_harris"
};
const struct floatformat floatformat_arm_ext_big =
{

  floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
  floatformat_intbit_yes,
  "floatformat_arm_ext_big"
};
const struct floatformat floatformat_arm_ext_littlebyte_bigword =
{

  floatformat_littlebyte_bigword, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
  floatformat_intbit_yes,
  "floatformat_arm_ext_littlebyte_bigword"
};
const struct floatformat floatformat_ia64_spill_big =
{
  floatformat_big, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64,
  floatformat_intbit_yes,
  "floatformat_ia64_spill_big"
};
const struct floatformat floatformat_ia64_spill_little =
{
  floatformat_little, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64,
  floatformat_intbit_yes,
  "floatformat_ia64_spill_little"
};
const struct floatformat floatformat_ia64_quad_big =
{
  floatformat_big, 128, 0, 1, 15, 16383, 0x7fff, 16, 112,
  floatformat_intbit_no,
  "floatformat_ia64_quad_big"
};
const struct floatformat floatformat_ia64_quad_little =
{
  floatformat_little, 128, 0, 1, 15, 16383, 0x7fff, 16, 112,
  floatformat_intbit_no,
  "floatformat_ia64_quad_little"
};

static unsigned long get_field (unsigned char *, enum floatformat_byteorders, unsigned int, unsigned int, unsigned int);







static unsigned long
get_field (data, order, total_len, start, len)
     unsigned char *data;
     enum floatformat_byteorders order;
     unsigned int total_len;
     unsigned int start;
     unsigned int len;
{
  unsigned long result;
  unsigned int cur_byte;
  int cur_bitshift;


  cur_byte = (start + len) / 8;
  if (order == floatformat_little)
    cur_byte = (total_len / 8) - cur_byte - 1;
  cur_bitshift =
    ((start + len) % 8) - 8;
  result = *(data + cur_byte) >> (-cur_bitshift);
  cur_bitshift += 8;
  if (order == floatformat_little)
    ++cur_byte;
  else
    --cur_byte;


  while ((unsigned int) cur_bitshift < len)
    {
      if (len - cur_bitshift < 8)


        result |=
          (*(data + cur_byte) & ((1 << (len - cur_bitshift)) - 1))
            << cur_bitshift;
      else
        result |= *(data + cur_byte) << cur_bitshift;
      cur_bitshift += 8;
      if (order == floatformat_little)
        ++cur_byte;
      else
        --cur_byte;
    }
  return result;
}
# 206 "/tmp/fnf/src/gcc/libiberty/floatformat.c"
void
floatformat_to_double (fmt, from, to)
     const struct floatformat *fmt;
     char *from;
     double *to;
{
  unsigned char *ufrom = (unsigned char *)from;
  double dto;
  long exponent;
  unsigned long mant;
  unsigned int mant_bits, mant_off;
  int mant_bits_left;
  int special_exponent;

  exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize,
                        fmt->exp_start, fmt->exp_len);




  mant_bits_left = fmt->man_len;
  mant_off = fmt->man_start;
  dto = 0.0;

  special_exponent = exponent == 0 || (unsigned long) exponent == fmt->exp_nan;


  if (!special_exponent)
    exponent -= fmt->exp_bias;







  if (!special_exponent)
    {
      if (fmt->intbit == floatformat_intbit_no)
        dto = ldexp (1.0, exponent);
      else
        exponent++;
    }

  while (mant_bits_left > 0)
    {
      mant_bits = ((mant_bits_left) < (32) ? (mant_bits_left) : (32));

      mant = get_field (ufrom, fmt->byteorder, fmt->totalsize,
                         mant_off, mant_bits);

      dto += ldexp ((double)mant, exponent - mant_bits);
      exponent -= mant_bits;
      mant_off += mant_bits;
      mant_bits_left -= mant_bits;
    }


  if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1))
    dto = -dto;
  *to = dto;
}

static void put_field (unsigned char *, enum floatformat_byteorders, unsigned int, unsigned int, unsigned int, unsigned long);







static void
put_field (data, order, total_len, start, len, stuff_to_put)
     unsigned char *data;
     enum floatformat_byteorders order;
     unsigned int total_len;
     unsigned int start;
     unsigned int len;
     unsigned long stuff_to_put;
{
  unsigned int cur_byte;
  int cur_bitshift;


  cur_byte = (start + len) / 8;
  if (order == floatformat_little)
    cur_byte = (total_len / 8) - cur_byte - 1;
  cur_bitshift =
    ((start + len) % 8) - 8;
  *(data + cur_byte) &=
    ~(((1 << ((start + len) % 8)) - 1) << (-cur_bitshift));
  *(data + cur_byte) |=
    (stuff_to_put & ((1 << 8) - 1)) << (-cur_bitshift);
  cur_bitshift += 8;
  if (order == floatformat_little)
    ++cur_byte;
  else
    --cur_byte;


  while ((unsigned int) cur_bitshift < len)
    {
      if (len - cur_bitshift < 8)
        {

          *(data + cur_byte) &=
            ~((1 << (len - cur_bitshift)) - 1);
          *(data + cur_byte) |= (stuff_to_put >> cur_bitshift);
        }
      else
        *(data + cur_byte) = ((stuff_to_put >> cur_bitshift)
                              & ((1 << 8) - 1));
      cur_bitshift += 8;
      if (order == floatformat_little)
        ++cur_byte;
      else
        --cur_byte;
    }
}





void
floatformat_from_double (fmt, from, to)
     const struct floatformat *fmt;
     double *from;
     char *to;
{
  double dfrom;
  int exponent;
  double mant;
  unsigned int mant_bits, mant_off;
  int mant_bits_left;
  unsigned char *uto = (unsigned char *)to;

  memcpy (&dfrom, from, sizeof (dfrom));
  memset (uto, 0, fmt->totalsize / 8);
  if (dfrom == 0)
    return;
  if (dfrom != dfrom)
    {

      put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
                 fmt->exp_len, fmt->exp_nan);

      put_field (uto, fmt->byteorder, fmt->totalsize, fmt->man_start,
                 32, 1);
      return;
    }


  if (dfrom < 0)
    {
      put_field (uto, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1, 1);
      dfrom = -dfrom;
    }



  mant = frexp (dfrom, &exponent);
  put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, fmt->exp_len,
             exponent + fmt->exp_bias - 1);

  mant_bits_left = fmt->man_len;
  mant_off = fmt->man_start;
  while (mant_bits_left > 0)
    {
      unsigned long mant_long;
      mant_bits = mant_bits_left < 32 ? mant_bits_left : 32;

      mant *= 4294967296.0;
      mant_long = (unsigned long)mant;
      mant -= mant_long;





      if ((unsigned int) mant_bits_left == fmt->man_len
          && fmt->intbit == floatformat_intbit_no)
        {
          mant_long &= 0x7fffffff;
          mant_bits -= 1;
        }
      else if (mant_bits < 32)
        {


          mant_long >>= 32 - mant_bits;
        }

      put_field (uto, fmt->byteorder, fmt->totalsize,
                 mant_off, mant_bits, mant_long);
      mant_off += mant_bits;
      mant_bits_left -= mant_bits;
    }
}
-------------- end floatformat.i -------------

>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]