Subversion Repositories Kolibri OS

Rev

Rev 5191 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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