summaryrefslogtreecommitdiff
path: root/gdb/valops.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-02-23 10:34:22 -0700
committerTom Tromey <tromey@adacore.com>2023-03-14 08:16:39 -0600
commit7607de943130608a0798a550581b15331d140825 (patch)
treecc6210f9401bd09698df64c6e4eadd6d731bb7e0 /gdb/valops.c
parent7aeae94f88791399ca4b50f850c36180de420e92 (diff)
downloadbinutils-gdb-7607de943130608a0798a550581b15331d140825.tar.gz
Add operators and methods to gdb_mpq
This adds some operators and methods to gdb_mpq, in preparation for making its implementation private. This only adds the operators currently needed by gdb. More could be added as necessary.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r--gdb/valops.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/gdb/valops.c b/gdb/valops.c
index e0936d45cb3..2cef24fc4c5 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -341,11 +341,7 @@ value_to_gdb_mpq (struct value *value)
gdb_mpq result;
if (is_floating_type (type))
- {
- double d = target_float_to_host_double (value->contents ().data (),
- type);
- mpq_set_d (result.val, d);
- }
+ result = target_float_to_host_double (value->contents ().data (), type);
else
{
gdb_assert (is_integral_type (type)
@@ -357,8 +353,7 @@ value_to_gdb_mpq (struct value *value)
result = vz;
if (is_fixed_point_type (type))
- mpq_mul (result.val, result.val,
- type->fixed_point_scaling_factor ().val);
+ result *= type->fixed_point_scaling_factor ();
}
return result;
@@ -386,7 +381,7 @@ value_cast_to_fixed_point (struct type *to_type, struct value *from_val)
/* Divide that value by the scaling factor to obtain the unscaled
value, first in rational form, and then in integer form. */
- mpq_div (vq.val, vq.val, to_type->fixed_point_scaling_factor ().val);
+ vq /= to_type->fixed_point_scaling_factor ();
gdb_mpz unscaled = vq.get_rounded ();
/* Finally, create the result value, and pack the unscaled value
@@ -559,7 +554,7 @@ value_cast (struct type *type, struct value *arg2)
struct value *v = value::allocate (to_type);
target_float_from_host_double (v->contents_raw ().data (),
- to_type, mpq_get_d (fp_val.val));
+ to_type, fp_val.as_double ());
return v;
}