floatformat.h revision 33965
1/* IEEE floating point support declarations, for GDB, the GNU Debugger. 2 Copyright (C) 1991 Free Software Foundation, Inc. 3 4This file is part of GDB. 5 6This program is free software; you can redistribute it and/or modify 7it under the terms of the GNU General Public License as published by 8the Free Software Foundation; either version 2 of the License, or 9(at your option) any later version. 10 11This program is distributed in the hope that it will be useful, 12but WITHOUT ANY WARRANTY; without even the implied warranty of 13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14GNU General Public License for more details. 15 16You should have received a copy of the GNU General Public License 17along with this program; if not, write to the Free Software 18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 19 20#if !defined (FLOATFORMAT_H) 21#define FLOATFORMAT_H 1 22 23#include "ansidecl.h" 24 25/* A floatformat consists of a sign bit, an exponent and a mantissa. Once the 26 bytes are concatenated according to the byteorder flag, then each of those 27 fields is contiguous. We number the bits with 0 being the most significant 28 (i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field 29 contains with the *_start and *_len fields. */ 30 31enum floatformat_byteorders { floatformat_little, floatformat_big }; 32 33enum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no }; 34 35struct floatformat 36{ 37 enum floatformat_byteorders byteorder; 38 unsigned int totalsize; /* Total size of number in bits */ 39 40 /* Sign bit is always one bit long. 1 means negative, 0 means positive. */ 41 unsigned int sign_start; 42 43 unsigned int exp_start; 44 unsigned int exp_len; 45 /* Amount added to "true" exponent. 0x3fff for many IEEE extendeds. */ 46 unsigned int exp_bias; 47 /* Exponent value which indicates NaN. This is the actual value stored in 48 the float, not adjusted by the exp_bias. This usually consists of all 49 one bits. */ 50 unsigned int exp_nan; 51 52 unsigned int man_start; 53 unsigned int man_len; 54 55 /* Is the integer bit explicit or implicit? */ 56 enum floatformat_intbit intbit; 57}; 58 59/* floatformats for IEEE single and double, big and little endian. */ 60 61extern const struct floatformat floatformat_ieee_single_big; 62extern const struct floatformat floatformat_ieee_single_little; 63extern const struct floatformat floatformat_ieee_double_big; 64extern const struct floatformat floatformat_ieee_double_little; 65 66/* floatformats for various extendeds. */ 67 68extern const struct floatformat floatformat_i387_ext; 69extern const struct floatformat floatformat_m68881_ext; 70extern const struct floatformat floatformat_i960_ext; 71extern const struct floatformat floatformat_m88110_ext; 72extern const struct floatformat floatformat_arm_ext; 73 74/* Convert from FMT to a double. 75 FROM is the address of the extended float. 76 Store the double in *TO. */ 77 78extern void 79floatformat_to_double PARAMS ((const struct floatformat *, char *, double *)); 80 81/* The converse: convert the double *FROM to FMT 82 and store where TO points. */ 83 84extern void 85floatformat_from_double PARAMS ((const struct floatformat *, 86 double *, char *)); 87 88#endif /* defined (FLOATFORMAT_H) */ 89