]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/doublest.h
2003-04-09 Andrew Cagney <cagney@redhat.com>
[thirdparty/binutils-gdb.git] / gdb / doublest.h
CommitLineData
d16aafd8 1/* Floating point definitions for GDB.
f1908289
AC
2
3 Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4 1996, 1997, 1998, 1999, 2000, 2001, 2003 Free Software Foundation,
5 Inc.
d16aafd8
AC
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
23
24#ifndef DOUBLEST_H
25#define DOUBLEST_H
26
27/* Setup definitions for host and target floating point formats. We need to
28 consider the format for `float', `double', and `long double' for both target
29 and host. We need to do this so that we know what kind of conversions need
30 to be done when converting target numbers to and from the hosts DOUBLEST
31 data type. */
32
33/* This is used to indicate that we don't know the format of the floating point
34 number. Typically, this is useful for native ports, where the actual format
35 is irrelevant, since no conversions will be taking place. */
36
37#include "floatformat.h" /* For struct floatformat */
38
d16aafd8
AC
39/* Use `long double' if the host compiler supports it. (Note that this is not
40 necessarily any longer than `double'. On SunOS/gcc, it's the same as
41 double.) This is necessary because GDB internally converts all floating
42 point values to the widest type supported by the host.
43
44 There are problems however, when the target `long double' is longer than the
45 host's `long double'. In general, we'll probably reduce the precision of
46 any such values and print a warning. */
47
48#ifdef HAVE_LONG_DOUBLE
49typedef long double DOUBLEST;
50#else
51typedef double DOUBLEST;
52#endif
53
54extern void floatformat_to_doublest (const struct floatformat *,
64f6fcad 55 const void *in, DOUBLEST *out);
d16aafd8 56extern void floatformat_from_doublest (const struct floatformat *,
64f6fcad 57 const DOUBLEST *in, void *out);
d16aafd8
AC
58
59extern int floatformat_is_negative (const struct floatformat *, char *);
60extern int floatformat_is_nan (const struct floatformat *, char *);
61extern char *floatformat_mantissa (const struct floatformat *, char *);
62
f1908289
AC
63/* These functions have been replaced by extract_typed_floating and
64 store_typed_floating.
65
66 Most calls are passing in TYPE_LENGTH (TYPE) so can be changed to
67 just pass the TYPE. The remainder pass in the length of a
68 register, those calls should instead pass in the floating point
69 type that corresponds to that length. */
87ffba60 70
f1908289
AC
71extern DOUBLEST deprecated_extract_floating (const void *addr, int len);
72extern void deprecated_store_floating (void *addr, int len, DOUBLEST val);
96d2f608 73
c2f05ac9
AC
74/* Given TYPE, return its floatformat. TYPE_FLOATFORMAT() may return
75 NULL. type_floatformat() detects that and returns a floatformat
76 based on the type size when FLOATFORMAT is NULL. */
77
78const struct floatformat *floatformat_from_type (const struct type *type);
79
96d2f608
AC
80extern DOUBLEST extract_typed_floating (const void *addr,
81 const struct type *type);
82extern void store_typed_floating (void *addr, const struct type *type,
83 DOUBLEST val);
43686d64
MK
84extern void convert_typed_floating (const void *from,
85 const struct type *from_type,
86 void *to, const struct type *to_type);
d16aafd8
AC
87
88#endif