]> git.saurik.com Git - apple/libc.git/blame - gdtoa/FreeBSD/_hdtoa.c.patch
Libc-391.5.22.tar.gz
[apple/libc.git] / gdtoa / FreeBSD / _hdtoa.c.patch
CommitLineData
31185420
A
1--- _hdtoa.c.orig 2006-01-31 15:21:41.000000000 -0800
2+++ _hdtoa.c 2006-01-31 23:37:12.000000000 -0800
3@@ -223,6 +223,10 @@
4 union IEEEl2bits u;
5 char *s, *s0;
6 int bufsize;
3d9156a7
A
7+#ifdef LDBL_HEAD_TAIL_PAIR
8+ uint32_t bits[4];
31185420 9+ int i, pos;
3d9156a7
A
10+#endif /* LDBL_HEAD_TAIL_PAIR */
11
12 u.e = e;
13 *sign = u.bits.sign;
31185420 14@@ -270,6 +274,19 @@
3d9156a7
A
15 */
16 for (s = s0 + bufsize - 1; s > s0 + sigfigs - 1; s--)
17 *s = 0;
18+#ifdef LDBL_HEAD_TAIL_PAIR
19+ _ldbl2array32dd(u, bits);
20+ i = 0;
21+ pos = 8;
22+ for (; s > s0; s--) {
23+ *s = bits[i] & 0xf;
24+ bits[i] >>= 4;
25+ if (--pos <= 0) {
26+ i++;
27+ pos = 8;
28+ }
29+ }
30+#else /* LDBL_HEAD_TAIL_PAIR */
31 for (; s > s0 + sigfigs - (LDBL_MANL_SIZE / 4) - 1 && s > s0; s--) {
32 *s = u.bits.manl & 0xf;
33 u.bits.manl >>= 4;
31185420 34@@ -278,6 +295,7 @@
3d9156a7
A
35 *s = u.bits.manh & 0xf;
36 u.bits.manh >>= 4;
37 }
38+#endif /* LDBL_HEAD_TAIL_PAIR */
39
40 /*
41 * At this point, we have snarfed all the bits in the
31185420
A
42@@ -285,7 +303,11 @@
43 * (partial) nibble, which is dealt with by the next
44 * statement. We also tack on the implicit normalization bit.
3d9156a7
A
45 */
46+#ifdef LDBL_HEAD_TAIL_PAIR
31185420 47+ *s = bits[i];
3d9156a7 48+#else /* LDBL_HEAD_TAIL_PAIR */
31185420 49 *s = u.bits.manh | (1U << ((LDBL_MANT_DIG - 1) % 4));
3d9156a7
A
50+#endif /* LDBL_HEAD_TAIL_PAIR */
51
52 /* If ndigits < 0, we are expected to auto-size the precision. */
53 if (ndigits < 0) {