source: project/release/4/endian-blob/tags/1.4/floatformat.h @ 26968

Last change on this file since 26968 was 26968, checked in by Ivan Raikov, 9 years ago

endian-blob release 1.4

File size: 5.2 KB
Line 
1/* IEEE floating point support declarations, for GDB, the GNU Debugger.
2   Copyright 1991, 1994, 1995, 1997, 2000, 2003, 2005
3   Free Software Foundation, Inc.
4
5This file is part of GDB.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
20
21#if !defined (FLOATFORMAT_H)
22#define FLOATFORMAT_H 1
23
24/* A floatformat consists of a sign bit, an exponent and a mantissa.  Once the
25   bytes are concatenated according to the byteorder flag, then each of those
26   fields is contiguous.  We number the bits with 0 being the most significant
27   (i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field
28   contains with the *_start and *_len fields.  */
29
30/* What is the order of the bytes?  */
31
32enum floatformat_byteorders {
33  /* Standard little endian byte order.
34     EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */
35  floatformat_little,
36
37  /* Standard big endian byte order.
38     EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */
39  floatformat_big,
40
41  /* Little endian byte order but big endian word order.
42     EX: 1.2345678e10 => e0 fe 06 42 00 00 80 c5 */
43  floatformat_littlebyte_bigword,
44
45  /* VAX byte order.  Little endian byte order with 16-bit words.  The
46     following example is an illustration of the byte order only; VAX
47     doesn't have a fully IEEE compliant floating-point format.
48     EX: 1.2345678e10 => 80 c5 00 00 06 42 e0 fe */
49  floatformat_vax
50};
51
52enum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no };
53
54struct floatformat
55{
56  enum floatformat_byteorders byteorder;
57  unsigned int totalsize;       /* Total size of number in bits */
58
59  /* Sign bit is always one bit long.  1 means negative, 0 means positive.  */
60  unsigned int sign_start;
61
62  unsigned int exp_start;
63  unsigned int exp_len;
64  /* Bias added to a "true" exponent to form the biased exponent.  It
65     is intentionally signed as, otherwize, -exp_bias can turn into a
66     very large number (e.g., given the exp_bias of 0x3fff and a 64
67     bit long, the equation (long)(1 - exp_bias) evaluates to
68     4294950914) instead of -16382).  */
69  int exp_bias;
70  /* Exponent value which indicates NaN.  This is the actual value stored in
71     the float, not adjusted by the exp_bias.  This usually consists of all
72     one bits.  */
73  unsigned int exp_nan;
74
75  unsigned int man_start;
76  unsigned int man_len;
77
78  /* Is the integer bit explicit or implicit?  */
79  enum floatformat_intbit intbit;
80
81  /* Internal name for debugging. */
82  const char *name;
83
84  /* Validator method.  */
85  int (*is_valid) (const struct floatformat *fmt, const void *from);
86};
87
88/* floatformats for IEEE single and double, big and little endian.  */
89
90extern const struct floatformat floatformat_ieee_single_big;
91extern const struct floatformat floatformat_ieee_single_little;
92extern const struct floatformat floatformat_ieee_double_big;
93extern const struct floatformat floatformat_ieee_double_little;
94
95/* floatformat for ARM IEEE double, little endian bytes and big endian words */
96
97extern const struct floatformat floatformat_ieee_double_littlebyte_bigword;
98
99/* floatformats for VAX.  */
100
101extern const struct floatformat floatformat_vax_f;
102extern const struct floatformat floatformat_vax_d;
103extern const struct floatformat floatformat_vax_g;
104
105/* floatformats for various extendeds.  */
106
107extern const struct floatformat floatformat_i387_ext;
108extern const struct floatformat floatformat_m68881_ext;
109extern const struct floatformat floatformat_i960_ext;
110extern const struct floatformat floatformat_m88110_ext;
111extern const struct floatformat floatformat_m88110_harris_ext;
112extern const struct floatformat floatformat_arm_ext_big;
113extern const struct floatformat floatformat_arm_ext_littlebyte_bigword;
114/* IA-64 Floating Point register spilt into memory.  */
115extern const struct floatformat floatformat_ia64_spill_big;
116extern const struct floatformat floatformat_ia64_spill_little;
117extern const struct floatformat floatformat_ia64_quad_big;
118extern const struct floatformat floatformat_ia64_quad_little;
119
120/* Convert from FMT to a double.
121   FROM is the address of the extended float.
122   Store the double in *TO.  */
123
124extern void
125floatformat_to_double (const struct floatformat *, const void *, double *);
126
127/* The converse: convert the double *FROM to FMT
128   and store where TO points.  */
129
130extern void
131double_to_floatformat (const struct floatformat *, const double *, void *);
132
133/* Return non-zero iff the data at FROM is a valid number in format FMT.  */
134
135extern int
136floatformat_is_valid (const struct floatformat *fmt, const void *from);
137
138
139extern unsigned long get_field (const unsigned char *,
140                                enum floatformat_byteorders,
141                                unsigned int,
142                                unsigned int,
143                                unsigned int);
144
145
146#endif  /* defined (FLOATFORMAT_H) */
Note: See TracBrowser for help on using the repository browser.