| 1 | /* Floating point definitions for GDB. |
| 2 | Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, |
| 3 | 1997, 1998, 1999, 2000, 2001 |
| 4 | Free Software Foundation, Inc. |
| 5 | |
| 6 | This file is part of GDB. |
| 7 | |
| 8 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation; either version 2 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program; if not, write to the Free Software |
| 20 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 21 | Boston, MA 02111-1307, USA. */ |
| 22 | |
| 23 | #ifndef DOUBLEST_H |
| 24 | #define DOUBLEST_H |
| 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 | extern const struct floatformat floatformat_unknown; |
| 39 | |
| 40 | /* Use `long double' if the host compiler supports it. (Note that this is not |
| 41 | necessarily any longer than `double'. On SunOS/gcc, it's the same as |
| 42 | double.) This is necessary because GDB internally converts all floating |
| 43 | point values to the widest type supported by the host. |
| 44 | |
| 45 | There are problems however, when the target `long double' is longer than the |
| 46 | host's `long double'. In general, we'll probably reduce the precision of |
| 47 | any such values and print a warning. */ |
| 48 | |
| 49 | #ifdef HAVE_LONG_DOUBLE |
| 50 | typedef long double DOUBLEST; |
| 51 | #else |
| 52 | typedef double DOUBLEST; |
| 53 | #endif |
| 54 | |
| 55 | extern void floatformat_to_doublest (const struct floatformat *, |
| 56 | const void *in, DOUBLEST *out); |
| 57 | extern void floatformat_from_doublest (const struct floatformat *, |
| 58 | const DOUBLEST *in, void *out); |
| 59 | |
| 60 | extern int floatformat_is_negative (const struct floatformat *, char *); |
| 61 | extern int floatformat_is_nan (const struct floatformat *, char *); |
| 62 | extern char *floatformat_mantissa (const struct floatformat *, char *); |
| 63 | |
| 64 | /* These two functions are deprecated in favour of |
| 65 | extract_typed_floating and store_typed_floating. See comments in |
| 66 | 'doublest.c' for details. */ |
| 67 | |
| 68 | extern DOUBLEST extract_floating (const void *addr, int len); |
| 69 | extern void store_floating (void *addr, int len, DOUBLEST val); |
| 70 | |
| 71 | /* Given TYPE, return its floatformat. TYPE_FLOATFORMAT() may return |
| 72 | NULL. type_floatformat() detects that and returns a floatformat |
| 73 | based on the type size when FLOATFORMAT is NULL. */ |
| 74 | |
| 75 | const struct floatformat *floatformat_from_type (const struct type *type); |
| 76 | |
| 77 | extern DOUBLEST extract_typed_floating (const void *addr, |
| 78 | const struct type *type); |
| 79 | extern void store_typed_floating (void *addr, const struct type *type, |
| 80 | DOUBLEST val); |
| 81 | extern void convert_typed_floating (const void *from, |
| 82 | const struct type *from_type, |
| 83 | void *to, const struct type *to_type); |
| 84 | |
| 85 | #endif |