1 --- gdtoa-hexnan.c.orig 2010-01-29 16:36:11.000000000 -0800
2 +++ gdtoa-hexnan.c 2010-01-29 16:40:59.000000000 -0800
3 @@ -30,7 +30,9 @@ THIS SOFTWARE.
4 * with " at " changed at "@" and " dot " changed to "."). */
12 L_shift(x, x1, i) ULong *x; ULong *x1; int i;
13 @@ -48,6 +50,7 @@ L_shift(ULong *x, ULong *x1, int i)
17 +#endif /* !__APPLE__ */
21 @@ -57,10 +60,21 @@ hexnan(sp, fpi, x0)
22 hexnan( CONST char **sp, FPI *fpi, ULong *x0)
28 +#else /* !__APPLE__ */
29 ULong c, h, *x, *x1, *xe;
30 +#endif /* __APPLE__ */
33 int havedig, hd0, i, nbits;
34 +#endif /* !__APPLE__ */
37 + if (sp == NULL || *sp == NULL || **sp != '(')
39 +#else /* !__APPLE__ */
43 @@ -70,7 +84,17 @@ hexnan( CONST char **sp, FPI *fpi, ULong
46 havedig = hd0 = i = 0;
47 +#endif /* __APPLE__ */
50 + if ((cp = strchr(s + 1, ')')) == NULL) {
55 + cp = alloca(len + 1);
57 +#else /* !__APPLE__ */
58 /* allow optional initial 0x or 0X */
59 while((c = *(CONST unsigned char*)(s+1)) && c <= ' ')
61 @@ -111,7 +135,12 @@ hexnan( CONST char **sp, FPI *fpi, ULong
65 +#endif /* __APPLE__ */
68 + strlcpy(cp, s + 1, len + 1);
70 +#else /* !__APPLE__ */
74 @@ -121,7 +150,17 @@ hexnan( CONST char **sp, FPI *fpi, ULong
77 *x = (*x << 4) | (h & 0xf);
78 +#endif /* __APPLE__ */
83 + if (nbits == 52) { /* double */
86 + x0[1] = u.bits.manh;
87 + x0[0] = u.bits.manl;
88 +#else /* !__APPLE__ */
92 @@ -132,12 +171,36 @@ hexnan( CONST char **sp, FPI *fpi, ULong
96 +#endif /* __APPLE__ */
99 + else if (nbits < 52) { /* float */
100 + union IEEEf2bits u;
102 + x0[0] = u.bits.man;
103 +#else /* !__APPLE__ */
105 /* truncate high-order word if necessary */
106 if ( (i = nbits & (ULbits-1)) !=0)
107 *xe &= ((ULong)0xffffffff) >> (ULbits - i);
108 +#endif /* __APPLE__ */
111 + else { /* long double */
112 + union IEEEl2bits u;
114 +#if defined(__ppc__) || defined(__ppc64__)
115 + x0[3] = (ULong)(u.bits.manh >> 44);
116 + x0[2] = (ULong)(u.bits.manh >> 12);
117 + x0[1] = ((ULong)u.bits.manh & 0xfff) << 20 | (ULong)(u.bits.manl >> 32);
118 + x0[0] = (ULong)u.bits.manl;
119 +#elif defined(__i386__) || defined(__x86_64__) || defined(__arm__)
120 + x0[1] = (ULong)u.bits.manh;
121 + x0[0] = (ULong)u.bits.manl;
123 +#error unsupported architecture
125 +#else /* !__APPLE__ */
126 for(x1 = xe;; --x1) {
129 @@ -145,6 +208,7 @@ hexnan( CONST char **sp, FPI *fpi, ULong
133 +#endif /* __APPLE__ */
135 return STRTOG_NaNbits;