]> git.saurik.com Git - apple/libc.git/blob - gdtoa/FreeBSD/_hdtoa.c.patch
Libc-498.1.1.tar.gz
[apple/libc.git] / gdtoa / FreeBSD / _hdtoa.c.patch
1 --- _hdtoa.c.orig 2006-08-14 16:12:46.000000000 -0700
2 +++ _hdtoa.c 2006-08-14 23:02:39.000000000 -0700
3 @@ -55,7 +55,7 @@
4 *s = 1;
5 return (1);
6 }
7 - ++*s;
8 + *s = 0;
9 }
10 ++*s;
11 return (0);
12 @@ -223,12 +223,17 @@
13 union IEEEl2bits u;
14 char *s, *s0;
15 int bufsize;
16 +#ifdef LDBL_HEAD_TAIL_PAIR
17 + uint32_t bits[4];
18 + int i, pos;
19 +#endif /* LDBL_HEAD_TAIL_PAIR */
20
21 u.e = e;
22 *sign = u.bits.sign;
23
24 switch (fpclassify(e)) {
25 case FP_NORMAL:
26 + case FP_SUPERNORMAL:
27 *decpt = u.bits.exp - LDBL_ADJ;
28 break;
29 case FP_ZERO:
30 @@ -270,6 +275,19 @@
31 */
32 for (s = s0 + bufsize - 1; s > s0 + sigfigs - 1; s--)
33 *s = 0;
34 +#ifdef LDBL_HEAD_TAIL_PAIR
35 + _ldbl2array32dd(u, bits);
36 + i = 0;
37 + pos = 8;
38 + for (; s > s0; s--) {
39 + *s = bits[i] & 0xf;
40 + bits[i] >>= 4;
41 + if (--pos <= 0) {
42 + i++;
43 + pos = 8;
44 + }
45 + }
46 +#else /* LDBL_HEAD_TAIL_PAIR */
47 for (; s > s0 + sigfigs - (LDBL_MANL_SIZE / 4) - 1 && s > s0; s--) {
48 *s = u.bits.manl & 0xf;
49 u.bits.manl >>= 4;
50 @@ -278,6 +296,7 @@
51 *s = u.bits.manh & 0xf;
52 u.bits.manh >>= 4;
53 }
54 +#endif /* LDBL_HEAD_TAIL_PAIR */
55
56 /*
57 * At this point, we have snarfed all the bits in the
58 @@ -285,7 +304,11 @@
59 * (partial) nibble, which is dealt with by the next
60 * statement. We also tack on the implicit normalization bit.
61 */
62 +#ifdef LDBL_HEAD_TAIL_PAIR
63 + *s = bits[i];
64 +#else /* LDBL_HEAD_TAIL_PAIR */
65 *s = u.bits.manh | (1U << ((LDBL_MANT_DIG - 1) % 4));
66 +#endif /* LDBL_HEAD_TAIL_PAIR */
67
68 /* If ndigits < 0, we are expected to auto-size the precision. */
69 if (ndigits < 0) {