forked from Imagelibrary/binutils-gdb
* Makefile.in (dfp.o): Depend on expression.h, gdbtypes.h and value.h.
(valarith.o): Depend on dfp.h. (valops.o): Likewise. * dfp.c: Include expression.h, gdbtypes.h, value.h and dfp.h. (set_decnumber_context): New function. (decimal_check_errors): Likewise. (decimal_from_number): Likewise. (decimal_to_number): Likewise. (decimal_from_string): Use set_decnumber_context and decimal_check_errors. (decimal_from_integral): New function. (decimal_from_floating): Likewise. (decimal_to_double): Likewise. (promote_decimal): Likewise. (decimal_binop): Likewise. (decimal_is_zero): Likewise. (decimal_compare): Likewise. (decimal_convert): Likewise. * dfp.h (decimal_from_integral): New prototype. (decimal_from_floating): Likewise. (decimal_to_double): Likewise. (decimal_binop): Likewise. (decimal_is_zero): Likewise. (decimal_compare): Likewise. (decimal_convert): Likewise. * eval.c (evaluate_subexp_standard): Remove expect_type argument from call to value_from_decfloat. * valarith.c: Include dfp.h. (value_args_as_decimal): New function. (value_binop): Add if block to handle TYPE_CODE_DECFLOAT values. (value_logical_not): Likewise. (value_equal): Likewise. (value_less): Likewise. (value_pos): Likewise. (value_neg): Formatting fix. * valops.c: Include dfp.h. (value_cast): Add if block to handle TYPE_CODE_DECFLOAT values. * value.c (unpack_long): Add case to handle TYPE_CODE_DECFLOAT. (unpack_double): Add if block to handle TYPE_CODE_DECFLOAT. (value_from_decfloat): Remove expect_type argument. * value.h (value_from_decfloat): Update prototype.
This commit is contained in:
23
gdb/value.c
23
gdb/value.c
@@ -982,6 +982,7 @@ value_as_double (struct value *val)
|
||||
error (_("Invalid floating value found in program."));
|
||||
return foo;
|
||||
}
|
||||
|
||||
/* Extract a value as a C pointer. Does not deallocate the value.
|
||||
Note that val's type may not actually be a pointer; value_as_long
|
||||
handles all the cases. */
|
||||
@@ -1127,6 +1128,11 @@ unpack_long (struct type *type, const gdb_byte *valaddr)
|
||||
case TYPE_CODE_FLT:
|
||||
return extract_typed_floating (valaddr, type);
|
||||
|
||||
case TYPE_CODE_DECFLOAT:
|
||||
/* libdecnumber has a function to convert from decimal to integer, but
|
||||
it doesn't work when the decimal number has a fractional part. */
|
||||
return decimal_to_double (valaddr, len);
|
||||
|
||||
case TYPE_CODE_PTR:
|
||||
case TYPE_CODE_REF:
|
||||
/* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure
|
||||
@@ -1184,6 +1190,8 @@ unpack_double (struct type *type, const gdb_byte *valaddr, int *invp)
|
||||
|
||||
return extract_typed_floating (valaddr, type);
|
||||
}
|
||||
else if (code == TYPE_CODE_DECFLOAT)
|
||||
return decimal_to_double (valaddr, len);
|
||||
else if (nosign)
|
||||
{
|
||||
/* Unsigned -- be sure we compensate for signed LONGEST. */
|
||||
@@ -1643,23 +1651,12 @@ value_from_double (struct type *type, DOUBLEST num)
|
||||
}
|
||||
|
||||
struct value *
|
||||
value_from_decfloat (struct type *expect_type, struct type *type,
|
||||
gdb_byte decbytes[16])
|
||||
value_from_decfloat (struct type *type, const gdb_byte *dec)
|
||||
{
|
||||
struct value *val = allocate_value (type);
|
||||
int len = TYPE_LENGTH (type);
|
||||
|
||||
if (expect_type)
|
||||
{
|
||||
int expect_len = TYPE_LENGTH (expect_type);
|
||||
char decstr[MAX_DECIMAL_STRING];
|
||||
int real_len;
|
||||
memcpy (value_contents_raw (val), dec, TYPE_LENGTH (type));
|
||||
|
||||
decimal_to_string (decbytes, len, decstr);
|
||||
decimal_from_string (decbytes, expect_len, decstr);
|
||||
}
|
||||
|
||||
memcpy (value_contents_raw (val), decbytes, len);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user