1 https://sourceware.org/ml/gdb-patches/2013-08/msg00483.html
3 diff --git a/include/floatformat.h b/include/floatformat.h
4 index 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;
15 /* Convert from FMT to a double.
16 FROM is the address of the extended float.
17 diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
18 index 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,
25 -const struct floatformat floatformat_ibm_long_double =
26 +const struct floatformat floatformat_ibm_long_double_big =
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
36 +const struct floatformat floatformat_ibm_long_double_little =
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
50 diff --git a/gdb/doublest.c b/gdb/doublest.c
51 index 2e4c87e..85890b1 100644
54 @@ -190,7 +190,8 @@ convert_floatformat_to_doublest (const struct floatformat *fmt,
58 - floatformat_to_double (fmt, from, &dto);
59 + floatformat_to_double (fmt->split_half ? fmt->split_half : fmt,
64 @@ -514,6 +515,11 @@ floatformat_is_negative (const struct floatformat *fmt,
65 gdb_assert (fmt->totalsize
66 <= FLOATFORMAT_LARGEST_BYTES * FLOATFORMAT_CHAR_BIT);
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;
73 order = floatformat_normalize_byteorder (fmt, uval, newfrom);
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);
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;
87 order = floatformat_normalize_byteorder (fmt, uval, newfrom);
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);
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;
104 order = floatformat_normalize_byteorder (fmt, uval, newfrom);
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);
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];
118 -extern void _initialize_doublest (void);
121 -_initialize_doublest (void)
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;
135 diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
136 index d19c593..dd2ef96 100644
139 @@ -108,8 +108,8 @@ const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN] = {
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
149 /* Should opaque types be resolved? */