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 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>
* cris-tdep.c (reg_mode_add_sub_cmp_and_or_move_op): Fetch operand1
#include "floatformat.h"
#include "gdb_assert.h"
#include "gdb_string.h"
+#include "gdbtypes.h"
#include <math.h> /* ldexp */
/* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not
}
\f
-/* Extract/store a floating-point number from a target-order
- byte-stream at ADDR. Returns the value as type DOUBLEST. */
+/* Extract/store a target floating-point number from byte-stream at
+ 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
extract_floating (const void *addr, int 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);
+}
extern int floatformat_is_nan (const struct floatformat *, char *);
extern char *floatformat_mantissa (const struct floatformat *, char *);
-extern DOUBLEST extract_floating (const void *in, int);
-extern void store_floating (void *, int, DOUBLEST);
+/* Use extract_typed_float() and store_typed_float(). */
+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
dbl_valu = (char *)
obstack_alloc (&objfile->symbol_obstack,
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_CLASS (sym) = LOC_CONST_BYTES;
}
else
val = allocate_value (builtin_type_double);
- store_floating (VALUE_CONTENTS_RAW (val), TYPE_LENGTH (VALUE_TYPE (val)),
- v);
+ store_typed_floating (VALUE_CONTENTS_RAW (val), VALUE_TYPE (val), v);
}
else if (TYPE_CODE (type1) == TYPE_CODE_BOOL
&&
return extract_signed_integer (valaddr, len);
case TYPE_CODE_FLT:
- return extract_floating (valaddr, len);
+ return extract_typed_floating (valaddr, type);
case TYPE_CODE_PTR:
case TYPE_CODE_REF:
return 1.234567891011121314;
}
#endif
- return extract_floating (valaddr, len);
+ return extract_typed_floating (valaddr, type);
}
else if (nosign)
{
if (code == TYPE_CODE_FLT)
{
- store_floating (VALUE_CONTENTS_RAW (val), len, num);
+ store_typed_floating (VALUE_CONTENTS_RAW (val), base_type, num);
}
else
error ("Unexpected type encountered for floating constant.");