]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/doublest.h
Use std::vector in h8300-tdep.c
[thirdparty/binutils-gdb.git] / gdb / doublest.h
CommitLineData
d16aafd8 1/* Floating point definitions for GDB.
f1908289 2
61baf725 3 Copyright (C) 1986-2017 Free Software Foundation, Inc.
d16aafd8
AC
4
5 This file is part of GDB.
6
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
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
d16aafd8
AC
10 (at your option) any later version.
11
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.
16
17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
d16aafd8
AC
19
20#ifndef DOUBLEST_H
21#define DOUBLEST_H
22
da3331ec 23struct type;
5ef2d0aa 24struct floatformat;
da3331ec 25
d16aafd8
AC
26/* Use `long double' if the host compiler supports it. (Note that this is not
27 necessarily any longer than `double'. On SunOS/gcc, it's the same as
28 double.) This is necessary because GDB internally converts all floating
29 point values to the widest type supported by the host.
30
31 There are problems however, when the target `long double' is longer than the
32 host's `long double'. In general, we'll probably reduce the precision of
33 any such values and print a warning. */
34
a6205f53
DJ
35#if (defined HAVE_LONG_DOUBLE && defined PRINTF_HAS_LONG_DOUBLE \
36 && defined SCANF_HAS_LONG_DOUBLE)
d16aafd8 37typedef long double DOUBLEST;
689e4e2d
TJB
38# define DOUBLEST_PRINT_FORMAT "Lg"
39# define DOUBLEST_SCAN_FORMAT "Lg"
d16aafd8
AC
40#else
41typedef double DOUBLEST;
689e4e2d
TJB
42# define DOUBLEST_PRINT_FORMAT "g"
43# define DOUBLEST_SCAN_FORMAT "lg"
96c1eda2
AO
44/* If we can't scan or print long double, we don't want to use it
45 anywhere. */
46# undef HAVE_LONG_DOUBLE
a6205f53
DJ
47# undef PRINTF_HAS_LONG_DOUBLE
48# undef SCANF_HAS_LONG_DOUBLE
d16aafd8
AC
49#endif
50
20389057
DJ
51/* Different kinds of floatformat numbers recognized by
52 floatformat_classify. To avoid portability issues, we use local
53 values instead of the C99 macros (FP_NAN et cetera). */
54enum float_kind {
55 float_nan,
56 float_infinite,
57 float_zero,
58 float_normal,
59 float_subnormal
60};
61
d16aafd8 62extern void floatformat_to_doublest (const struct floatformat *,
64f6fcad 63 const void *in, DOUBLEST *out);
d16aafd8 64extern void floatformat_from_doublest (const struct floatformat *,
64f6fcad 65 const DOUBLEST *in, void *out);
d16aafd8 66
108d6ead
AC
67extern int floatformat_is_negative (const struct floatformat *,
68 const bfd_byte *);
20389057
DJ
69extern enum float_kind floatformat_classify (const struct floatformat *,
70 const bfd_byte *);
108d6ead
AC
71extern const char *floatformat_mantissa (const struct floatformat *,
72 const bfd_byte *);
d16aafd8 73
fdf0cbc2 74extern std::string floatformat_to_string (const struct floatformat *fmt,
16e812b2
UW
75 const gdb_byte *in,
76 const char *format = nullptr);
edd079d9
UW
77extern bool floatformat_from_string (const struct floatformat *fmt,
78 gdb_byte *out, const std::string &in);
fdf0cbc2 79
b79497cb
PA
80/* Return the floatformat's total size in host bytes. */
81
82extern size_t floatformat_totalsize_bytes (const struct floatformat *fmt);
83
96d2f608
AC
84extern DOUBLEST extract_typed_floating (const void *addr,
85 const struct type *type);
86extern void store_typed_floating (void *addr, const struct type *type,
87 DOUBLEST val);
43686d64
MK
88extern void convert_typed_floating (const void *from,
89 const struct type *from_type,
90 void *to, const struct type *to_type);
d16aafd8
AC
91
92#endif