This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bootstrap failure with mainstream sources
- To: egcs-bugs at cygnus dot com
- Subject: Bootstrap failure with mainstream sources
- From: Andreas Jaeger <aj at arthur dot rhein-neckar dot de>
- Date: Mon, 31 Aug 1998 20:40:03 +0200 (CEST)
I just tried to bootstrap the mainstream egcs sources (checked out at
13:00 UST, 08-31-98):
/mnt/cc/egcs/build-mainstream/gcc/xgcc -B/mnt/cc/egcs/build-mainstream/gcc/ -c -DHAVE_CONFIG_H -g -I. -I../../../egcs-cvs/libiberty/../include -fpic ../../../egcs-cvs/libiberty/floatformat.c -o pic/floatformat.o
../../../egcs-cvs/libiberty/floatformat.c: In function `floatformat_from_double':
../../../egcs-cvs/libiberty/floatformat.c:354: internal error--unrecognizable insn:
(insn 262 261 263 (set:DF (reg:DF 84)
(mem/u:DF (symbol_ref/u:SI ("*.LC0")))) -1 (nil)
(expr_list:REG_EQUAL (const_double:DF (mem/u:DF (symbol_ref/u:SI ("*.LC0"))) 0 0 1075806208)
(nil)))
../../egcs-cvs/gcc/toplev.c:1360: Internal compiler error in function fatal_insn
I used the following commands for bootstraping:
../egcs-cvs/configure --prefix=/opt/egcs --enable-shared --enable-threads \
--with-gnu-as --with-gnu-ld
make BOOT_CFLAGS='-O2' LIBCFLAGS='-g -O2' LIBCXXFLAGS='-g -O2 -fno-implicit-templates' bootstrap-lean
My system: i486, Linux 2.1.113, recent glibc 2.1 snapshot.
I'm appending the preprocessed floatformat.i.
Andreas
# 1 "../../../egcs-cvs/libiberty/floatformat.c"
# 1 "../../../egcs-cvs/libiberty/../include/floatformat.h" 1
# 1 "../../../egcs-cvs/libiberty/../include/ansidecl.h" 1
# 152 "../../../egcs-cvs/libiberty/../include/ansidecl.h"
# 23 "../../../egcs-cvs/libiberty/../include/floatformat.h" 2
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;
};
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_arm_ext;
extern void
floatformat_to_double (const struct floatformat *, char *, double *) ;
extern void
floatformat_from_double (const struct floatformat *,
double *, char *) ;
# 20 "../../../egcs-cvs/libiberty/floatformat.c" 2
# 1 "/usr/include/math.h" 1 3
# 1 "/usr/include/features.h" 1 3
# 134 "/usr/include/features.h" 3
# 188 "/usr/include/features.h" 3
# 1 "/usr/include/sys/cdefs.h" 1 3
# 1 "/usr/include/features.h" 1 3
# 273 "/usr/include/features.h" 3
# 22 "/usr/include/sys/cdefs.h" 2 3
# 66 "/usr/include/sys/cdefs.h" 3
# 98 "/usr/include/sys/cdefs.h" 3
# 242 "/usr/include/features.h" 2 3
# 1 "/usr/include/gnu/stubs.h" 1 3
# 270 "/usr/include/features.h" 2 3
# 27 "/usr/include/math.h" 2 3
# 1 "/usr/include/bits/huge_val.h" 1 3
# 68 "/usr/include/bits/huge_val.h" 3
# 33 "/usr/include/math.h" 2 3
# 1 "/usr/include/bits/mathcalls.h" 1 3
extern double acos (double __x) ; extern double __acos (double __x) ;
extern double asin (double __x) ; extern double __asin (double __x) ;
extern double atan (double __x) ; extern double __atan (double __x) ;
extern double atan2 (double __y, double __x) ; extern double __atan2 (double __y, double __x) ;
extern double cos (double __x) ; extern double __cos (double __x) ;
extern double sin (double __x) ; extern double __sin (double __x) ;
extern double tan (double __x) ; extern double __tan (double __x) ;
extern double cosh (double __x) ; extern double __cosh (double __x) ;
extern double sinh (double __x) ; extern double __sinh (double __x) ;
extern double tanh (double __x) ; extern double __tanh (double __x) ;
extern double acosh (double __x) ; extern double __acosh (double __x) ;
extern double asinh (double __x) ; extern double __asinh (double __x) ;
extern double atanh (double __x) ; extern double __atanh (double __x) ;
extern double exp (double __x) ; extern double __exp (double __x) ;
extern double frexp (double __x, int *__exponent) ; extern double __frexp (double __x, int *__exponent) ;
extern double ldexp (double __x, int __exponent) ; extern double __ldexp (double __x, int __exponent) ;
extern double log (double __x) ; extern double __log (double __x) ;
extern double log10 (double __x) ; extern double __log10 (double __x) ;
extern double modf (double __x, double *__iptr) ; extern double __modf (double __x, double *__iptr) ;
extern double expm1 (double __x) ; extern double __expm1 (double __x) ;
extern double log1p (double __x) ; extern double __log1p (double __x) ;
extern double logb (double __x) ; extern double __logb (double __x) ;
extern double pow (double __x, double __y) ; extern double __pow (double __x, double __y) ;
extern double sqrt (double __x) ; extern double __sqrt (double __x) ;
extern double hypot (double __x, double __y) ; extern double __hypot (double __x, double __y) ;
extern double cbrt (double __x) ; extern double __cbrt (double __x) ;
extern double ceil (double __x) ; extern double __ceil (double __x) ;
extern double fabs (double __x) __attribute__ ( (__const__) ); extern double __fabs (double __x) __attribute__ ( (__const__) ) ;
extern double floor (double __x) ; extern double __floor (double __x) ;
extern double fmod (double __x, double __y) ; extern double __fmod (double __x, double __y) ;
extern int isinf (double __value) __attribute__ ( (__const__) ); extern int __isinf (double __value) __attribute__ ( (__const__) ) ;
extern int finite (double __value) __attribute__ ( (__const__) ); extern int __finite (double __value) __attribute__ ( (__const__) ) ;
extern double infnan (int __error) __attribute__ ( (__const__) ); extern double __infnan (int __error) __attribute__ ( (__const__) ) ;
extern double drem (double __x, double __y) ; extern double __drem (double __x, double __y) ;
extern double significand (double __x) ; extern double __significand (double __x) ;
extern double copysign (double __x, double __y) __attribute__ ( (__const__) ); extern double __copysign (double __x, double __y) __attribute__ ( (__const__) ) ;
extern int isnan (double __value) __attribute__ ( (__const__) ); extern int __isnan (double __value) __attribute__ ( (__const__) ) ;
extern double j0 (double ) ; extern double __j0 (double ) ;
extern double j1 (double ) ; extern double __j1 (double ) ;
extern double jn (int, double ) ; extern double __jn (int, double ) ;
extern double y0 (double ) ; extern double __y0 (double ) ;
extern double y1 (double ) ; extern double __y1 (double ) ;
extern double yn (int, double ) ; extern double __yn (int, double ) ;
extern double erf (double ) ; extern double __erf (double ) ;
extern double erfc (double ) ; extern double __erfc (double ) ;
extern double lgamma (double ) ; extern double __lgamma (double ) ;
extern double tgamma (double ) ; extern double __tgamma (double ) ;
extern double gamma (double ) ; extern double __gamma (double ) ;
extern double gamma_r (double , int *) ; extern double __gamma_r (double , int *) ;
extern double lgamma_r (double , int *) ; extern double __lgamma_r (double , int *) ;
extern double rint (double __x) ; extern double __rint (double __x) ;
extern double nextafter (double __x, double __y) __attribute__ ( (__const__) ); extern double __nextafter (double __x, double __y) __attribute__ ( (__const__) ) ;
extern double remainder (double __x, double __y) ; extern double __remainder (double __x, double __y) ;
extern double scalb (double __x, double __n) ; extern double __scalb (double __x, double __n) ;
extern double scalbn (double __x, int __n) ; extern double __scalbn (double __x, int __n) ;
extern int ilogb (double __x) ; extern int __ilogb (double __x) ;
# 324 "/usr/include/bits/mathcalls.h" 3
# 61 "/usr/include/math.h" 2 3
# 1 "/usr/include/bits/mathcalls.h" 1 3
extern float acosf (float __x) ; extern float __acosf (float __x) ;
extern float asinf (float __x) ; extern float __asinf (float __x) ;
extern float atanf (float __x) ; extern float __atanf (float __x) ;
extern float atan2f (float __y, float __x) ; extern float __atan2f (float __y, float __x) ;
extern float cosf (float __x) ; extern float __cosf (float __x) ;
extern float sinf (float __x) ; extern float __sinf (float __x) ;
extern float tanf (float __x) ; extern float __tanf (float __x) ;
extern float coshf (float __x) ; extern float __coshf (float __x) ;
extern float sinhf (float __x) ; extern float __sinhf (float __x) ;
extern float tanhf (float __x) ; extern float __tanhf (float __x) ;
extern float acoshf (float __x) ; extern float __acoshf (float __x) ;
extern float asinhf (float __x) ; extern float __asinhf (float __x) ;
extern float atanhf (float __x) ; extern float __atanhf (float __x) ;
extern float expf (float __x) ; extern float __expf (float __x) ;
extern float frexpf (float __x, int *__exponent) ; extern float __frexpf (float __x, int *__exponent) ;
extern float ldexpf (float __x, int __exponent) ; extern float __ldexpf (float __x, int __exponent) ;
extern float logf (float __x) ; extern float __logf (float __x) ;
extern float log10f (float __x) ; extern float __log10f (float __x) ;
extern float modff (float __x, float *__iptr) ; extern float __modff (float __x, float *__iptr) ;
extern float expm1f (float __x) ; extern float __expm1f (float __x) ;
extern float log1pf (float __x) ; extern float __log1pf (float __x) ;
extern float logbf (float __x) ; extern float __logbf (float __x) ;
extern float powf (float __x, float __y) ; extern float __powf (float __x, float __y) ;
extern float sqrtf (float __x) ; extern float __sqrtf (float __x) ;
extern float hypotf (float __x, float __y) ; extern float __hypotf (float __x, float __y) ;
extern float cbrtf (float __x) ; extern float __cbrtf (float __x) ;
extern float ceilf (float __x) ; extern float __ceilf (float __x) ;
extern float fabsf (float __x) __attribute__ ( (__const__) ); extern float __fabsf (float __x) __attribute__ ( (__const__) ) ;
extern float floorf (float __x) ; extern float __floorf (float __x) ;
extern float fmodf (float __x, float __y) ; extern float __fmodf (float __x, float __y) ;
extern int isinff (float __value) __attribute__ ( (__const__) ); extern int __isinff (float __value) __attribute__ ( (__const__) ) ;
extern int finitef (float __value) __attribute__ ( (__const__) ); extern int __finitef (float __value) __attribute__ ( (__const__) ) ;
extern float infnanf (int __error) __attribute__ ( (__const__) ); extern float __infnanf (int __error) __attribute__ ( (__const__) ) ;
extern float dremf (float __x, float __y) ; extern float __dremf (float __x, float __y) ;
extern float significandf (float __x) ; extern float __significandf (float __x) ;
extern float copysignf (float __x, float __y) __attribute__ ( (__const__) ); extern float __copysignf (float __x, float __y) __attribute__ ( (__const__) ) ;
extern int isnanf (float __value) __attribute__ ( (__const__) ); extern int __isnanf (float __value) __attribute__ ( (__const__) ) ;
extern float j0f (float ) ; extern float __j0f (float ) ;
extern float j1f (float ) ; extern float __j1f (float ) ;
extern float jnf (int, float ) ; extern float __jnf (int, float ) ;
extern float y0f (float ) ; extern float __y0f (float ) ;
extern float y1f (float ) ; extern float __y1f (float ) ;
extern float ynf (int, float ) ; extern float __ynf (int, float ) ;
extern float erff (float ) ; extern float __erff (float ) ;
extern float erfcf (float ) ; extern float __erfcf (float ) ;
extern float lgammaf (float ) ; extern float __lgammaf (float ) ;
extern float tgammaf (float ) ; extern float __tgammaf (float ) ;
extern float gammaf (float ) ; extern float __gammaf (float ) ;
extern float gammaf_r (float , int *) ; extern float __gammaf_r (float , int *) ;
extern float lgammaf_r (float , int *) ; extern float __lgammaf_r (float , int *) ;
extern float rintf (float __x) ; extern float __rintf (float __x) ;
extern float nextafterf (float __x, float __y) __attribute__ ( (__const__) ); extern float __nextafterf (float __x, float __y) __attribute__ ( (__const__) ) ;
extern float remainderf (float __x, float __y) ; extern float __remainderf (float __x, float __y) ;
extern float scalbf (float __x, float __n) ; extern float __scalbf (float __x, float __n) ;
extern float scalbnf (float __x, int __n) ; extern float __scalbnf (float __x, int __n) ;
extern int ilogbf (float __x) ; extern int __ilogbf (float __x) ;
# 324 "/usr/include/bits/mathcalls.h" 3
# 80 "/usr/include/math.h" 2 3
# 1 "/usr/include/bits/mathcalls.h" 1 3
extern long double acosl (long double __x) ; extern long double __acosl (long double __x) ;
extern long double asinl (long double __x) ; extern long double __asinl (long double __x) ;
extern long double atanl (long double __x) ; extern long double __atanl (long double __x) ;
extern long double atan2l (long double __y, long double __x) ; extern long double __atan2l (long double __y, long double __x) ;
extern long double cosl (long double __x) ; extern long double __cosl (long double __x) ;
extern long double sinl (long double __x) ; extern long double __sinl (long double __x) ;
extern long double tanl (long double __x) ; extern long double __tanl (long double __x) ;
extern long double coshl (long double __x) ; extern long double __coshl (long double __x) ;
extern long double sinhl (long double __x) ; extern long double __sinhl (long double __x) ;
extern long double tanhl (long double __x) ; extern long double __tanhl (long double __x) ;
extern long double acoshl (long double __x) ; extern long double __acoshl (long double __x) ;
extern long double asinhl (long double __x) ; extern long double __asinhl (long double __x) ;
extern long double atanhl (long double __x) ; extern long double __atanhl (long double __x) ;
extern long double expl (long double __x) ; extern long double __expl (long double __x) ;
extern long double frexpl (long double __x, int *__exponent) ; extern long double __frexpl (long double __x, int *__exponent) ;
extern long double ldexpl (long double __x, int __exponent) ; extern long double __ldexpl (long double __x, int __exponent) ;
extern long double logl (long double __x) ; extern long double __logl (long double __x) ;
extern long double log10l (long double __x) ; extern long double __log10l (long double __x) ;
extern long double modfl (long double __x, long double *__iptr) ; extern long double __modfl (long double __x, long double *__iptr) ;
extern long double expm1l (long double __x) ; extern long double __expm1l (long double __x) ;
extern long double log1pl (long double __x) ; extern long double __log1pl (long double __x) ;
extern long double logbl (long double __x) ; extern long double __logbl (long double __x) ;
extern long double powl (long double __x, long double __y) ; extern long double __powl (long double __x, long double __y) ;
extern long double sqrtl (long double __x) ; extern long double __sqrtl (long double __x) ;
extern long double hypotl (long double __x, long double __y) ; extern long double __hypotl (long double __x, long double __y) ;
extern long double cbrtl (long double __x) ; extern long double __cbrtl (long double __x) ;
extern long double ceill (long double __x) ; extern long double __ceill (long double __x) ;
extern long double fabsl (long double __x) __attribute__ ( (__const__) ); extern long double __fabsl (long double __x) __attribute__ ( (__const__) ) ;
extern long double floorl (long double __x) ; extern long double __floorl (long double __x) ;
extern long double fmodl (long double __x, long double __y) ; extern long double __fmodl (long double __x, long double __y) ;
extern int isinfl (long double __value) __attribute__ ( (__const__) ); extern int __isinfl (long double __value) __attribute__ ( (__const__) ) ;
extern int finitel (long double __value) __attribute__ ( (__const__) ); extern int __finitel (long double __value) __attribute__ ( (__const__) ) ;
extern long double infnanl (int __error) __attribute__ ( (__const__) ); extern long double __infnanl (int __error) __attribute__ ( (__const__) ) ;
extern long double dreml (long double __x, long double __y) ; extern long double __dreml (long double __x, long double __y) ;
extern long double significandl (long double __x) ; extern long double __significandl (long double __x) ;
extern long double copysignl (long double __x, long double __y) __attribute__ ( (__const__) ); extern long double __copysignl (long double __x, long double __y) __attribute__ ( (__const__) ) ;
extern int isnanl (long double __value) __attribute__ ( (__const__) ); extern int __isnanl (long double __value) __attribute__ ( (__const__) ) ;
extern long double j0l (long double ) ; extern long double __j0l (long double ) ;
extern long double j1l (long double ) ; extern long double __j1l (long double ) ;
extern long double jnl (int, long double ) ; extern long double __jnl (int, long double ) ;
extern long double y0l (long double ) ; extern long double __y0l (long double ) ;
extern long double y1l (long double ) ; extern long double __y1l (long double ) ;
extern long double ynl (int, long double ) ; extern long double __ynl (int, long double ) ;
extern long double erfl (long double ) ; extern long double __erfl (long double ) ;
extern long double erfcl (long double ) ; extern long double __erfcl (long double ) ;
extern long double lgammal (long double ) ; extern long double __lgammal (long double ) ;
extern long double tgammal (long double ) ; extern long double __tgammal (long double ) ;
extern long double gammal (long double ) ; extern long double __gammal (long double ) ;
extern long double gammal_r (long double , int *) ; extern long double __gammal_r (long double , int *) ;
extern long double lgammal_r (long double , int *) ; extern long double __lgammal_r (long double , int *) ;
extern long double rintl (long double __x) ; extern long double __rintl (long double __x) ;
extern long double nextafterl (long double __x, long double __y) __attribute__ ( (__const__) ); extern long double __nextafterl (long double __x, long double __y) __attribute__ ( (__const__) ) ;
extern long double remainderl (long double __x, long double __y) ; extern long double __remainderl (long double __x, long double __y) ;
extern long double scalbl (long double __x, long double __n) ; extern long double __scalbl (long double __x, long double __n) ;
extern long double scalbnl (long double __x, int __n) ; extern long double __scalbnl (long double __x, int __n) ;
extern int ilogbl (long double __x) ; extern int __ilogbl (long double __x) ;
# 324 "/usr/include/bits/mathcalls.h" 3
# 97 "/usr/include/math.h" 2 3
extern int signgam;
# 199 "/usr/include/math.h" 3
typedef enum
{
_IEEE_ = -1,
_SVID_,
_XOPEN_,
_POSIX_,
_ISOC_
} _LIB_VERSION_TYPE;
extern _LIB_VERSION_TYPE _LIB_VERSION;
struct exception
{
int type;
char *name;
double arg1;
double arg2;
double retval;
};
extern int __matherr (struct exception *__exc) ;
extern int matherr (struct exception *__exc) ;
# 1 "/mnt/cc/egcs/build-mainstream/gcc/include/float.h" 1 3
union __convert_long_double {
unsigned __convert_long_double_i[4];
long double __convert_long_double_d;
};
# 258 "/usr/include/math.h" 2 3
# 268 "/usr/include/math.h" 3
# 305 "/usr/include/math.h" 3
# 369 "/usr/include/math.h" 3
# 21 "../../../egcs-cvs/libiberty/floatformat.c" 2
# 1 "/mnt/cc/egcs/build-mainstream/gcc/include/stddef.h" 1 3
# 61 "/mnt/cc/egcs/build-mainstream/gcc/include/stddef.h" 3
typedef int ptrdiff_t;
typedef unsigned int size_t;
typedef long int wchar_t;
typedef unsigned int wint_t;
# 317 "/mnt/cc/egcs/build-mainstream/gcc/include/stddef.h" 3
# 23 "../../../egcs-cvs/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);
const struct floatformat floatformat_ieee_single_big =
{
floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23, floatformat_intbit_no
};
const struct floatformat floatformat_ieee_single_little =
{
floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23, floatformat_intbit_no
};
const struct floatformat floatformat_ieee_double_big =
{
floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no
};
const struct floatformat floatformat_ieee_double_little =
{
floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no
};
const struct floatformat floatformat_ieee_double_littlebyte_bigword =
{
floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no
};
const struct floatformat floatformat_i387_ext =
{
floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
floatformat_intbit_yes
};
const struct floatformat floatformat_m68881_ext =
{
floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64, floatformat_intbit_yes
};
const struct floatformat floatformat_i960_ext =
{
floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64,
floatformat_intbit_yes
};
const struct floatformat floatformat_m88110_ext =
{
floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
floatformat_intbit_yes
};
const struct floatformat floatformat_arm_ext =
{
floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
floatformat_intbit_yes
};
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 (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;
}
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 || 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 (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 (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;
}
}
# 401 "../../../egcs-cvs/libiberty/floatformat.c"
--
Andreas Jaeger aj@arthur.rhein-neckar.de jaeger@informatik.uni-kl.de
for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de