[RFC patch] Add support for snan/qnan/nan/inf for VAX
Matt Thomas
matt@3am-software.com
Thu Apr 2 00:19:00 GMT 2009
When trying to pass the gcc testsuite, i found gas for vax had a big
problem with
recognizing NAN, QNAN, SNAN, and INF. The following fixes things so
that they are
properly dealt with. Anyone have a problem with the atof-generic.c
changes?
2009-04-01 Matt Thomas <matt@netbsd.org>
* atof-generic.c (atof_generic): recognize snan and qnan in
addition to nan and inf.
* atof-vax.c (flonum_gen2vax): deal properly with nan, snan, qnan,
and +Inf and -Inf codes.
Index: atof-generic.c
===================================================================
RCS file: /cvs/src/src/gas/atof-generic.c,v
retrieving revision 1.13
diff -u -r1.13 atof-generic.c
--- atof-generic.c 3 Jul 2007 11:01:02 -0000 1.13
+++ atof-generic.c 2 Apr 2009 00:15:08 -0000
@@ -121,6 +121,32 @@
switch (first_digit[0])
{
+ case 's':
+ case 'S':
+ if (!strncasecmp ("snan", first_digit, 4))
+ {
+ address_of_generic_floating_point_number->sign = 0;
+ address_of_generic_floating_point_number->exponent = 0;
+ address_of_generic_floating_point_number->leader =
+ address_of_generic_floating_point_number->low;
+ *address_of_string_pointer = first_digit + 4;
+ return 0;
+ }
+ break;
+
+ case 'q':
+ case 'Q':
+ if (!strncasecmp ("qnan", first_digit, 4))
+ {
+ address_of_generic_floating_point_number->sign = 0;
+ address_of_generic_floating_point_number->exponent = 0;
+ address_of_generic_floating_point_number->leader =
+ address_of_generic_floating_point_number->low;
+ *address_of_string_pointer = first_digit + 4;
+ return 0;
+ }
+ break;
+
case 'n':
case 'N':
if (!strncasecmp ("nan", first_digit, 3))
Index: config/atof-vax.c
===================================================================
RCS file: /cvs/src/src/gas/config/atof-vax.c,v
retrieving revision 1.12
diff -u -r1.12 atof-vax.c
--- config/atof-vax.c 17 Oct 2007 16:45:54 -0000 1.12
+++ config/atof-vax.c 2 Apr 2009 00:15:08 -0000
@@ -268,10 +268,27 @@
int exponent_skippage;
LITTLENUM_TYPE word1;
- /* JF: Deal with new Nan, +Inf and -Inf codes. */
if (f->sign != '-' && f->sign != '+')
{
- make_invalid_floating_point_number (words);
+ if (f->sign == 0)
+ {
+ /* All NaNs are 0. */
+ memset (words, 0x00, sizeof (LITTLENUM_TYPE) * precision);
+ }
+ else if (f->sign == 'P')
+ {
+ /* Positive Infinity. */
+ memset (words, 0xff, sizeof (LITTLENUM_TYPE) * precision);
+ words[0] &= 0x7fff;
+ }
+ else if (f->sign == 'N')
+ {
+ /* Negative Infinity. */
+ memset (words, 0x00, sizeof (LITTLENUM_TYPE) * precision);
+ words[0] = 0x0080;
+ }
+ else
+ make_invalid_floating_point_number (words);
return return_value;
}
More information about the Binutils
mailing list