]> git.pld-linux.org Git - packages/gdb.git/blame - floatformat_ibm_long_double.patch
- updated to 7.6.2
[packages/gdb.git] / floatformat_ibm_long_double.patch
CommitLineData
99d067e5
JR
1https://sourceware.org/ml/gdb-patches/2013-08/msg00483.html
2
3diff --git a/include/floatformat.h b/include/floatformat.h
4index b595164..04db61a 100644
5--- a/include/floatformat.h
6+++ b/include/floatformat.h
7@@ -128,7 +128,8 @@ extern const struct floatformat floatformat_ia64_spill_little;
8 extern const struct floatformat floatformat_ia64_quad_big;
9 extern const struct floatformat floatformat_ia64_quad_little;
10 /* IBM long double (double+double). */
11-extern const struct floatformat floatformat_ibm_long_double;
12+extern const struct floatformat floatformat_ibm_long_double_big;
13+extern const struct floatformat floatformat_ibm_long_double_little;
14
15 /* Convert from FMT to a double.
16 FROM is the address of the extended float.
17diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
18index c58ab01..789fa05 100644
19--- a/libiberty/floatformat.c
20+++ b/libiberty/floatformat.c
21@@ -371,14 +371,23 @@ floatformat_ibm_long_double_is_valid (const struct floatformat *fmt,
22 }
23 }
24
25-const struct floatformat floatformat_ibm_long_double =
26+const struct floatformat floatformat_ibm_long_double_big =
27 {
28 floatformat_big, 128, 0, 1, 11, 1023, 2047, 12, 52,
29 floatformat_intbit_no,
30- "floatformat_ibm_long_double",
31+ "floatformat_ibm_long_double_big",
32 floatformat_ibm_long_double_is_valid,
33 &floatformat_ieee_double_big
34 };
35+
36+const struct floatformat floatformat_ibm_long_double_little =
37+{
38+ floatformat_little, 128, 0, 1, 11, 1023, 2047, 12, 52,
39+ floatformat_intbit_no,
40+ "floatformat_ibm_long_double_little",
41+ floatformat_ibm_long_double_is_valid,
42+ &floatformat_ieee_double_little
43+};
44 \f
45
46 #ifndef min
47--
481.7.1
49
50diff --git a/gdb/doublest.c b/gdb/doublest.c
51index 2e4c87e..85890b1 100644
52--- a/gdb/doublest.c
53+++ b/gdb/doublest.c
54@@ -190,7 +190,8 @@ convert_floatformat_to_doublest (const struct floatformat *fmt,
55 {
56 double dto;
57
58- floatformat_to_double (fmt, from, &dto);
59+ floatformat_to_double (fmt->split_half ? fmt->split_half : fmt,
60+ from, &dto);
61 *to = (DOUBLEST) dto;
62 return;
63 }
64@@ -514,6 +515,11 @@ floatformat_is_negative (const struct floatformat *fmt,
65 gdb_assert (fmt->totalsize
66 <= FLOATFORMAT_LARGEST_BYTES * FLOATFORMAT_CHAR_BIT);
67
68+ /* An IBM long double (a two element array of double) always takes the
69+ sign of the first double. */
70+ if (fmt->split_half)
71+ fmt = fmt->split_half;
72+
73 order = floatformat_normalize_byteorder (fmt, uval, newfrom);
74
75 if (order != fmt->byteorder)
76@@ -540,6 +546,13 @@ floatformat_classify (const struct floatformat *fmt,
77 gdb_assert (fmt->totalsize
78 <= FLOATFORMAT_LARGEST_BYTES * FLOATFORMAT_CHAR_BIT);
79
80+ /* An IBM long double (a two element array of double) can be classified
81+ by looking at the first double. inf and nan are specified as
82+ ignoring the second double. zero and subnormal will always have
83+ the second double 0.0 if the long double is correctly rounded. */
84+ if (fmt->split_half)
85+ fmt = fmt->split_half;
86+
87 order = floatformat_normalize_byteorder (fmt, uval, newfrom);
88
89 if (order != fmt->byteorder)
90@@ -622,6 +635,16 @@ floatformat_mantissa (const struct floatformat *fmt,
91 gdb_assert (fmt->totalsize
92 <= FLOATFORMAT_LARGEST_BYTES * FLOATFORMAT_CHAR_BIT);
93
94+ /* For IBM long double (a two element array of double), return the
95+ mantissa of the first double. The problem with returning the
96+ actual mantissa from both doubles is that there can be an
97+ arbitrary number of implied 0's or 1's between the mantissas
98+ of the first and second double. In any case, this function
99+ is only used for dumping out nans, and a nan is specified to
100+ ignore the value in the second double. */
101+ if (fmt->split_half)
102+ fmt = fmt->split_half;
103+
104 order = floatformat_normalize_byteorder (fmt, uval, newfrom);
105
106 if (order != fmt->byteorder)
107@@ -879,27 +902,3 @@ convert_typed_floating (const void *from, const struct type *from_type,
108 floatformat_from_doublest (to_fmt, &d, to);
109 }
110 }
111-
112-const struct floatformat *floatformat_ieee_single[BFD_ENDIAN_UNKNOWN];
113-const struct floatformat *floatformat_ieee_double[BFD_ENDIAN_UNKNOWN];
114-const struct floatformat *floatformat_ieee_quad[BFD_ENDIAN_UNKNOWN];
115-const struct floatformat *floatformat_arm_ext[BFD_ENDIAN_UNKNOWN];
116-const struct floatformat *floatformat_ia64_spill[BFD_ENDIAN_UNKNOWN];
117-
118-extern void _initialize_doublest (void);
119-
120-extern void
121-_initialize_doublest (void)
122-{
123- floatformat_ieee_single[BFD_ENDIAN_LITTLE] = &floatformat_ieee_single_little;
124- floatformat_ieee_single[BFD_ENDIAN_BIG] = &floatformat_ieee_single_big;
125- floatformat_ieee_double[BFD_ENDIAN_LITTLE] = &floatformat_ieee_double_little;
126- floatformat_ieee_double[BFD_ENDIAN_BIG] = &floatformat_ieee_double_big;
127- floatformat_arm_ext[BFD_ENDIAN_LITTLE]
128- = &floatformat_arm_ext_littlebyte_bigword;
129- floatformat_arm_ext[BFD_ENDIAN_BIG] = &floatformat_arm_ext_big;
130- floatformat_ia64_spill[BFD_ENDIAN_LITTLE] = &floatformat_ia64_spill_little;
131- floatformat_ia64_spill[BFD_ENDIAN_BIG] = &floatformat_ia64_spill_big;
132- floatformat_ieee_quad[BFD_ENDIAN_LITTLE] = &floatformat_ia64_quad_little;
133- floatformat_ieee_quad[BFD_ENDIAN_BIG] = &floatformat_ia64_quad_big;
134-}
135diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
136index d19c593..dd2ef96 100644
137--- a/gdb/gdbtypes.c
138+++ b/gdb/gdbtypes.c
139@@ -108,8 +108,8 @@ const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN] = {
140 &floatformat_vax_d
141 };
142 const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN] = {
143- &floatformat_ibm_long_double,
144- &floatformat_ibm_long_double
145+ &floatformat_ibm_long_double_big,
146+ &floatformat_ibm_long_double_little
147 };
148
149 /* Should opaque types be resolved? */
150--
1511.7.1
152
This page took 0.291499 seconds and 4 git commands to generate.