X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Ftarget-float.c;h=d077ca2e8e888fd1554ddbbaf01dfdc54c3d76fc;hb=ea764154c27a11619ba764a4c92f395ba5007234;hp=83ef98ab8199f5e5d546446e65947f14cfd47053;hpb=7813437494ac39f3aef392d06ed5416e84fe386b;p=binutils-gdb.git diff --git a/gdb/target-float.c b/gdb/target-float.c index 83ef98ab819..d077ca2e8e8 100644 --- a/gdb/target-float.c +++ b/gdb/target-float.c @@ -1,6 +1,6 @@ /* Floating point routines for GDB, the GNU debugger. - Copyright (C) 2017-2020 Free Software Foundation, Inc. + Copyright (C) 2017-2022 Free Software Foundation, Inc. This file is part of GDB. @@ -189,9 +189,9 @@ get_field (const bfd_byte *data, enum floatformat_byteorders order, int excess = FLOATFORMAT_CHAR_BIT - (total_len % FLOATFORMAT_CHAR_BIT); cur_byte = (total_len / FLOATFORMAT_CHAR_BIT) - - ((start + len + excess) / FLOATFORMAT_CHAR_BIT); + - ((start + len + excess) / FLOATFORMAT_CHAR_BIT); cur_bitshift = ((start + len + excess) % FLOATFORMAT_CHAR_BIT) - - FLOATFORMAT_CHAR_BIT; + - FLOATFORMAT_CHAR_BIT; } else { @@ -249,9 +249,9 @@ put_field (unsigned char *data, enum floatformat_byteorders order, int excess = FLOATFORMAT_CHAR_BIT - (total_len % FLOATFORMAT_CHAR_BIT); cur_byte = (total_len / FLOATFORMAT_CHAR_BIT) - - ((start + len + excess) / FLOATFORMAT_CHAR_BIT); + - ((start + len + excess) / FLOATFORMAT_CHAR_BIT); cur_bitshift = ((start + len + excess) % FLOATFORMAT_CHAR_BIT) - - FLOATFORMAT_CHAR_BIT; + - FLOATFORMAT_CHAR_BIT; } else { @@ -481,7 +481,7 @@ floatformat_mantissa (const struct floatformat *fmt, floating-point number of format FMT. */ static std::string floatformat_printf_format (const struct floatformat *fmt, - const char *format, char length) + const char *format, char length) { std::string host_format; char conversion; @@ -508,7 +508,7 @@ floatformat_printf_format (const struct floatformat *fmt, else { /* Use the specified format, stripping out the conversion character - and length modifier, if present. */ + and length modifier, if present. */ size_t len = strlen (format); gdb_assert (len > 1); conversion = format[--len]; @@ -878,23 +878,23 @@ host_float_ops::to_target (const struct floatformat *fmt, mant -= mant_long; /* If the integer bit is implicit, then we need to discard it. - If we are discarding a zero, we should be (but are not) creating - a denormalized number which means adjusting the exponent - (I think). */ + If we are discarding a zero, we should be (but are not) creating + a denormalized number which means adjusting the exponent + (I think). */ if (mant_bits_left == fmt->man_len && fmt->intbit == floatformat_intbit_no) { mant_long <<= 1; mant_long &= 0xffffffffL; - /* If we are processing the top 32 mantissa bits of a doublest - so as to convert to a float value with implied integer bit, - we will only be putting 31 of those 32 bits into the - final value due to the discarding of the top bit. In the - case of a small float value where the number of mantissa - bits is less than 32, discarding the top bit does not alter - the number of bits we will be adding to the result. */ - if (mant_bits == 32) - mant_bits -= 1; + /* If we are processing the top 32 mantissa bits of a doublest + so as to convert to a float value with implied integer bit, + we will only be putting 31 of those 32 bits into the + final value due to the discarding of the top bit. In the + case of a small float value where the number of mantissa + bits is less than 32, discarding the top bit does not alter + the number of bits we will be adding to the result. */ + if (mant_bits == 32) + mant_bits -= 1; } if (mant_bits < 32) @@ -1191,7 +1191,7 @@ public: const gdb_byte *y, const struct type *type_y) const override; private: - /* Local wrapper class to handle mpfr_t initalization and cleanup. */ + /* Local wrapper class to handle mpfr_t initialization and cleanup. */ class gdb_mpfr { public: @@ -1456,23 +1456,23 @@ mpfr_float_ops::to_target (const struct floatformat *fmt, mpfr_sub_ui (tmp.val, tmp.val, mant_long, MPFR_RNDZ); /* If the integer bit is implicit, then we need to discard it. - If we are discarding a zero, we should be (but are not) creating - a denormalized number which means adjusting the exponent - (I think). */ + If we are discarding a zero, we should be (but are not) creating + a denormalized number which means adjusting the exponent + (I think). */ if (mant_bits_left == fmt->man_len && fmt->intbit == floatformat_intbit_no) { mant_long <<= 1; mant_long &= 0xffffffffL; - /* If we are processing the top 32 mantissa bits of a doublest - so as to convert to a float value with implied integer bit, - we will only be putting 31 of those 32 bits into the - final value due to the discarding of the top bit. In the - case of a small float value where the number of mantissa - bits is less than 32, discarding the top bit does not alter - the number of bits we will be adding to the result. */ - if (mant_bits == 32) - mant_bits -= 1; + /* If we are processing the top 32 mantissa bits of a doublest + so as to convert to a float value with implied integer bit, + we will only be putting 31 of those 32 bits into the + final value due to the discarding of the top bit. In the + case of a small float value where the number of mantissa + bits is less than 32, discarding the top bit does not alter + the number of bits we will be adding to the result. */ + if (mant_bits == 32) + mant_bits -= 1; } if (mant_bits < 32) @@ -1808,7 +1808,7 @@ decimal_check_errors (decContext *ctx) for computation to each size of decimal float. */ static void decimal_from_number (const decNumber *from, - gdb_byte *to, const struct type *type) + gdb_byte *to, const struct type *type) { gdb_byte dec[16]; @@ -1839,7 +1839,7 @@ decimal_from_number (const decNumber *from, appropriate representation for computation. */ static void decimal_to_number (const gdb_byte *addr, const struct type *type, - decNumber *to) + decNumber *to) { gdb_byte dec[16]; match_endianness (addr, type, dec); @@ -2032,7 +2032,7 @@ decimal_float_ops::from_ulongest (gdb_byte *addr, const struct type *type, /* Converts a decimal float of LEN bytes to a LONGEST. */ LONGEST decimal_float_ops::to_longest (const gdb_byte *addr, - const struct type *type) const + const struct type *type) const { /* libdecnumber has a function to convert from decimal to integer, but it doesn't work when the decimal number has a fractional part. */ @@ -2208,7 +2208,7 @@ get_target_float_ops_kind (const struct type *type) switch (type->code ()) { case TYPE_CODE_FLT: - { + { const struct floatformat *fmt = floatformat_from_type (type); /* Binary floating-point formats matching a host format. */ @@ -2234,7 +2234,7 @@ get_target_float_ops_kind (const struct type *type) } } -/* Return target_float_ops to peform operations for KIND. */ +/* Return target_float_ops to perform operations for KIND. */ static const target_float_ops * get_target_float_ops (enum target_float_ops_kind kind) { @@ -2243,29 +2243,29 @@ get_target_float_ops (enum target_float_ops_kind kind) /* If the type format matches one of the host floating-point types, use that type as intermediate format. */ case target_float_ops_kind::host_float: - { + { static host_float_ops host_float_ops_float; return &host_float_ops_float; } case target_float_ops_kind::host_double: - { + { static host_float_ops host_float_ops_double; return &host_float_ops_double; } case target_float_ops_kind::host_long_double: - { + { static host_float_ops host_float_ops_long_double; return &host_float_ops_long_double; } /* For binary floating-point formats that do not match any host format, - use mpfr_t as intermediate format to provide precise target-floating - point emulation. However, if the MPFR library is not available, - use the largest host floating-point type as intermediate format. */ + use mpfr_t as intermediate format to provide precise target-floating + point emulation. However, if the MPFR library is not available, + use the largest host floating-point type as intermediate format. */ case target_float_ops_kind::binary: - { + { #ifdef HAVE_LIBMPFR static mpfr_float_ops binary_float_ops; #else @@ -2451,11 +2451,11 @@ target_float_convert (const gdb_byte *from, const struct type *from_type, /* Convert between two different formats in the same category. */ if (!target_float_same_format_p (from_type, to_type)) - { - const target_float_ops *ops = get_target_float_ops (from_type, to_type); - ops->convert (from, from_type, to, to_type); - return; - } + { + const target_float_ops *ops = get_target_float_ops (from_type, to_type); + ops->convert (from, from_type, to, to_type); + return; + } /* The floating-point formats match, so we simply copy the data, ensuring possible padding bytes in the target buffer are zeroed out. */