1 /* Floating point routines for GDB, the GNU debugger.
3 Copyright (C) 2017 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include "floatformat.h"
25 #include "target-float.h"
28 /* Typed floating-point routines. These routines operate on floating-point
29 values in target format, represented by a byte buffer interpreted as a
30 "struct type", which may be either a binary or decimal floating-point
31 type (TYPE_CODE_FLT or TYPE_CODE_DECFLOAT). */
33 /* Return whether the byte-stream ADDR holds a valid value of
34 floating-point type TYPE. */
36 target_float_is_valid (const gdb_byte
*addr
, const struct type
*type
)
38 if (TYPE_CODE (type
) == TYPE_CODE_FLT
)
39 return floatformat_is_valid (floatformat_from_type (type
), addr
);
41 if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
)
44 gdb_assert_not_reached ("unexpected type code");
47 /* Return whether the byte-stream ADDR, interpreted as floating-point
48 type TYPE, is numerically equal to zero (of either sign). */
50 target_float_is_zero (const gdb_byte
*addr
, const struct type
*type
)
52 if (TYPE_CODE (type
) == TYPE_CODE_FLT
)
53 return (floatformat_classify (floatformat_from_type (type
), addr
)
56 if (TYPE_CODE (type
) == TYPE_CODE_DECFLOAT
)
57 return decimal_is_zero (addr
, TYPE_LENGTH (type
),
58 gdbarch_byte_order (get_type_arch (type
)));
60 gdb_assert_not_reached ("unexpected type code");
This page took 0.032255 seconds and 4 git commands to generate.