GDB (xrefs)
/tmp/gdb-7.10/gdb/doublest.h
Go to the documentation of this file.
1 /* Floating point definitions for GDB.
2 
3  Copyright (C) 1986-2015 Free Software Foundation, Inc.
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
9  the Free Software Foundation; either version 3 of the License, or
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
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 #ifndef DOUBLEST_H
21 #define DOUBLEST_H
22 
23 struct type;
24 struct floatformat;
25 
26 /* Setup definitions for host and target floating point formats. We need to
27  consider the format for `float', `double', and `long double' for both target
28  and host. We need to do this so that we know what kind of conversions need
29  to be done when converting target numbers to and from the hosts DOUBLEST
30  data type. */
31 
32 /* This is used to indicate that we don't know the format of the floating point
33  number. Typically, this is useful for native ports, where the actual format
34  is irrelevant, since no conversions will be taking place. */
35 
36 #include "floatformat.h" /* For struct floatformat */
37 
38 /* Use `long double' if the host compiler supports it. (Note that this is not
39  necessarily any longer than `double'. On SunOS/gcc, it's the same as
40  double.) This is necessary because GDB internally converts all floating
41  point values to the widest type supported by the host.
42 
43  There are problems however, when the target `long double' is longer than the
44  host's `long double'. In general, we'll probably reduce the precision of
45  any such values and print a warning. */
46 
47 #if (defined HAVE_LONG_DOUBLE && defined PRINTF_HAS_LONG_DOUBLE \
48  && defined SCANF_HAS_LONG_DOUBLE)
49 typedef long double DOUBLEST;
50 # define DOUBLEST_PRINT_FORMAT "Lg"
51 # define DOUBLEST_SCAN_FORMAT "Lg"
52 #else
53 typedef double DOUBLEST;
54 # define DOUBLEST_PRINT_FORMAT "g"
55 # define DOUBLEST_SCAN_FORMAT "lg"
56 /* If we can't scan or print long double, we don't want to use it
57  anywhere. */
58 # undef HAVE_LONG_DOUBLE
59 # undef PRINTF_HAS_LONG_DOUBLE
60 # undef SCANF_HAS_LONG_DOUBLE
61 #endif
62 
63 /* Different kinds of floatformat numbers recognized by
64  floatformat_classify. To avoid portability issues, we use local
65  values instead of the C99 macros (FP_NAN et cetera). */
66 enum float_kind {
72 };
73 
74 extern void floatformat_to_doublest (const struct floatformat *,
75  const void *in, DOUBLEST *out);
76 extern void floatformat_from_doublest (const struct floatformat *,
77  const DOUBLEST *in, void *out);
78 
79 extern int floatformat_is_negative (const struct floatformat *,
80  const bfd_byte *);
81 extern enum float_kind floatformat_classify (const struct floatformat *,
82  const bfd_byte *);
83 extern const char *floatformat_mantissa (const struct floatformat *,
84  const bfd_byte *);
85 
86 /* Given TYPE, return its floatformat. TYPE_FLOATFORMAT() may return
87  NULL. type_floatformat() detects that and returns a floatformat
88  based on the type size when FLOATFORMAT is NULL. */
89 
90 const struct floatformat *floatformat_from_type (const struct type *type);
91 
92 extern DOUBLEST extract_typed_floating (const void *addr,
93  const struct type *type);
94 extern void store_typed_floating (void *addr, const struct type *type,
95  DOUBLEST val);
96 extern void convert_typed_floating (const void *from,
97  const struct type *from_type,
98  void *to, const struct type *to_type);
99 
100 #endif
enum float_kind floatformat_classify(const struct floatformat *, const bfd_byte *)
Definition: doublest.c:532
float_kind
Definition: doublest.h:66
int * from
Definition: varobj.h:282
const struct floatformat * floatformat_from_type(const struct type *type)
Definition: doublest.c:802
double DOUBLEST
Definition: doublest.h:24
Definition: gdbtypes.h:749
int floatformat_is_negative(const struct floatformat *, const bfd_byte *)
Definition: doublest.c:506
void convert_typed_floating(const void *from, const struct type *from_type, void *to, const struct type *to_type)
Definition: doublest.c:862
void floatformat_to_doublest(const struct floatformat *, const void *in, DOUBLEST *out)
Definition: doublest.c:697
void store_typed_floating(void *addr, const struct type *type, DOUBLEST val)
Definition: doublest.c:830
void floatformat_from_doublest(const struct floatformat *, const DOUBLEST *in, void *out)
Definition: doublest.c:727
int int * to
Definition: varobj.h:282
DOUBLEST extract_typed_floating(const void *addr, const struct type *type)
Definition: doublest.c:817
const char * floatformat_mantissa(const struct floatformat *, const bfd_byte *)
Definition: doublest.c:619