From c9f0b43fe46f473e4de3494f95b11ffb3d5a42a8 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Mon, 23 Nov 2020 21:46:38 -0500 Subject: gmp-utils: Convert the read/write methods to using gdb::array_view This commit changes the interfaces of some of the methods declared in gmp-utils to take a gdb::array_view of gdb_byte instead of a (gdb_byte *, size) couple. This makes these methods' API probably more C++-idiomatic. * gmp-utils.h (gdb_mpz::read): Change buf and len parameters into one single gdb::array_view parameter. (gdb_mpz::write): Likewise. (gdb_mpq::read_fixed_point, gdb_mpq::write_fixed_point): Likewise. * gmp-utils.c (gdb_mpz::read): Change buf and len parameters into one single gdb::array_view parameter. Adjust implementation accordingly. (gdb_mpz::write): Likewise. (gdb_mpq::read_fixed_point, gdb_mpq::write_fixed_point): Likewise. * unittests/gmp-utils-selftests.c: Adapt following changes above. * valarith.c, valops.c, valprint.c, value.c: Likewise. --- gdb/valarith.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gdb/valarith.c') diff --git a/gdb/valarith.c b/gdb/valarith.c index f4497cd..7ab183c 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -908,10 +908,12 @@ fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) } gdb_mpq v1, v2, res; - v1.read_fixed_point (value_contents (arg1), TYPE_LENGTH (type1), + v1.read_fixed_point (gdb::make_array_view (value_contents (arg1), + TYPE_LENGTH (type1)), type_byte_order (type1), type1->is_unsigned (), fixed_point_scaling_factor (type1)); - v2.read_fixed_point (value_contents (arg2), TYPE_LENGTH (type2), + v2.read_fixed_point (gdb::make_array_view (value_contents (arg2), + TYPE_LENGTH (type2)), type_byte_order (type2), type2->is_unsigned (), fixed_point_scaling_factor (type2)); @@ -919,7 +921,8 @@ fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) do { \ val = allocate_value (type1); \ (RESULT).write_fixed_point \ - (value_contents_raw (val), TYPE_LENGTH (type1), \ + (gdb::make_array_view (value_contents_raw (val), \ + TYPE_LENGTH (type1)), \ type_byte_order (type1), type1->is_unsigned (), \ fixed_point_scaling_factor (type1)); \ } while (0) -- cgit v1.1