floatformat.h revision 33965
133965Sjdp/* IEEE floating point support declarations, for GDB, the GNU Debugger. 233965Sjdp Copyright (C) 1991 Free Software Foundation, Inc. 333965Sjdp 433965SjdpThis file is part of GDB. 533965Sjdp 633965SjdpThis program is free software; you can redistribute it and/or modify 733965Sjdpit under the terms of the GNU General Public License as published by 833965Sjdpthe Free Software Foundation; either version 2 of the License, or 933965Sjdp(at your option) any later version. 1033965Sjdp 1133965SjdpThis program is distributed in the hope that it will be useful, 1233965Sjdpbut WITHOUT ANY WARRANTY; without even the implied warranty of 1333965SjdpMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1433965SjdpGNU General Public License for more details. 1533965Sjdp 1633965SjdpYou should have received a copy of the GNU General Public License 1733965Sjdpalong with this program; if not, write to the Free Software 1833965SjdpFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 1933965Sjdp 2033965Sjdp#if !defined (FLOATFORMAT_H) 2133965Sjdp#define FLOATFORMAT_H 1 2233965Sjdp 2333965Sjdp#include "ansidecl.h" 2433965Sjdp 2533965Sjdp/* A floatformat consists of a sign bit, an exponent and a mantissa. Once the 2633965Sjdp bytes are concatenated according to the byteorder flag, then each of those 2733965Sjdp fields is contiguous. We number the bits with 0 being the most significant 2833965Sjdp (i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field 2933965Sjdp contains with the *_start and *_len fields. */ 3033965Sjdp 3133965Sjdpenum floatformat_byteorders { floatformat_little, floatformat_big }; 3233965Sjdp 3333965Sjdpenum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no }; 3433965Sjdp 3533965Sjdpstruct floatformat 3633965Sjdp{ 3733965Sjdp enum floatformat_byteorders byteorder; 3833965Sjdp unsigned int totalsize; /* Total size of number in bits */ 3933965Sjdp 4033965Sjdp /* Sign bit is always one bit long. 1 means negative, 0 means positive. */ 4133965Sjdp unsigned int sign_start; 4233965Sjdp 4333965Sjdp unsigned int exp_start; 4433965Sjdp unsigned int exp_len; 4533965Sjdp /* Amount added to "true" exponent. 0x3fff for many IEEE extendeds. */ 4633965Sjdp unsigned int exp_bias; 4733965Sjdp /* Exponent value which indicates NaN. This is the actual value stored in 4833965Sjdp the float, not adjusted by the exp_bias. This usually consists of all 4933965Sjdp one bits. */ 5033965Sjdp unsigned int exp_nan; 5133965Sjdp 5233965Sjdp unsigned int man_start; 5333965Sjdp unsigned int man_len; 5433965Sjdp 5533965Sjdp /* Is the integer bit explicit or implicit? */ 5633965Sjdp enum floatformat_intbit intbit; 5733965Sjdp}; 5833965Sjdp 5933965Sjdp/* floatformats for IEEE single and double, big and little endian. */ 6033965Sjdp 6133965Sjdpextern const struct floatformat floatformat_ieee_single_big; 6233965Sjdpextern const struct floatformat floatformat_ieee_single_little; 6333965Sjdpextern const struct floatformat floatformat_ieee_double_big; 6433965Sjdpextern const struct floatformat floatformat_ieee_double_little; 6533965Sjdp 6633965Sjdp/* floatformats for various extendeds. */ 6733965Sjdp 6833965Sjdpextern const struct floatformat floatformat_i387_ext; 6933965Sjdpextern const struct floatformat floatformat_m68881_ext; 7033965Sjdpextern const struct floatformat floatformat_i960_ext; 7133965Sjdpextern const struct floatformat floatformat_m88110_ext; 7233965Sjdpextern const struct floatformat floatformat_arm_ext; 7333965Sjdp 7433965Sjdp/* Convert from FMT to a double. 7533965Sjdp FROM is the address of the extended float. 7633965Sjdp Store the double in *TO. */ 7733965Sjdp 7833965Sjdpextern void 7933965Sjdpfloatformat_to_double PARAMS ((const struct floatformat *, char *, double *)); 8033965Sjdp 8133965Sjdp/* The converse: convert the double *FROM to FMT 8233965Sjdp and store where TO points. */ 8333965Sjdp 8433965Sjdpextern void 8533965Sjdpfloatformat_from_double PARAMS ((const struct floatformat *, 8633965Sjdp double *, char *)); 8733965Sjdp 8833965Sjdp#endif /* defined (FLOATFORMAT_H) */ 89