198944Sobrien/* Floating point definitions for GDB.
298944Sobrien
3130803Smarcel   Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4130803Smarcel   1996, 1997, 1998, 1999, 2000, 2001, 2003 Free Software Foundation,
5130803Smarcel   Inc.
6130803Smarcel
798944Sobrien   This file is part of GDB.
898944Sobrien
998944Sobrien   This program is free software; you can redistribute it and/or modify
1098944Sobrien   it under the terms of the GNU General Public License as published by
1198944Sobrien   the Free Software Foundation; either version 2 of the License, or
1298944Sobrien   (at your option) any later version.
1398944Sobrien
1498944Sobrien   This program is distributed in the hope that it will be useful,
1598944Sobrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
1698944Sobrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1798944Sobrien   GNU General Public License for more details.
1898944Sobrien
1998944Sobrien   You should have received a copy of the GNU General Public License
2098944Sobrien   along with this program; if not, write to the Free Software
2198944Sobrien   Foundation, Inc., 59 Temple Place - Suite 330,
2298944Sobrien   Boston, MA 02111-1307, USA.  */
2398944Sobrien
2498944Sobrien#ifndef DOUBLEST_H
2598944Sobrien#define DOUBLEST_H
2698944Sobrien
27130803Smarcelstruct type;
28130803Smarcel
2998944Sobrien/* Setup definitions for host and target floating point formats.  We need to
3098944Sobrien   consider the format for `float', `double', and `long double' for both target
3198944Sobrien   and host.  We need to do this so that we know what kind of conversions need
3298944Sobrien   to be done when converting target numbers to and from the hosts DOUBLEST
3398944Sobrien   data type.  */
3498944Sobrien
3598944Sobrien/* This is used to indicate that we don't know the format of the floating point
3698944Sobrien   number.  Typically, this is useful for native ports, where the actual format
3798944Sobrien   is irrelevant, since no conversions will be taking place.  */
3898944Sobrien
3998944Sobrien#include "floatformat.h"	/* For struct floatformat */
4098944Sobrien
4198944Sobrien/* Use `long double' if the host compiler supports it.  (Note that this is not
4298944Sobrien   necessarily any longer than `double'.  On SunOS/gcc, it's the same as
4398944Sobrien   double.)  This is necessary because GDB internally converts all floating
4498944Sobrien   point values to the widest type supported by the host.
4598944Sobrien
4698944Sobrien   There are problems however, when the target `long double' is longer than the
4798944Sobrien   host's `long double'.  In general, we'll probably reduce the precision of
4898944Sobrien   any such values and print a warning.  */
4998944Sobrien
5098944Sobrien#ifdef HAVE_LONG_DOUBLE
5198944Sobrientypedef long double DOUBLEST;
5298944Sobrien#else
5398944Sobrientypedef double DOUBLEST;
5498944Sobrien#endif
5598944Sobrien
5698944Sobrienextern void floatformat_to_doublest (const struct floatformat *,
5798944Sobrien				     const void *in, DOUBLEST *out);
5898944Sobrienextern void floatformat_from_doublest (const struct floatformat *,
5998944Sobrien				       const DOUBLEST *in, void *out);
6098944Sobrien
6198944Sobrienextern int floatformat_is_negative (const struct floatformat *, char *);
6298944Sobrienextern int floatformat_is_nan (const struct floatformat *, char *);
6398944Sobrienextern char *floatformat_mantissa (const struct floatformat *, char *);
6498944Sobrien
65130803Smarcel/* These functions have been replaced by extract_typed_floating and
66130803Smarcel   store_typed_floating.
6798944Sobrien
68130803Smarcel   Most calls are passing in TYPE_LENGTH (TYPE) so can be changed to
69130803Smarcel   just pass the TYPE.  The remainder pass in the length of a
70130803Smarcel   register, those calls should instead pass in the floating point
71130803Smarcel   type that corresponds to that length.  */
7298944Sobrien
73130803Smarcelextern DOUBLEST deprecated_extract_floating (const void *addr, int len);
74130803Smarcelextern void deprecated_store_floating (void *addr, int len, DOUBLEST val);
75130803Smarcel
7698944Sobrien/* Given TYPE, return its floatformat.  TYPE_FLOATFORMAT() may return
7798944Sobrien   NULL.  type_floatformat() detects that and returns a floatformat
7898944Sobrien   based on the type size when FLOATFORMAT is NULL.  */
7998944Sobrien
8098944Sobrienconst struct floatformat *floatformat_from_type (const struct type *type);
8198944Sobrien
8298944Sobrienextern DOUBLEST extract_typed_floating (const void *addr,
8398944Sobrien					const struct type *type);
8498944Sobrienextern void store_typed_floating (void *addr, const struct type *type,
8598944Sobrien				  DOUBLEST val);
8698944Sobrienextern void convert_typed_floating (const void *from,
8798944Sobrien				    const struct type *from_type,
8898944Sobrien                                    void *to, const struct type *to_type);
8998944Sobrien
9098944Sobrien#endif
91