GDB (API)
/home/stan/gdb/src/gdb/doublest.h
Go to the documentation of this file.
00001 /* Floating point definitions for GDB.
00002 
00003    Copyright (C) 1986-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #ifndef DOUBLEST_H
00021 #define DOUBLEST_H
00022 
00023 struct type;
00024 struct floatformat;
00025 
00026 /* Setup definitions for host and target floating point formats.  We need to
00027    consider the format for `float', `double', and `long double' for both target
00028    and host.  We need to do this so that we know what kind of conversions need
00029    to be done when converting target numbers to and from the hosts DOUBLEST
00030    data type.  */
00031 
00032 /* This is used to indicate that we don't know the format of the floating point
00033    number.  Typically, this is useful for native ports, where the actual format
00034    is irrelevant, since no conversions will be taking place.  */
00035 
00036 #include "floatformat.h"        /* For struct floatformat */
00037 
00038 /* Use `long double' if the host compiler supports it.  (Note that this is not
00039    necessarily any longer than `double'.  On SunOS/gcc, it's the same as
00040    double.)  This is necessary because GDB internally converts all floating
00041    point values to the widest type supported by the host.
00042 
00043    There are problems however, when the target `long double' is longer than the
00044    host's `long double'.  In general, we'll probably reduce the precision of
00045    any such values and print a warning.  */
00046 
00047 #if (defined HAVE_LONG_DOUBLE && defined PRINTF_HAS_LONG_DOUBLE \
00048      && defined SCANF_HAS_LONG_DOUBLE)
00049 typedef long double DOUBLEST;
00050 # define DOUBLEST_PRINT_FORMAT "Lg"
00051 # define DOUBLEST_SCAN_FORMAT "Lg"
00052 #else
00053 typedef double DOUBLEST;
00054 # define DOUBLEST_PRINT_FORMAT "g"
00055 # define DOUBLEST_SCAN_FORMAT "lg"
00056 /* If we can't scan or print long double, we don't want to use it
00057    anywhere.  */
00058 # undef HAVE_LONG_DOUBLE
00059 # undef PRINTF_HAS_LONG_DOUBLE
00060 # undef SCANF_HAS_LONG_DOUBLE
00061 #endif
00062 
00063 /* Different kinds of floatformat numbers recognized by
00064    floatformat_classify.  To avoid portability issues, we use local
00065    values instead of the C99 macros (FP_NAN et cetera).  */
00066 enum float_kind {
00067   float_nan,
00068   float_infinite,
00069   float_zero,
00070   float_normal,
00071   float_subnormal
00072 };
00073 
00074 extern void floatformat_to_doublest (const struct floatformat *,
00075                                      const void *in, DOUBLEST *out);
00076 extern void floatformat_from_doublest (const struct floatformat *,
00077                                        const DOUBLEST *in, void *out);
00078 
00079 extern int floatformat_is_negative (const struct floatformat *,
00080                                     const bfd_byte *);
00081 extern enum float_kind floatformat_classify (const struct floatformat *,
00082                                              const bfd_byte *);
00083 extern const char *floatformat_mantissa (const struct floatformat *,
00084                                          const bfd_byte *);
00085 
00086 /* Given TYPE, return its floatformat.  TYPE_FLOATFORMAT() may return
00087    NULL.  type_floatformat() detects that and returns a floatformat
00088    based on the type size when FLOATFORMAT is NULL.  */
00089 
00090 const struct floatformat *floatformat_from_type (const struct type *type);
00091 
00092 extern DOUBLEST extract_typed_floating (const void *addr,
00093                                         const struct type *type);
00094 extern void store_typed_floating (void *addr, const struct type *type,
00095                                   DOUBLEST val);
00096 extern void convert_typed_floating (const void *from,
00097                                     const struct type *from_type,
00098                                     void *to, const struct type *to_type);
00099 
00100 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines