Loading...
gdtoa/FreeBSD/_hdtoa.c.patch Libc-391 Libc-498
--- Libc/Libc-391/gdtoa/FreeBSD/_hdtoa.c.patch
+++ Libc/Libc-498/gdtoa/FreeBSD/_hdtoa.c.patch
@@ -1,86 +1,33 @@
---- _hdtoa.c.orig	2004-06-03 15:22:08.000000000 -0700
-+++ _hdtoa.c	2004-08-28 17:10:21.000000000 -0700
-@@ -32,6 +32,9 @@
- #include <limits.h>
- #include <math.h>
- #include <stdlib.h>
-+#ifdef LDBL_HEAD_TAIL_PAIR
-+#include <alloca.h>
-+#endif /* LDBL_HEAD_TAIL_PAIR */
- #include "fpmath.h"
- #include "gdtoaimp.h"
- 
-@@ -301,16 +304,31 @@
- 	int pos;
- 	int shift;	/* for subnormals, # of shifts required to normalize */
- 	int sigfigs;	/* number of significant hex figures in result */
+--- _hdtoa.c.orig	2006-08-14 16:12:46.000000000 -0700
++++ _hdtoa.c	2006-08-14 23:02:39.000000000 -0700
+@@ -55,7 +55,7 @@
+ 			*s = 1;
+ 			return (1);
+ 		}
+-		++*s;
++		*s = 0;
+ 	}
+ 	++*s;
+ 	return (0);
+@@ -223,12 +223,17 @@
+ 	union IEEEl2bits u;
+ 	char *s, *s0;
+ 	int bufsize;
 +#ifdef LDBL_HEAD_TAIL_PAIR
 +	uint32_t bits[4];
-+	int i;
++	int i, pos;
 +#endif /* LDBL_HEAD_TAIL_PAIR */
  
  	u.e = e;
  	*sign = u.bits.sign;
  
-+#ifdef LDBL_HEAD_TAIL_PAIR
-+	switch (__fpclassifyd(u.d[0])) {
-+#else /* LDBL_HEAD_TAIL_PAIR */
  	switch (fpclassify(e)) {
-+#endif /* LDBL_HEAD_TAIL_PAIR */
  	case FP_NORMAL:
-+#ifdef LDBL_HEAD_TAIL_PAIR
- 		sigfigs = (LDBL_MANT_DIG + 3) / 4;
- 		impnbit = 1 << ((LDBL_MANT_DIG - 1) % 4);
- 		*decpt = u.bits.exp - LDBL_BIAS + 1 -
- 		    ((LDBL_MANT_DIG - 1) % 4);
-+#else /* LDBL_HEAD_TAIL_PAIR */
-+		sigfigs = (LDBL_MANT_DIG + 3) / 4;
-+		impnbit = 1 << ((LDBL_MANT_DIG - 1) % 4);
-+		*decpt = u.bits.exp - LDBL_BIAS + 1 -
-+		    ((LDBL_MANT_DIG - 1) % 4);
-+#endif /* LDBL_HEAD_TAIL_PAIR */
++	case FP_SUPERNORMAL:
+ 		*decpt = u.bits.exp - LDBL_ADJ;
  		break;
  	case FP_ZERO:
- 		*decpt = 1;
-@@ -328,13 +346,26 @@
- 		/* Don't trust the normalization bit to be off. */
- 		u.bits.manh &= ~(~0ULL << (LDBL_MANH_SIZE - 1));
- #endif
-+#ifndef LDBL_HEAD_TAIL_PAIR
- 		if (u.bits.manh != 0) {
-+#endif /* LDBL_HEAD_TAIL_PAIR */
- #if LDBL_MANH_SIZE > 32
- 			pos = log2_64(u.bits.manh);
- #else
- 			pos = log2_32(u.bits.manh);
- #endif
- 			shift = LDBL_MANH_SIZE - LDBL_NBIT_ADJ - pos;
-+#ifdef LDBL_HEAD_TAIL_PAIR
-+		sigfigs = (3 + LDBL_MANT_DIG - LDBL_NBIT_ADJ - shift) / 4;
-+		// we use DBL_MIN_EXP below because the head double is
-+		// subnormal (and the tail double is zero)
-+		*decpt = DBL_MIN_EXP + LDBL_NBIT_ADJ;
-+		pos = (LDBL_MANT_DIG + 3) % 4;
-+		if (pos < shift)
-+			*decpt -= pos + ((shift - pos + 3) & ~(4 - 1));
-+		else
-+			*decpt -= shift;
-+#else /* LDBL_HEAD_TAIL_PAIR */
- 		} else {
- #if LDBL_MANL_SIZE > 32
- 			pos = log2_64(u.bits.manl);
-@@ -345,8 +376,9 @@
- 			    LDBL_NBIT_ADJ - pos;
- 		}
- 		sigfigs = (3 + LDBL_MANT_DIG - LDBL_NBIT_ADJ - shift) / 4;
--		*decpt = LDBL_MIN_EXP + LDBL_NBIT_ADJ -
-+		*decpt = DBL_MIN_EXP + LDBL_NBIT_ADJ -
- 		    ((shift + 3) & ~(4 - 1));
-+#endif /* LDBL_HEAD_TAIL_PAIR */
- 		impnbit = 0;
- 		break;
- 	case FP_INFINITE:
-@@ -381,6 +413,19 @@
+@@ -270,6 +275,19 @@
  	 */
  	for (s = s0 + bufsize - 1; s > s0 + sigfigs - 1; s--)
  		*s = 0;
@@ -100,7 +47,7 @@
  	for (; s > s0 + sigfigs - (LDBL_MANL_SIZE / 4) - 1 && s > s0; s--) {
  		*s = u.bits.manl & 0xf;
  		u.bits.manl >>= 4;
-@@ -389,6 +434,7 @@
+@@ -278,6 +296,7 @@
  		*s = u.bits.manh & 0xf;
  		u.bits.manh >>= 4;
  	}
@@ -108,14 +55,14 @@
  
  	/*
  	 * At this point, we have snarfed all the bits in the
-@@ -398,7 +444,11 @@
- 	 * in manl instead for small subnormals.  We also tack on the
- 	 * implicit normalization bit if appropriate.
+@@ -285,7 +304,11 @@
+ 	 * (partial) nibble, which is dealt with by the next
+ 	 * statement.  We also tack on the implicit normalization bit.
  	 */
 +#ifdef LDBL_HEAD_TAIL_PAIR
-+	*s = bits[i] | impnbit;
++	*s = bits[i];
 +#else /* LDBL_HEAD_TAIL_PAIR */
- 	*s = u.bits.manh | u.bits.manl | impnbit;
+ 	*s = u.bits.manh | (1U << ((LDBL_MANT_DIG - 1) % 4));
 +#endif /* LDBL_HEAD_TAIL_PAIR */
  
  	/* If ndigits < 0, we are expected to auto-size the precision. */