1231200Smm/* Floating point definitions for GDB.
2238856Smm
3231200Smm   Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4231200Smm   1996, 1997, 1998, 1999, 2000, 2001, 2003 Free Software Foundation,
5231200Smm   Inc.
6231200Smm
7231200Smm   This file is part of GDB.
8231200Smm
9231200Smm   This program is free software; you can redistribute it and/or modify
10231200Smm   it under the terms of the GNU General Public License as published by
11231200Smm   the Free Software Foundation; either version 2 of the License, or
12231200Smm   (at your option) any later version.
13231200Smm
14231200Smm   This program is distributed in the hope that it will be useful,
15231200Smm   but WITHOUT ANY WARRANTY; without even the implied warranty of
16231200Smm   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17231200Smm   GNU General Public License for more details.
18231200Smm
19231200Smm   You should have received a copy of the GNU General Public License
20231200Smm   along with this program; if not, write to the Free Software
21231200Smm   Foundation, Inc., 59 Temple Place - Suite 330,
22231200Smm   Boston, MA 02111-1307, USA.  */
23231200Smm
24231200Smm#ifndef DOUBLEST_H
25231200Smm#define DOUBLEST_H
26231200Smm
27231200Smmstruct type;
28231200Smm
29231200Smm/* Setup definitions for host and target floating point formats.  We need to
30231200Smm   consider the format for `float', `double', and `long double' for both target
31231200Smm   and host.  We need to do this so that we know what kind of conversions need
32231200Smm   to be done when converting target numbers to and from the hosts DOUBLEST
33231200Smm   data type.  */
34231200Smm
35231200Smm/* This is used to indicate that we don't know the format of the floating point
36231200Smm   number.  Typically, this is useful for native ports, where the actual format
37238856Smm   is irrelevant, since no conversions will be taking place.  */
38231200Smm
39231200Smm#include "floatformat.h"	/* For struct floatformat */
40231200Smm
41231200Smm/* Use `long double' if the host compiler supports it.  (Note that this is not
42231200Smm   necessarily any longer than `double'.  On SunOS/gcc, it's the same as
43231200Smm   double.)  This is necessary because GDB internally converts all floating
44231200Smm   point values to the widest type supported by the host.
45231200Smm
46231200Smm   There are problems however, when the target `long double' is longer than the
47231200Smm   host's `long double'.  In general, we'll probably reduce the precision of
48231200Smm   any such values and print a warning.  */
49231200Smm
50231200Smm#ifdef HAVE_LONG_DOUBLE
51231200Smmtypedef long double DOUBLEST;
52231200Smm#else
53231200Smmtypedef double DOUBLEST;
54231200Smm#endif
55231200Smm
56231200Smmextern void floatformat_to_doublest (const struct floatformat *,
57231200Smm				     const void *in, DOUBLEST *out);
58231200Smmextern void floatformat_from_doublest (const struct floatformat *,
59231200Smm				       const DOUBLEST *in, void *out);
60231200Smm
61231200Smmextern int floatformat_is_negative (const struct floatformat *, char *);
62231200Smmextern int floatformat_is_nan (const struct floatformat *, char *);
63231200Smmextern char *floatformat_mantissa (const struct floatformat *, char *);
64231200Smm
65231200Smm/* These functions have been replaced by extract_typed_floating and
66231200Smm   store_typed_floating.
67231200Smm
68231200Smm   Most calls are passing in TYPE_LENGTH (TYPE) so can be changed to
69231200Smm   just pass the TYPE.  The remainder pass in the length of a
70231200Smm   register, those calls should instead pass in the floating point
71231200Smm   type that corresponds to that length.  */
72231200Smm
73231200Smmextern DOUBLEST deprecated_extract_floating (const void *addr, int len);
74231200Smmextern void deprecated_store_floating (void *addr, int len, DOUBLEST val);
75231200Smm
76231200Smm/* Given TYPE, return its floatformat.  TYPE_FLOATFORMAT() may return
77231200Smm   NULL.  type_floatformat() detects that and returns a floatformat
78231200Smm   based on the type size when FLOATFORMAT is NULL.  */
79231200Smm
80231200Smmconst struct floatformat *floatformat_from_type (const struct type *type);
81231200Smm
82231200Smmextern DOUBLEST extract_typed_floating (const void *addr,
83231200Smm					const struct type *type);
84231200Smmextern void store_typed_floating (void *addr, const struct type *type,
85231200Smm				  DOUBLEST val);
86231200Smmextern void convert_typed_floating (const void *from,
87231200Smm				    const struct type *from_type,
88231200Smm                                    void *to, const struct type *to_type);
89231200Smm
90231200Smm#endif
91231200Smm