* doublest.h (store_floating, extract_floating): Add comment

indicating these functions are deprecated.
(extract_typed_floating, store_typed_floating): Declare.
* doublest.c: Include "gdbtypes.h".
(extract_typed_floating, store_typed_floating): Define.

* stabsread.c (define_symbol): Use store_typed_floating.
* valarith.c (value_binop): Ditto.
* values.c (unpack_long): Use extract_typed_floating.
(unpack_double): Ditto.
This commit is contained in:
Andrew Cagney 2001-09-24 17:16:53 +00:00
parent 2f8d8971c6
commit 96d2f608dc
6 changed files with 64 additions and 10 deletions

View file

@ -1,3 +1,16 @@
2001-09-24 Andrew Cagney <ac131313@redhat.com>
* doublest.h (store_floating, extract_floating): Add comment
indicating these functions are deprecated.
(extract_typed_floating, store_typed_floating): Declare.
* doublest.c: Include "gdbtypes.h".
(extract_typed_floating, store_typed_floating): Define.
* stabsread.c (define_symbol): Use store_typed_floating.
* valarith.c (value_binop): Ditto.
* values.c (unpack_long): Use extract_typed_floating.
(unpack_double): Ditto.
2001-09-24 Orjan Friberg <orjanf@axis.com> 2001-09-24 Orjan Friberg <orjanf@axis.com>
* cris-tdep.c (reg_mode_add_sub_cmp_and_or_move_op): Fetch operand1 * cris-tdep.c (reg_mode_add_sub_cmp_and_or_move_op): Fetch operand1

View file

@ -31,6 +31,7 @@
#include "floatformat.h" #include "floatformat.h"
#include "gdb_assert.h" #include "gdb_assert.h"
#include "gdb_string.h" #include "gdb_string.h"
#include "gdbtypes.h"
#include <math.h> /* ldexp */ #include <math.h> /* ldexp */
/* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not /* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not
@ -606,8 +607,12 @@ floatformat_from_doublest (const struct floatformat *fmt,
} }
/* Extract/store a floating-point number from a target-order /* Extract/store a target floating-point number from byte-stream at
byte-stream at ADDR. Returns the value as type DOUBLEST. */ ADDR to/from a DOUBLEST. The LEN is used to select between the
pre-defined target type FLOAT, DOUBLE or LONG_DOUBLE. These
functions are used when extract/store typed floating() find that
the ``struct type'' did not include a FLOATFORMAT (e.g. some symbol
table readers and XXX-language support modules). */
DOUBLEST DOUBLEST
extract_floating (const void *addr, int len) extract_floating (const void *addr, int len)
@ -652,3 +657,34 @@ store_floating (void *addr, int len, DOUBLEST val)
error ("Can't deal with a floating point number of %d bytes.", len); error ("Can't deal with a floating point number of %d bytes.", len);
} }
} }
/* Extract/store a floating-point number of format TYPE from a
target-ordered byte-stream at ADDR to/from an internal DOUBLEST
accroding to its TYPE_FORMAT(). When GDB reads in debug
information, it is sometimes only provided with the type name, its
length and the fact that it is a float (TYPE_FORMAT() is not set).
For such types, the old extract/store floating() functions are
used. */
DOUBLEST
extract_typed_floating (const void *addr, const struct type *type)
{
DOUBLEST retval;
gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
if (TYPE_FLOATFORMAT (type) == NULL)
retval = extract_floating (addr, TYPE_LENGTH (type));
else
floatformat_to_doublest (TYPE_FLOATFORMAT (type), addr, &retval);
return retval;
}
void
store_typed_floating (void *addr, const struct type *type, DOUBLEST val)
{
gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
memset (addr, 0, TYPE_LENGTH (type));
if (TYPE_FLOATFORMAT (type) == NULL)
store_floating (addr, TYPE_LENGTH (type), val);
else
floatformat_from_doublest (TYPE_FLOATFORMAT (type), &val, addr);
}

View file

@ -61,7 +61,13 @@ extern int floatformat_is_negative (const struct floatformat *, char *);
extern int floatformat_is_nan (const struct floatformat *, char *); extern int floatformat_is_nan (const struct floatformat *, char *);
extern char *floatformat_mantissa (const struct floatformat *, char *); extern char *floatformat_mantissa (const struct floatformat *, char *);
extern DOUBLEST extract_floating (const void *in, int); /* Use extract_typed_float() and store_typed_float(). */
extern void store_floating (void *, int, DOUBLEST); extern DOUBLEST extract_floating (const void *in, int); /* DEPRECATED */
extern void store_floating (void *, int, DOUBLEST); /* DEPRECATED */
extern DOUBLEST extract_typed_floating (const void *addr,
const struct type *type);
extern void store_typed_floating (void *addr, const struct type *type,
DOUBLEST val);
#endif #endif

View file

@ -1491,7 +1491,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
dbl_valu = (char *) dbl_valu = (char *)
obstack_alloc (&objfile->symbol_obstack, obstack_alloc (&objfile->symbol_obstack,
TYPE_LENGTH (SYMBOL_TYPE (sym))); TYPE_LENGTH (SYMBOL_TYPE (sym)));
store_floating (dbl_valu, TYPE_LENGTH (SYMBOL_TYPE (sym)), d); store_typed_floating (dbl_valu, SYMBOL_TYPE (sym), d);
SYMBOL_VALUE_BYTES (sym) = dbl_valu; SYMBOL_VALUE_BYTES (sym) = dbl_valu;
SYMBOL_CLASS (sym) = LOC_CONST_BYTES; SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
} }

View file

@ -763,8 +763,7 @@ value_binop (value_ptr arg1, value_ptr arg2, enum exp_opcode op)
else else
val = allocate_value (builtin_type_double); val = allocate_value (builtin_type_double);
store_floating (VALUE_CONTENTS_RAW (val), TYPE_LENGTH (VALUE_TYPE (val)), store_typed_floating (VALUE_CONTENTS_RAW (val), VALUE_TYPE (val), v);
v);
} }
else if (TYPE_CODE (type1) == TYPE_CODE_BOOL else if (TYPE_CODE (type1) == TYPE_CODE_BOOL
&& &&

View file

@ -645,7 +645,7 @@ unpack_long (struct type *type, char *valaddr)
return extract_signed_integer (valaddr, len); return extract_signed_integer (valaddr, len);
case TYPE_CODE_FLT: case TYPE_CODE_FLT:
return extract_floating (valaddr, len); return extract_typed_floating (valaddr, type);
case TYPE_CODE_PTR: case TYPE_CODE_PTR:
case TYPE_CODE_REF: case TYPE_CODE_REF:
@ -689,7 +689,7 @@ unpack_double (struct type *type, char *valaddr, int *invp)
return 1.234567891011121314; return 1.234567891011121314;
} }
#endif #endif
return extract_floating (valaddr, len); return extract_typed_floating (valaddr, type);
} }
else if (nosign) else if (nosign)
{ {
@ -1297,7 +1297,7 @@ value_from_double (struct type *type, DOUBLEST num)
if (code == TYPE_CODE_FLT) if (code == TYPE_CODE_FLT)
{ {
store_floating (VALUE_CONTENTS_RAW (val), len, num); store_typed_floating (VALUE_CONTENTS_RAW (val), base_type, num);
} }
else else
error ("Unexpected type encountered for floating constant."); error ("Unexpected type encountered for floating constant.");