/[gnats]/gnats/libiberty/floatformat.c
ViewVC logotype

Diff of /gnats/libiberty/floatformat.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by jsm, Tue Oct 26 07:10:16 1999 UTC revision 1.3 by pdm, Mon Dec 10 23:03:26 2001 UTC
# Line 1  Line 1 
1  /* IEEE floating point support routines, for GDB, the GNU Debugger.  /* IEEE floating point support routines, for GDB, the GNU Debugger.
2     Copyright (C) 1991, 1994 Free Software Foundation, Inc.     Copyright (C) 1991, 1994, 1999, 2000 Free Software Foundation, Inc.
3    
4  This file is part of GDB.  This file is part of GDB.
5    
# Line 36  extern char *memset (); Line 36  extern char *memset ();
36  /* floatformats for IEEE single and double, big and little endian.  */  /* floatformats for IEEE single and double, big and little endian.  */
37  const struct floatformat floatformat_ieee_single_big =  const struct floatformat floatformat_ieee_single_big =
38  {  {
39    floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23, floatformat_intbit_no    floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23,
40      floatformat_intbit_no,
41      "floatformat_ieee_single_big"
42  };  };
43  const struct floatformat floatformat_ieee_single_little =  const struct floatformat floatformat_ieee_single_little =
44  {  {
45    floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23, floatformat_intbit_no    floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23,
46      floatformat_intbit_no,
47      "floatformat_ieee_single_little"
48  };  };
49  const struct floatformat floatformat_ieee_double_big =  const struct floatformat floatformat_ieee_double_big =
50  {  {
51    floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no    floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52,
52      floatformat_intbit_no,
53      "floatformat_ieee_double_big"
54  };  };
55  const struct floatformat floatformat_ieee_double_little =  const struct floatformat floatformat_ieee_double_little =
56  {  {
57    floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no    floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52,
58      floatformat_intbit_no,
59      "floatformat_ieee_double_little"
60  };  };
61    
62  /* floatformat for IEEE double, little endian byte order, with big endian word  /* floatformat for IEEE double, little endian byte order, with big endian word
# Line 56  const struct floatformat floatformat_iee Line 64  const struct floatformat floatformat_iee
64    
65  const struct floatformat floatformat_ieee_double_littlebyte_bigword =  const struct floatformat floatformat_ieee_double_littlebyte_bigword =
66  {  {
67    floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no    floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52,
68      floatformat_intbit_no,
69      "floatformat_ieee_double_little"
70  };  };
71    
72  const struct floatformat floatformat_i387_ext =  const struct floatformat floatformat_i387_ext =
73  {  {
74    floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,    floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
75    floatformat_intbit_yes    floatformat_intbit_yes,
76      "floatformat_i387_ext"
77  };  };
78  const struct floatformat floatformat_m68881_ext =  const struct floatformat floatformat_m68881_ext =
79  {  {
80    /* Note that the bits from 16 to 31 are unused.  */    /* Note that the bits from 16 to 31 are unused.  */
81    floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64, floatformat_intbit_yes    floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64,
82      floatformat_intbit_yes,
83      "floatformat_m68881_ext"
84  };  };
85  const struct floatformat floatformat_i960_ext =  const struct floatformat floatformat_i960_ext =
86  {  {
87    /* Note that the bits from 0 to 15 are unused.  */    /* Note that the bits from 0 to 15 are unused.  */
88    floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64,    floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64,
89    floatformat_intbit_yes    floatformat_intbit_yes,
90      "floatformat_i960_ext"
91  };  };
92  const struct floatformat floatformat_m88110_ext =  const struct floatformat floatformat_m88110_ext =
93  {  {
# Line 81  const struct floatformat floatformat_m88 Line 95  const struct floatformat floatformat_m88
95    /* Harris uses raw format 128 bytes long, but the number is just an ieee    /* Harris uses raw format 128 bytes long, but the number is just an ieee
96       double, and the last 64 bits are wasted. */       double, and the last 64 bits are wasted. */
97    floatformat_big,128, 0, 1, 11,  0x3ff,  0x7ff, 12, 52,    floatformat_big,128, 0, 1, 11,  0x3ff,  0x7ff, 12, 52,
98    floatformat_intbit_no    floatformat_intbit_no,
99      "floatformat_m88110_ext(harris)"
100  #else  #else
101    floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,    floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
102    floatformat_intbit_yes    floatformat_intbit_yes,
103      "floatformat_m88110_ext"
104  #endif /* HARRIS_FLOAT_FORMAT */  #endif /* HARRIS_FLOAT_FORMAT */
105  };  };
106  const struct floatformat floatformat_arm_ext =  const struct floatformat floatformat_arm_ext =
107  {  {
108    /* Bits 1 to 16 are unused.  */    /* Bits 1 to 16 are unused.  */
109    floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,    floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
110    floatformat_intbit_yes    floatformat_intbit_yes,
111      "floatformat_arm_ext"
112  };  };
113    
114  static unsigned long get_field PARAMS ((unsigned char *,  static unsigned long get_field PARAMS ((unsigned char *,
# Line 128  get_field (data, order, total_len, start Line 145  get_field (data, order, total_len, start
145      --cur_byte;      --cur_byte;
146    
147    /* Move towards the most significant part of the field.  */    /* Move towards the most significant part of the field.  */
148    while (cur_bitshift < len)    while ((unsigned int) cur_bitshift < len)
149      {      {
150        if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT)        if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT)
151          /* This is the last byte; zero out the bits which are not part of          /* This is the last byte; zero out the bits which are not part of
# Line 179  floatformat_to_double (fmt, from, to) Line 196  floatformat_to_double (fmt, from, to)
196    mant_off = fmt->man_start;    mant_off = fmt->man_start;
197    dto = 0.0;    dto = 0.0;
198    
199    special_exponent = exponent == 0 || exponent == fmt->exp_nan;    special_exponent = exponent == 0 || (unsigned long) exponent == fmt->exp_nan;
200    
201    /* Don't bias zero's, denorms or NaNs.  */    /* Don't bias zero's, denorms or NaNs.  */
202    if (!special_exponent)    if (!special_exponent)
# Line 255  put_field (data, order, total_len, start Line 272  put_field (data, order, total_len, start
272      --cur_byte;      --cur_byte;
273    
274    /* Move towards the most significant part of the field.  */    /* Move towards the most significant part of the field.  */
275    while (cur_bitshift < len)    while ((unsigned int) cur_bitshift < len)
276      {      {
277        if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT)        if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT)
278          {          {
# Line 335  floatformat_from_double (fmt, from, to) Line 352  floatformat_from_double (fmt, from, to)
352           If we are discarding a zero, we should be (but are not) creating           If we are discarding a zero, we should be (but are not) creating
353           a denormalized number which means adjusting the exponent           a denormalized number which means adjusting the exponent
354           (I think).  */           (I think).  */
355        if (mant_bits_left == fmt->man_len        if ((unsigned int) mant_bits_left == fmt->man_len
356            && fmt->intbit == floatformat_intbit_no)            && fmt->intbit == floatformat_intbit_no)
357          {          {
358            mant_long &= 0x7fffffff;            mant_long &= 0x7fffffff;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26