1 --- _hdtoa.c.orig 2008-09-07 11:38:10.000000000 -0700
2 +++ _hdtoa.c 2008-09-07 12:49:47.000000000 -0700
3 @@ -55,7 +55,7 @@ roundup(char *s0, int ndigits)
12 @@ -126,12 +126,12 @@ __hdtoa(double d, const char *xdigs, int
13 static const int sigfigs = (DBL_MANT_DIG + 3) / 4;
22 - switch (fpclassify(d)) {
23 + switch (f = fpclassify(d)) {
25 *decpt = u.bits.exp - DBL_ADJ;
27 @@ -149,7 +149,7 @@ __hdtoa(double d, const char *xdigs, int
29 return (nrv_alloc(NANSTR, rve, sizeof(NANSTR) - 1));
32 + LIBC_ABORT("fpclassify returned %d", f);
35 /* FP_NORMAL or FP_SUBNORMAL */
36 @@ -210,6 +210,7 @@ __hdtoa(double d, const char *xdigs, int
41 #if (LDBL_MANT_DIG > DBL_MANT_DIG)
44 @@ -222,13 +223,18 @@ __hldtoa(long double e, const char *xdig
45 static const int sigfigs = (LDBL_MANT_DIG + 3) / 4;
50 +#ifdef LDBL_HEAD_TAIL_PAIR
53 +#endif /* LDBL_HEAD_TAIL_PAIR */
58 - switch (fpclassify(e)) {
59 + switch (f = fpclassify(e)) {
61 + case FP_SUPERNORMAL:
62 *decpt = u.bits.exp - LDBL_ADJ;
65 @@ -245,7 +251,7 @@ __hldtoa(long double e, const char *xdig
67 return (nrv_alloc(NANSTR, rve, sizeof(NANSTR) - 1));
70 + LIBC_ABORT("fpclassify returned %d", f);
73 /* FP_NORMAL or FP_SUBNORMAL */
74 @@ -270,6 +276,19 @@ __hldtoa(long double e, const char *xdig
76 for (s = s0 + bufsize - 1; s > s0 + sigfigs - 1; s--)
78 +#ifdef LDBL_HEAD_TAIL_PAIR
79 + *decpt -= _ldbl2array32dd(u, bits);
82 + for (; s > s0; s--) {
90 +#else /* LDBL_HEAD_TAIL_PAIR */
91 for (; s > s0 + sigfigs - (LDBL_MANL_SIZE / 4) - 1 && s > s0; s--) {
92 *s = u.bits.manl & 0xf;
94 @@ -278,6 +297,7 @@ __hldtoa(long double e, const char *xdig
95 *s = u.bits.manh & 0xf;
98 +#endif /* LDBL_HEAD_TAIL_PAIR */
101 * At this point, we have snarfed all the bits in the
102 @@ -285,7 +305,11 @@ __hldtoa(long double e, const char *xdig
103 * (partial) nibble, which is dealt with by the next
104 * statement. We also tack on the implicit normalization bit.
106 +#ifdef LDBL_HEAD_TAIL_PAIR
108 +#else /* LDBL_HEAD_TAIL_PAIR */
109 *s = u.bits.manh | (1U << ((LDBL_MANT_DIG - 1) % 4));
110 +#endif /* LDBL_HEAD_TAIL_PAIR */
112 /* If ndigits < 0, we are expected to auto-size the precision. */
114 @@ -317,3 +341,4 @@ __hldtoa(long double e, const char *xdig
117 #endif /* (LDBL_MANT_DIG == DBL_MANT_DIG) */
118 +#endif /* !LDBL_COMPAT */