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