diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-03-07 14:53:37 +0000 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-03-07 14:53:37 +0000 |
commit | 7584bb30cf380cff9cc3914b1b523c5a1a5b4302 (patch) | |
tree | 6a6bf77b40345eadf32c168a602575d5ab347fcd /gdb/guile | |
parent | 2c5ebf12393443eec1d666f613cbc70a6b72f49a (diff) | |
download | gdb-7584bb30cf380cff9cc3914b1b523c5a1a5b4302.zip gdb-7584bb30cf380cff9cc3914b1b523c5a1a5b4302.tar.gz gdb-7584bb30cf380cff9cc3914b1b523c5a1a5b4302.tar.bz2 |
gdb: Move value_from_host_double into value.c and make more use of it
The function value_from_host_double can be moved from f-lang.c into
value.c as a generally useful function, and then used more widely.
Tested on X86-64/GNU Linux with no regressions.
gdb/ChangeLog:
* f-lang.c (value_from_host_double): Moved to...
* value.c (value_from_host_double): ...here.
* value.h (value_from_host_double): Declare.
* guile/scm-math.c (vlscm_convert_typed_number): Use
value_from_host_double.
(vlscm_convert_number): Likewise.
* guile/scm-value.c (gdbscm_value_to_real): Likewise.
* python/py-value.c (convert_value_from_python): Likewise.
Diffstat (limited to 'gdb/guile')
-rw-r--r-- | gdb/guile/scm-math.c | 16 | ||||
-rw-r--r-- | gdb/guile/scm-value.c | 3 |
2 files changed, 3 insertions, 16 deletions
diff --git a/gdb/guile/scm-math.c b/gdb/guile/scm-math.c index a31a145..d351ed0 100644 --- a/gdb/guile/scm-math.c +++ b/gdb/guile/scm-math.c @@ -559,13 +559,7 @@ vlscm_convert_typed_number (const char *func_name, int obj_arg_pos, SCM obj, } } else if (TYPE_CODE (type) == TYPE_CODE_FLT) - { - struct value *value = allocate_value (type); - target_float_from_host_double (value_contents_raw (value), - value_type (value), - scm_to_double (obj)); - return value; - } + return value_from_host_double (type, scm_to_double (obj)); else { *except_scmp = gdbscm_make_type_error (func_name, obj_arg_pos, obj, @@ -645,13 +639,7 @@ vlscm_convert_number (const char *func_name, int obj_arg_pos, SCM obj, gdbscm_scm_to_ulongest (obj)); } else if (scm_is_real (obj)) - { - struct value *value = allocate_value (bt->builtin_double); - target_float_from_host_double (value_contents_raw (value), - value_type (value), - scm_to_double (obj)); - return value; - } + return value_from_host_double (bt->builtin_double, scm_to_double (obj)); *except_scmp = gdbscm_make_out_of_range_error (func_name, obj_arg_pos, obj, _("value not a number representable on the target")); diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 294e3e7..658924b 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -903,8 +903,7 @@ gdbscm_value_to_real (SCM self) if (is_floating_value (value)) { d = target_float_to_host_double (value_contents (value), type); - check = allocate_value (type); - target_float_from_host_double (value_contents_raw (check), type, d); + check = value_from_host_double (type, d); } else if (TYPE_UNSIGNED (type)) { |