CVS commit: src/lib/libc/gdtoa

2021-06-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jun 15 10:56:52 UTC 2021

Modified Files:
src/lib/libc/gdtoa: hdtoa.c

Log Message:
PR/56247: Greg A. Woods: printf("%La", LDBL_MIN) dumps core
Don't write to ((char *)malloc(size))[-1];


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/gdtoa/hdtoa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/hdtoa.c
diff -u src/lib/libc/gdtoa/hdtoa.c:1.11 src/lib/libc/gdtoa/hdtoa.c:1.12
--- src/lib/libc/gdtoa/hdtoa.c:1.11	Sat Apr 11 16:48:53 2020
+++ src/lib/libc/gdtoa/hdtoa.c	Tue Jun 15 06:56:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: hdtoa.c,v 1.11 2020/04/11 20:48:53 christos Exp $	*/
+/*	$NetBSD: hdtoa.c,v 1.12 2021/06/15 10:56:52 christos Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2005 David Schultz 
@@ -30,7 +30,7 @@
 #if 0
 __FBSDID("$FreeBSD: src/lib/libc/gdtoa/_hdtoa.c,v 1.4 2007/01/03 04:57:58 das Exp $");
 #else
-__RCSID("$NetBSD: hdtoa.c,v 1.11 2020/04/11 20:48:53 christos Exp $");
+__RCSID("$NetBSD: hdtoa.c,v 1.12 2021/06/15 10:56:52 christos Exp $");
 #endif
 
 #include 
@@ -256,7 +256,7 @@ char *
 hldtoa(long double e, const char *xdigs, int ndigits, int *decpt, int *sign,
 char **rve)
 {
-	static const int sigfigs = (LDBL_MANT_DIG + 3) / 4;
+	static const int sigfigs = (LDBL_MANT_DIG + 3) / 4 + 1;
 	union ieee_ext_u u;
 	char *s, *s0;
 	size_t bufsize;



CVS commit: src/lib/libc/gdtoa

2021-05-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu May  6 16:15:33 UTC 2021

Modified Files:
src/lib/libc/gdtoa: dtoa.c gdtoa.c strtoIg.c strtod.c strtodg.c

Log Message:
PR/56148: Andreas Gustafsson: lib/libc/stdio/t_printf:snprintf_float test
randomly fails.
Add checks to all places where lshift is called because it can return NULL


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/gdtoa/dtoa.c
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/gdtoa/gdtoa.c
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/gdtoa/strtoIg.c
cvs rdiff -u -r1.17 -r1.18 src/lib/libc/gdtoa/strtod.c
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/gdtoa/strtodg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/dtoa.c
diff -u src/lib/libc/gdtoa/dtoa.c:1.10 src/lib/libc/gdtoa/dtoa.c:1.11
--- src/lib/libc/gdtoa/dtoa.c:1.10	Wed May 16 13:48:59 2012
+++ src/lib/libc/gdtoa/dtoa.c	Thu May  6 12:15:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: dtoa.c,v 1.10 2012/05/16 17:48:59 alnsn Exp $ */
+/* $NetBSD: dtoa.c,v 1.11 2021/05/06 16:15:33 christos Exp $ */
 
 /
 
@@ -787,6 +787,8 @@ dtoa
 	  }
 #endif
 	b = lshift(b, 1);
+	if (b == NULL)
+		return NULL;
 	j = cmp(b, S);
 #ifdef ROUND_BIASED
 	if (j >= 0)

Index: src/lib/libc/gdtoa/gdtoa.c
diff -u src/lib/libc/gdtoa/gdtoa.c:1.7 src/lib/libc/gdtoa/gdtoa.c:1.8
--- src/lib/libc/gdtoa/gdtoa.c:1.7	Wed Jul 31 22:27:43 2019
+++ src/lib/libc/gdtoa/gdtoa.c	Thu May  6 12:15:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: gdtoa.c,v 1.7 2019/08/01 02:27:43 riastradh Exp $ */
+/* $NetBSD: gdtoa.c,v 1.8 2021/05/06 16:15:33 christos Exp $ */
 
 /
 
@@ -601,10 +601,16 @@ gdtoa
 	 */
 	i = ((s5 ? hi0bits(S->x[S->wds-1]) : ULbits - 1) - s2 - 4) & kmask;
 	m2 += i;
-	if ((b2 += i) > 0)
+	if ((b2 += i) > 0) {
 		b = lshift(b, b2);
-	if ((s2 += i) > 0)
+		if (b == NULL)
+			return NULL;
+		}
+	if ((s2 += i) > 0) {
 		S = lshift(S, s2);
+		if (S == NULL)
+			return NULL;
+		}
 	if (k_check) {
 		if (cmp(b,S) < 0) {
 			k--;

Index: src/lib/libc/gdtoa/strtoIg.c
diff -u src/lib/libc/gdtoa/strtoIg.c:1.4 src/lib/libc/gdtoa/strtoIg.c:1.5
--- src/lib/libc/gdtoa/strtoIg.c:1.4	Wed Jul 31 22:27:43 2019
+++ src/lib/libc/gdtoa/strtoIg.c	Thu May  6 12:15:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: strtoIg.c,v 1.4 2019/08/01 02:27:43 riastradh Exp $ */
+/* $NetBSD: strtoIg.c,v 1.5 2021/05/06 16:15:33 christos Exp $ */
 
 /
 
@@ -119,6 +119,8 @@ strtoIg(CONST char *s00, char **se, CONS
 }
 			else {
 b1 = lshift(b1, 1);
+if (b1 == NULL)
+	return STRTOG_NoMemory;
 b1->x[0] |= 1;
 --e1;
 }

Index: src/lib/libc/gdtoa/strtod.c
diff -u src/lib/libc/gdtoa/strtod.c:1.17 src/lib/libc/gdtoa/strtod.c:1.18
--- src/lib/libc/gdtoa/strtod.c:1.17	Fri Sep 18 10:19:34 2020
+++ src/lib/libc/gdtoa/strtod.c	Thu May  6 12:15:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: strtod.c,v 1.17 2020/09/18 14:19:34 christos Exp $ */
+/* $NetBSD: strtod.c,v 1.18 2021/05/06 16:15:33 christos Exp $ */
 
 /
 
@@ -712,6 +712,8 @@ _int_strtod_l(CONST char *s00, char **se
 #endif
 		  {
 		  delta = lshift(delta,Log2P);
+		  if (delta == NULL)
+			goto ovfl;
 		  if (cmp(delta, bs) <= 0)
 			dval() = -0.5;
 		  }
@@ -804,6 +806,8 @@ _int_strtod_l(CONST char *s00, char **se
 break;
 }
 			delta = lshift(delta,Log2P);
+			if (delta == NULL)
+goto ovfl;
 			if (cmp(delta, bs) > 0)
 goto drop_down;
 			break;

Index: src/lib/libc/gdtoa/strtodg.c
diff -u src/lib/libc/gdtoa/strtodg.c:1.12 src/lib/libc/gdtoa/strtodg.c:1.13
--- src/lib/libc/gdtoa/strtodg.c:1.12	Fri Apr 19 06:41:53 2013
+++ src/lib/libc/gdtoa/strtodg.c	Thu May  6 12:15:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: strtodg.c,v 1.12 2013/04/19 10:41:53 joerg Exp $ */
+/* $NetBSD: strtodg.c,v 1.13 2021/05/06 16:15:33 christos Exp $ */
 
 /
 
@@ -248,8 +248,11 @@ rvOK
 }
 			}
 		}
-	else if (bdif < 0)
+	else if (bdif < 0) {
 		b = lshift(b, -bdif);
+		if (b == NULL)
+			return STRTOG_NoMemory;
+		}
 	if (e < fpi->emin) {
 		k = fpi->emin - e;
 		e = fpi->emin;
@@ -679,6 +682,8 @@ strtodg(CONST char *s00, char **se, CONS
 		j = rve - emin;
 		if (j > 0) {
 			rvb = lshift(rvb, j);
+			if (rvb == NULL)
+return STRTOG_NoMemory;
 			rvbits += j;
 			}
 		else if (j < 0) {
@@ -950,8 +955,11 @@ strtodg(CONST char *s00, char **se, CONS
 			return STRTOG_NoMemory;
 		if (abe < 0)
 			rshift(ab, -abe);
-		else if (abe > 0)
+		else if (abe > 0) {
 			ab = lshift(ab, abe);
+			if (ab == NULL)
+return STRTOG_NoMemory;
+			}
 		rvb0 = rvb;
 		if (asub) {
 			/* rv -= adj; */
@@ -1027,8 +1035,11 @@ strtodg(CONST char *s00, char **se, CONS
 		

CVS commit: src/lib/libc/gdtoa

2020-09-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 18 14:19:34 UTC 2020

Modified Files:
src/lib/libc/gdtoa: strtod.c

Log Message:
delint


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libc/gdtoa/strtod.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/strtod.c
diff -u src/lib/libc/gdtoa/strtod.c:1.16 src/lib/libc/gdtoa/strtod.c:1.17
--- src/lib/libc/gdtoa/strtod.c:1.16	Fri Sep 18 10:06:45 2020
+++ src/lib/libc/gdtoa/strtod.c	Fri Sep 18 10:19:34 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: strtod.c,v 1.16 2020/09/18 14:06:45 christos Exp $ */
+/* $NetBSD: strtod.c,v 1.17 2020/09/18 14:19:34 christos Exp $ */
 
 /
 
@@ -743,7 +743,7 @@ _int_strtod_l(CONST char *s00, char **se
 /* dval() = Rounding ? ceil() : floor(); */
 y = adj.d;
 if (y != adj.d) {
-	if (!((Rounding>>1) ^ dsign))
+	if (!(((unsigned int)Rounding>>1) ^ (unsigned int)dsign))
 		y++;
 	dval() = y;
 	}
@@ -976,7 +976,7 @@ _int_strtod_l(CONST char *s00, char **se
 #ifdef Avoid_Underflow
 			if (scale && y <= 2*P*Exp_msk1) {
 if (aadj <= 0x7fff) {
-	if ((z = aadj) <= 0)
+	if ((z = aadj) == 0)
 		z = 1;
 	aadj = z;
 	dval() = dsign ? aadj : -aadj;



CVS commit: src/lib/libc/gdtoa

2020-09-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 18 14:06:45 UTC 2020

Modified Files:
src/lib/libc/gdtoa: strtod.c

Log Message:
PR/55668: Martin Husemann: Disable optimization to avoid infinite loop.
Also bring in a few changes from the most recent gdtoa code (not relevant
to the bug).


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/gdtoa/strtod.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/strtod.c
diff -u src/lib/libc/gdtoa/strtod.c:1.15 src/lib/libc/gdtoa/strtod.c:1.16
--- src/lib/libc/gdtoa/strtod.c:1.15	Wed Jul 31 22:27:43 2019
+++ src/lib/libc/gdtoa/strtod.c	Fri Sep 18 10:06:45 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: strtod.c,v 1.15 2019/08/01 02:27:43 riastradh Exp $ */
+/* $NetBSD: strtod.c,v 1.16 2020/09/18 14:06:45 christos Exp $ */
 
 /
 
@@ -90,16 +90,16 @@ sulp
 	}
 #endif /*}*/
 
+#if __GNUC_PREREQ__(9, 3)
+__attribute__((__optimize__("O0")))
+#endif
 static double
 _int_strtod_l(CONST char *s00, char **se, locale_t loc)
 {
 #ifdef Avoid_Underflow
 	int scale;
 #endif
-#ifdef INFNAN_CHECK
-	int decpt;
-#endif
-	int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
+	int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, decpt, dsign,
 		 e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
 	CONST char *s, *s0, *s1;
 	double aadj;
@@ -133,10 +133,7 @@ _int_strtod_l(CONST char *s00, char **se
 #endif /*}}*/
 #endif /*}*/
 
-#ifdef INFNAN_CHECK
-	decpt = 0;
-#endif
-	sign = nz0 = nz = 0;
+	sign = nz0 = nz = decpt = 0;
 	dval() = 0.;
 	for(s = s00;;s++) switch(*s) {
 		case '-':
@@ -203,7 +200,7 @@ _int_strtod_l(CONST char *s00, char **se
 	for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
 		if (nd < 9)
 			y = 10*y + c - '0';
-		else if (nd < 16)
+		else if (nd < DBL_DIG + 2)
 			z = 10*z + c - '0';
 	nd0 = nd;
 #ifdef USE_LOCALE
@@ -217,9 +214,7 @@ _int_strtod_l(CONST char *s00, char **se
 	if (c == '.') {
 		c = *++s;
 #endif
-#ifdef INFNAN_CHECK
 		decpt = 1;
-#endif
 		if (!nd) {
 			for(; c == '0'; c = *++s)
 nz++;
@@ -239,11 +234,11 @@ _int_strtod_l(CONST char *s00, char **se
 for(i = 1; i < nz; i++)
 	if (nd++ < 9)
 		y *= 10;
-	else if (nd <= DBL_DIG + 1)
+	else if (nd <= DBL_DIG + 2)
 		z *= 10;
 if (nd++ < 9)
 	y = 10*y + c;
-else if (nd <= DBL_DIG + 1)
+else if (nd <= DBL_DIG + 2)
 	z = 10*z + c;
 nz = 0;
 }
@@ -344,7 +339,7 @@ _int_strtod_l(CONST char *s00, char **se
 
 	if (!nd0)
 		nd0 = nd;
-	k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;
+	k = nd < DBL_DIG + 2 ? nd : DBL_DIG + 2;
 	dval() = y;
 	if (k > 9) {
 #ifdef SET_INEXACT
@@ -555,6 +550,10 @@ _int_strtod_l(CONST char *s00, char **se
 if (!dval()) {
  undfl:
 	dval() = 0.;
+#ifdef Honor_FLT_ROUNDS
+	if (Rounding == 2)
+		word1() = 1;
+#endif
 	goto range_err;
 	}
 #ifndef Avoid_Underflow
@@ -977,7 +976,7 @@ _int_strtod_l(CONST char *s00, char **se
 #ifdef Avoid_Underflow
 			if (scale && y <= 2*P*Exp_msk1) {
 if (aadj <= 0x7fff) {
-	if ((z = aadj) == 0)
+	if ((z = aadj) <= 0)
 		z = 1;
 	aadj = z;
 	dval() = dsign ? aadj : -aadj;



CVS commit: src/lib/libc/gdtoa

2020-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr 11 20:48:53 UTC 2020

Modified Files:
src/lib/libc/gdtoa: hdtoa.c

Log Message:
fix tyop


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/gdtoa/hdtoa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/hdtoa.c
diff -u src/lib/libc/gdtoa/hdtoa.c:1.10 src/lib/libc/gdtoa/hdtoa.c:1.11
--- src/lib/libc/gdtoa/hdtoa.c:1.10	Sat Apr 11 16:28:28 2020
+++ src/lib/libc/gdtoa/hdtoa.c	Sat Apr 11 16:48:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hdtoa.c,v 1.10 2020/04/11 20:28:28 christos Exp $	*/
+/*	$NetBSD: hdtoa.c,v 1.11 2020/04/11 20:48:53 christos Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2005 David Schultz 
@@ -30,7 +30,7 @@
 #if 0
 __FBSDID("$FreeBSD: src/lib/libc/gdtoa/_hdtoa.c,v 1.4 2007/01/03 04:57:58 das Exp $");
 #else
-__RCSID("$NetBSD: hdtoa.c,v 1.10 2020/04/11 20:28:28 christos Exp $");
+__RCSID("$NetBSD: hdtoa.c,v 1.11 2020/04/11 20:48:53 christos Exp $");
 #endif
 
 #include 
@@ -348,7 +348,7 @@ hldtoa(long double e, const char *xdigs,
 	 * (partial) nibble, which is dealt with by the next
 	 * statement.  We also tack on the implicit normalization bit.
 	 */
-	*s = (u.extu_ext.ext_frach | (1U << ((LDBL_MANT_DIG - 1) % 4))) 0xf;
+	*s = (u.extu_ext.ext_frach | (1U << ((LDBL_MANT_DIG - 1) % 4))) & 0xf;
 
 	/* If ndigits < 0, we are expected to auto-size the precision. */
 	if (ndigits < 0) {



CVS commit: src/lib/libc/gdtoa

2020-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr 11 20:28:28 UTC 2020

Modified Files:
src/lib/libc/gdtoa: hdtoa.c

Log Message:
Via enh at google dot com in tech-userlevel. Fix handling of
EXT_FRAC{H,L}BITS (although we don't need to since we don't have them).


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/gdtoa/hdtoa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/hdtoa.c
diff -u src/lib/libc/gdtoa/hdtoa.c:1.9 src/lib/libc/gdtoa/hdtoa.c:1.10
--- src/lib/libc/gdtoa/hdtoa.c:1.9	Mon Jul  4 07:46:41 2011
+++ src/lib/libc/gdtoa/hdtoa.c	Sat Apr 11 16:28:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: hdtoa.c,v 1.9 2011/07/04 11:46:41 mrg Exp $	*/
+/*	$NetBSD: hdtoa.c,v 1.10 2020/04/11 20:28:28 christos Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2005 David Schultz 
@@ -30,7 +30,7 @@
 #if 0
 __FBSDID("$FreeBSD: src/lib/libc/gdtoa/_hdtoa.c,v 1.4 2007/01/03 04:57:58 das Exp $");
 #else
-__RCSID("$NetBSD: hdtoa.c,v 1.9 2011/07/04 11:46:41 mrg Exp $");
+__RCSID("$NetBSD: hdtoa.c,v 1.10 2020/04/11 20:28:28 christos Exp $");
 #endif
 
 #include 
@@ -310,23 +310,34 @@ hldtoa(long double e, const char *xdigs,
 	 */
 	for (s = s0 + bufsize - 1; s > s0 + sigfigs - 1; s--)
 		*s = 0;
-	for (; s > s0 + sigfigs - (EXT_FRACLBITS / 4) - 1 && s > s0; s--) {
+	for (; s > s0 + sigfigs -
+	(EXT_FRACLBITS / 4) - 1 && s > s0; s--) {
 		*s = u.extu_ext.ext_fracl & 0xf;
 		u.extu_ext.ext_fracl >>= 4;
 	}
 #ifdef EXT_FRACHMBITS
-	for (; s > s0; s--) {
+	for (; s > s0 + sigfigs - 
+	((EXT_FRACLBITS + EXT_FRACHMBITS) / 4) - 1; s--) {
 		*s = u.extu_ext.ext_frachm & 0xf;
 		u.extu_ext.ext_frachm >>= 4;
 	}
+#else
+#define EXT_FRACHMBITS 0
 #endif
+
 #ifdef EXT_FRACLMBITS
-	for (; s > s0; s--) {
+	for (; s > s0 + sigfigs -
+	((EXT_FRACLBITS + EXT_FRACHMBITS + EXT_FRACLMBITS) / 4) - 1; s--) {
+
 		*s = u.extu_ext.ext_fraclm & 0xf;
 		u.extu_ext.ext_fraclm >>= 4;
 	}
+#else
+#define EXT_FRACLMBITS 0
 #endif
-	for (; s > s0; s--) {
+
+	for (; s > s0 + sigfigs -
+	((EXT_FRACLBITS + EXT_FRACHMBITS + EXT_FRACLMBITS + EXT_FRACHBITS) / 4) - 1; s--) {
 		*s = u.extu_ext.ext_frach & 0xf;
 		u.extu_ext.ext_frach >>= 4;
 	}
@@ -337,7 +348,7 @@ hldtoa(long double e, const char *xdigs,
 	 * (partial) nibble, which is dealt with by the next
 	 * statement.  We also tack on the implicit normalization bit.
 	 */
-	*s = u.extu_ext.ext_frach | (1U << ((LDBL_MANT_DIG - 1) % 4));
+	*s = (u.extu_ext.ext_frach | (1U << ((LDBL_MANT_DIG - 1) % 4))) 0xf;
 
 	/* If ndigits < 0, we are expected to auto-size the precision. */
 	if (ndigits < 0) {



CVS commit: src/lib/libc/gdtoa

2020-02-21 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb 22 00:38:15 UTC 2020

Modified Files:
src/lib/libc/gdtoa: gethex.c

Log Message:
Avoid unportable left shift construct

left shift of 9 by 28 places cannot be represented in type 'int'


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/gdtoa/gethex.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/gethex.c
diff -u src/lib/libc/gdtoa/gethex.c:1.6 src/lib/libc/gdtoa/gethex.c:1.7
--- src/lib/libc/gdtoa/gethex.c:1.6	Fri Apr 19 10:41:53 2013
+++ src/lib/libc/gdtoa/gethex.c	Sat Feb 22 00:38:14 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gethex.c,v 1.6 2013/04/19 10:41:53 joerg Exp $ */
+/* $NetBSD: gethex.c,v 1.7 2020/02/22 00:38:14 kamil Exp $ */
 
 /
 
@@ -209,7 +209,7 @@ gethex( CONST char **sp, CONST FPI *fpi,
 			L = 0;
 			n = 0;
 			}
-		L |= (hexdig[(unsigned char)*s1] & 0x0f) << n;
+		L |= (unsigned int)(hexdig[(unsigned char)*s1] & 0x0f) << n;
 		n += 4;
 		}
 	*x++ = L;



CVS commit: src/lib/libc/gdtoa

2016-03-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 13 19:44:58 UTC 2016

Modified Files:
src/lib/libc/gdtoa: ldtoa.c

Log Message:
PR/50937: Henning Petersen: Fix subnormal printf for long double x86. From
FreeBSD PR 85080.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/gdtoa/ldtoa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/ldtoa.c
diff -u src/lib/libc/gdtoa/ldtoa.c:1.4 src/lib/libc/gdtoa/ldtoa.c:1.5
--- src/lib/libc/gdtoa/ldtoa.c:1.4	Fri Feb 23 12:45:59 2007
+++ src/lib/libc/gdtoa/ldtoa.c	Sun Mar 13 15:44:58 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldtoa.c,v 1.4 2007/02/23 17:45:59 christos Exp $	*/
+/*	$NetBSD: ldtoa.c,v 1.5 2016/03/13 19:44:58 christos Exp $	*/
 
 /*-
  * Copyright (c) 2003 David Schultz 
@@ -30,7 +30,7 @@
 #if 0
 __FBSDID("$FreeBSD: src/lib/libc/gdtoa/_ldtoa.c,v 1.2 2004/01/18 07:53:49 das Exp $");
 #else
-__RCSID("$NetBSD: ldtoa.c,v 1.4 2007/02/23 17:45:59 christos Exp $");
+__RCSID("$NetBSD: ldtoa.c,v 1.5 2016/03/13 19:44:58 christos Exp $");
 #endif
 
 #include 
@@ -87,9 +87,7 @@ ldtoa(long double *ld, int mode, int ndi
 		break;
 	case FP_SUBNORMAL:
 		kind = STRTOG_Denormal;
-#ifdef	LDBL_IMPLICIT_NBIT
 		be++;
-#endif
 		break;
 	case FP_INFINITE:
 		kind = STRTOG_Infinite;



CVS commit: src/lib/libc/gdtoa

2013-04-19 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Apr 19 10:41:54 UTC 2013

Modified Files:
src/lib/libc/gdtoa: gdtoaimp.h gethex.c strtod.c strtodg.c

Log Message:
Pass locale down to gethex as well.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/gdtoa/gdtoaimp.h
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/gdtoa/gethex.c
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/gdtoa/strtod.c
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/gdtoa/strtodg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/gdtoaimp.h
diff -u src/lib/libc/gdtoa/gdtoaimp.h:1.13 src/lib/libc/gdtoa/gdtoaimp.h:1.14
--- src/lib/libc/gdtoa/gdtoaimp.h:1.13	Tue Mar 13 21:13:34 2012
+++ src/lib/libc/gdtoa/gdtoaimp.h	Fri Apr 19 10:41:53 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: gdtoaimp.h,v 1.13 2012/03/13 21:13:34 christos Exp $ */
+/* $NetBSD: gdtoaimp.h,v 1.14 2013/04/19 10:41:53 joerg Exp $ */
 
 /
 
@@ -601,7 +601,7 @@ extern void memcpy_D2A ANSI((void*, cons
  extern char *dtoa ANSI((double d, int mode, int ndigits,
 			int *decpt, int *sign, char **rve));
  extern char *g__fmt ANSI((char*, char*, char*, int, ULong, size_t));
- extern int gethex ANSI((CONST char**, CONST FPI*, Long*, Bigint**, int));
+ extern int gethex ANSI((CONST char**, CONST FPI*, Long*, Bigint**, int, locale_t));
  extern void hexdig_init_D2A(Void);
  extern int hexnan ANSI((CONST char**, CONST FPI*, ULong*));
  extern int hi0bits_D2A ANSI((ULong));

Index: src/lib/libc/gdtoa/gethex.c
diff -u src/lib/libc/gdtoa/gethex.c:1.5 src/lib/libc/gdtoa/gethex.c:1.6
--- src/lib/libc/gdtoa/gethex.c:1.5	Sun Mar 20 23:15:35 2011
+++ src/lib/libc/gdtoa/gethex.c	Fri Apr 19 10:41:53 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: gethex.c,v 1.5 2011/03/20 23:15:35 christos Exp $ */
+/* $NetBSD: gethex.c,v 1.6 2013/04/19 10:41:53 joerg Exp $ */
 
 /
 
@@ -38,12 +38,7 @@ THIS SOFTWARE.
 #endif
 
  int
-#ifdef KR_headers
-gethex(sp, fpi, expt, bp, sign)
-	CONST char **sp; CONST FPI *fpi; Long *expt; Bigint **bp; int sign;
-#else
-gethex( CONST char **sp, CONST FPI *fpi, Long *expt, Bigint **bp, int sign)
-#endif
+gethex( CONST char **sp, CONST FPI *fpi, Long *expt, Bigint **bp, int sign, locale_t loc)
 {
 	Bigint *b;
 	CONST char *decpt, *s, *s0, *s1;
@@ -52,20 +47,7 @@ gethex( CONST char **sp, CONST FPI *fpi,
 	Long e, e1;
 #ifdef USE_LOCALE
 	int i;
-#ifdef NO_LOCALE_CACHE
-	const char *decimalpoint = localeconv()-decimal_point;
-#else
-	const unsigned char *decimalpoint;
-	static char *decimalpoint_cache;
-	if (!(s0 = decimalpoint_cache)) {
-		s0 = localeconv()-decimal_point;
-		if ((decimalpoint_cache = MALLOC(strlen(s0) + 1)) != NULL) {
-			strcpy(decimalpoint_cache, s0);
-			s0 = decimalpoint_cache;
-			}
-		}
-	decimalpoint = __UNCONST(s0);
-#endif
+	const char *decimalpoint = localeconv_l(loc)-decimal_point;
 #endif
 
 	if (!hexdig[(unsigned char)'0'])

Index: src/lib/libc/gdtoa/strtod.c
diff -u src/lib/libc/gdtoa/strtod.c:1.12 src/lib/libc/gdtoa/strtod.c:1.13
--- src/lib/libc/gdtoa/strtod.c:1.12	Thu Apr 18 21:54:10 2013
+++ src/lib/libc/gdtoa/strtod.c	Fri Apr 19 10:41:53 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: strtod.c,v 1.12 2013/04/18 21:54:10 joerg Exp $ */
+/* $NetBSD: strtod.c,v 1.13 2013/04/19 10:41:53 joerg Exp $ */
 
 /
 
@@ -175,7 +175,7 @@ _int_strtod_l(CONST char *s00, char **se
 #else
 #define fpi1 fpi
 #endif
-			switch((i = gethex(s, fpi1, expt, bb, sign))  STRTOG_Retmask) {
+			switch((i = gethex(s, fpi1, expt, bb, sign, loc))  STRTOG_Retmask) {
 			  case STRTOG_NoNumber:
 s = s00;
 sign = 0;

Index: src/lib/libc/gdtoa/strtodg.c
diff -u src/lib/libc/gdtoa/strtodg.c:1.11 src/lib/libc/gdtoa/strtodg.c:1.12
--- src/lib/libc/gdtoa/strtodg.c:1.11	Thu Apr 18 21:54:10 2013
+++ src/lib/libc/gdtoa/strtodg.c	Fri Apr 19 10:41:53 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: strtodg.c,v 1.11 2013/04/18 21:54:10 joerg Exp $ */
+/* $NetBSD: strtodg.c,v 1.12 2013/04/19 10:41:53 joerg Exp $ */
 
 /
 
@@ -377,7 +377,7 @@ strtodg(CONST char *s00, char **se, CONS
 		switch(s[1]) {
 		  case 'x':
 		  case 'X':
-			irv = gethex(s, fpi, expt, rvb, sign);
+			irv = gethex(s, fpi, expt, rvb, sign, loc);
 			if (irv == STRTOG_NoNumber) {
 s = s00;
 sign = 0;



CVS commit: src/lib/libc/gdtoa

2013-04-19 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Apr 19 20:18:33 UTC 2013

Modified Files:
src/lib/libc/gdtoa: Makefile.inc

Log Message:
Add libc/locale to the search path.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/gdtoa/Makefile.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/Makefile.inc
diff -u src/lib/libc/gdtoa/Makefile.inc:1.8 src/lib/libc/gdtoa/Makefile.inc:1.9
--- src/lib/libc/gdtoa/Makefile.inc:1.8	Sat Feb  9 02:37:21 2008
+++ src/lib/libc/gdtoa/Makefile.inc	Fri Apr 19 20:18:33 2013
@@ -1,8 +1,8 @@
-#	$NetBSD: Makefile.inc,v 1.8 2008/02/09 02:37:21 mrg Exp $
+#	$NetBSD: Makefile.inc,v 1.9 2013/04/19 20:18:33 joerg Exp $
 
 # gdtoa sources
 .PATH: ${.CURDIR}/gdtoa
-CPPFLAGS+=-I${.CURDIR}/gdtoa
+CPPFLAGS+=-I${.CURDIR}/gdtoa -I${.CURDIR}/locale
 
 CPPFLAGS+=-DNO_FENV_H
 



CVS commit: src/lib/libc/gdtoa

2012-05-16 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Wed May 16 17:48:59 UTC 2012

Modified Files:
src/lib/libc/gdtoa: dtoa.c

Log Message:
Use original indentation style in more places.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/gdtoa/dtoa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/dtoa.c
diff -u src/lib/libc/gdtoa/dtoa.c:1.9 src/lib/libc/gdtoa/dtoa.c:1.10
--- src/lib/libc/gdtoa/dtoa.c:1.9	Tue May 15 18:13:21 2012
+++ src/lib/libc/gdtoa/dtoa.c	Wed May 16 17:48:59 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: dtoa.c,v 1.9 2012/05/15 18:13:21 alnsn Exp $ */
+/* $NetBSD: dtoa.c,v 1.10 2012/05/16 17:48:59 alnsn Exp $ */
 
 /
 
@@ -555,7 +555,7 @@ dtoa
 		S = pow5mult(S, s5);
 		if (S == NULL)
 			return NULL;
-	}
+		}
 
 	/* Check for special case that d is a normalized power of 2. */
 
@@ -607,12 +607,12 @@ dtoa
 		b = lshift(b, b2);
 		if (b == NULL)
 			return NULL;
-	}
+		}
 	if (s2  0) {
 		S = lshift(S, s2);
 		if (S == NULL)
 			return NULL;
-	}
+		}
 	if (k_check) {
 		if (cmp(b,S)  0) {
 			k--;
@@ -623,7 +623,7 @@ dtoa
 mhi = multadd(mhi, 10, 0);
 if (mhi == NULL)
 	return NULL;
-			}
+}
 			ilim = ilim1;
 			}
 		}
@@ -644,7 +644,7 @@ dtoa
 			mhi = lshift(mhi, m2);
 			if (mhi == NULL)
 return NULL;
-		}
+			}
 
 		/* Compute mlo -- check for special case
 		 * that d is a normalized power of 2.



CVS commit: src/lib/libc/gdtoa

2012-05-15 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Tue May 15 18:10:02 UTC 2012

Modified Files:
src/lib/libc/gdtoa: dtoa.c

Log Message:
Add missing {} around two if (b == NULL) checks which were added in r1.5.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/gdtoa/dtoa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/dtoa.c
diff -u src/lib/libc/gdtoa/dtoa.c:1.7 src/lib/libc/gdtoa/dtoa.c:1.8
--- src/lib/libc/gdtoa/dtoa.c:1.7	Mon Mar 21 19:46:41 2011
+++ src/lib/libc/gdtoa/dtoa.c	Tue May 15 18:10:02 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: dtoa.c,v 1.7 2011/03/21 19:46:41 christos Exp $ */
+/* $NetBSD: dtoa.c,v 1.8 2012/05/15 18:10:02 alnsn Exp $ */
 
 /
 
@@ -536,16 +536,18 @@ dtoa
 Bfree(b);
 b = b1;
 }
-			if (( j = b5 - m5 )!=0)
+			if (( j = b5 - m5 )!=0) {
 b = pow5mult(b, j);
 if (b == NULL)
 	return NULL;
+}
 			}
-		else
+		else {
 			b = pow5mult(b, b5);
 			if (b == NULL)
 return NULL;
 		}
+		}
 	S = i2b(1);
 	if (S == NULL)
 		return NULL;



CVS commit: src/lib/libc/gdtoa

2012-05-15 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Tue May 15 18:13:22 UTC 2012

Modified Files:
src/lib/libc/gdtoa: dtoa.c

Log Message:
Don't use normal indentation style, use original author's indentation style.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/gdtoa/dtoa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/dtoa.c
diff -u src/lib/libc/gdtoa/dtoa.c:1.8 src/lib/libc/gdtoa/dtoa.c:1.9
--- src/lib/libc/gdtoa/dtoa.c:1.8	Tue May 15 18:10:02 2012
+++ src/lib/libc/gdtoa/dtoa.c	Tue May 15 18:13:21 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: dtoa.c,v 1.8 2012/05/15 18:10:02 alnsn Exp $ */
+/* $NetBSD: dtoa.c,v 1.9 2012/05/15 18:13:21 alnsn Exp $ */
 
 /
 
@@ -546,7 +546,7 @@ dtoa
 			b = pow5mult(b, b5);
 			if (b == NULL)
 return NULL;
-		}
+			}
 		}
 	S = i2b(1);
 	if (S == NULL)



CVS commit: src/lib/libc/gdtoa

2012-03-22 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Thu Mar 22 13:09:13 UTC 2012

Modified Files:
src/lib/libc/gdtoa: strtodg.c

Log Message:
A few fixes to make this build for vax:
 * The fivesbits[] variable is not used for vax
 * The decpt variable is only used if INFNAN_CHECK, which isn't
   defined for vax


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/gdtoa/strtodg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/strtodg.c
diff -u src/lib/libc/gdtoa/strtodg.c:1.9 src/lib/libc/gdtoa/strtodg.c:1.10
--- src/lib/libc/gdtoa/strtodg.c:1.9	Tue Mar 13 21:13:34 2012
+++ src/lib/libc/gdtoa/strtodg.c	Thu Mar 22 13:09:12 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: strtodg.c,v 1.9 2012/03/13 21:13:34 christos Exp $ */
+/* $NetBSD: strtodg.c,v 1.10 2012/03/22 13:09:12 he Exp $ */
 
 /
 
@@ -37,14 +37,13 @@ THIS SOFTWARE.
 #include locale.h
 #endif
 
+#ifndef VAX
  static CONST int
 fivesbits[] = {	 0,  3,  5,  7, 10, 12, 14, 17, 19, 21,
 		24, 26, 28, 31, 33, 35, 38, 40, 42, 45,
 		47, 49, 52
-#ifdef VAX
-		, 54, 56
-#endif
 		};
+#endif
 
  Bigint *
 #ifdef KR_headers
@@ -329,7 +328,10 @@ strtodg
 #endif
 {
 	int abe, abits, asub;
-	int bb0, bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, decpt, denorm;
+#ifdef INFNAN_CHECK
+	int decpt;
+#endif
+	int bb0, bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, denorm;
 	int dsign, e, e1, e2, emin, esign, finished, i, inex, irv;
 	int j, k, nbits, nd, nd0, nf, nz, nz0, rd, rvbits, rve, rve1, sign;
 	int sudden_underflow = 0; /* pacify gcc */
@@ -413,7 +415,10 @@ strtodg
 	sudden_underflow = fpi-sudden_underflow;
 	s0 = s;
 	y = z = 0;
-	for(decpt = nd = nf = 0; (c = *s) = '0'  c = '9'; nd++, s++)
+#ifdef INFNAN_CHECK
+	decpt = 0;
+#endif
+	for(nd = nf = 0; (c = *s) = '0'  c = '9'; nd++, s++)
 		if (nd  9)
 			y = 10*y + c - '0';
 		else if (nd  16)
@@ -430,7 +435,9 @@ strtodg
 	if (c == '.') {
 		c = *++s;
 #endif
+#ifdef INFNAN_CHECK
 		decpt = 1;
+#endif
 		if (!nd) {
 			for(; c == '0'; c = *++s)
 nz++;



CVS commit: src/lib/libc/gdtoa

2012-03-22 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Thu Mar 22 13:15:48 UTC 2012

Modified Files:
src/lib/libc/gdtoa: strtod.c

Log Message:
A few modifications to make this build for vax:
 * The decpt variable is only used if INFNAN_CHECK, which isn't defined
   for vax.
 * Use a cast to avoid warning about shift of a signed variable.
 * Mark a condition as (potentially) a constant condition.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/gdtoa/strtod.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/strtod.c
diff -u src/lib/libc/gdtoa/strtod.c:1.9 src/lib/libc/gdtoa/strtod.c:1.10
--- src/lib/libc/gdtoa/strtod.c:1.9	Tue Mar 13 21:13:34 2012
+++ src/lib/libc/gdtoa/strtod.c	Thu Mar 22 13:15:48 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: strtod.c,v 1.9 2012/03/13 21:13:34 christos Exp $ */
+/* $NetBSD: strtod.c,v 1.10 2012/03/22 13:15:48 he Exp $ */
 
 /
 
@@ -97,7 +97,10 @@ strtod
 #ifdef Avoid_Underflow
 	int scale;
 #endif
-	int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, decpt, dsign,
+#ifdef INFNAN_CHECK
+	int decpt;
+#endif
+	int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
 		 e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
 	CONST char *s, *s0, *s1;
 	double aadj;
@@ -148,7 +151,10 @@ strtod
 #endif /*}}*/
 #endif /*}*/
 
-	sign = nz0 = nz = decpt = 0;
+#ifdef INFNAN_CHECK
+	decpt = 0;
+#endif
+	sign = nz0 = nz = 0;
 	dval(rv) = 0.;
 	for(s = s00;;s++) switch(*s) {
 		case '-':
@@ -229,7 +235,9 @@ strtod
 	if (c == '.') {
 		c = *++s;
 #endif
+#ifdef INFNAN_CHECK
 		decpt = 1;
+#endif
 		if (!nd) {
 			for(; c == '0'; c = *++s)
 nz++;
@@ -552,7 +560,7 @@ strtod
 	word1(rv) = 0x  j;
 }
 #else
-			for(j = 0; e1  1; j++, e1 = 1)
+			for(j = 0; e1  1; j++, e1 = (unsigned int)e1  1)
 if (e1  1)
 	dval(rv) *= tinytens[j];
 			/* The last multiplication could underflow. */
@@ -957,6 +965,7 @@ strtod
 	dval(aadj1) += 0.5;
 }
 #else
+			/* CONSTCOND */
 			if (Flt_Rounds == 0)
 dval(aadj1) += 0.5;
 #endif /*Check_FLT_ROUNDS*/



CVS commit: src/lib/libc/gdtoa

2012-03-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Mar 22 15:34:14 UTC 2012

Modified Files:
src/lib/libc/gdtoa: strtod.c

Log Message:
add constcond, make shifts unsigned


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/gdtoa/strtod.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/strtod.c
diff -u src/lib/libc/gdtoa/strtod.c:1.10 src/lib/libc/gdtoa/strtod.c:1.11
--- src/lib/libc/gdtoa/strtod.c:1.10	Thu Mar 22 09:15:48 2012
+++ src/lib/libc/gdtoa/strtod.c	Thu Mar 22 11:34:14 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: strtod.c,v 1.10 2012/03/22 13:15:48 he Exp $ */
+/* $NetBSD: strtod.c,v 1.11 2012/03/22 15:34:14 christos Exp $ */
 
 /
 
@@ -554,10 +554,10 @@ strtod
 	if (j = 53)
 	 word0(rv) = (P+2)*Exp_msk1;
 	else
-	 word0(rv) = 0x  (j-32);
+	 word0(rv) = 0xU  (j-32);
 	}
 else
-	word1(rv) = 0x  j;
+	word1(rv) = 0xU  j;
 }
 #else
 			for(j = 0; e1  1; j++, e1 = (unsigned int)e1  1)
@@ -956,6 +956,7 @@ strtod
 			aadj *= 0.5;
 			dval(aadj1) = dsign ? aadj : -aadj;
 #ifdef Check_FLT_ROUNDS
+			/* CONSTCOND */
 			switch(Rounding) {
 case 2: /* towards +infinity */
 	dval(aadj1) -= 0.5;



CVS commit: src/lib/libc/gdtoa

2011-11-21 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Nov 21 09:46:20 UTC 2011

Modified Files:
src/lib/libc/gdtoa: misc.c

Log Message:
one more error path that didn't free a lock.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/gdtoa/misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/misc.c
diff -u src/lib/libc/gdtoa/misc.c:1.10 src/lib/libc/gdtoa/misc.c:1.11
--- src/lib/libc/gdtoa/misc.c:1.10	Fri Nov 18 08:20:13 2011
+++ src/lib/libc/gdtoa/misc.c	Mon Nov 21 09:46:19 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: misc.c,v 1.10 2011/11/18 08:20:13 martin Exp $ */
+/* $NetBSD: misc.c,v 1.11 2011/11/21 09:46:19 mlelstv Exp $ */
 
 /
 
@@ -76,8 +76,10 @@ Balloc
 		else
 			rv = (Bigint*)MALLOC(len*sizeof(double));
 #endif
-		if (rv == NULL)
+		if (rv == NULL) {
+			FREE_DTOA_LOCK(0);
 			return NULL;
+		}
 		rv-k = k;
 		rv-maxwds = x;
 		}



CVS commit: src/lib/libc/gdtoa

2011-11-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov 18 08:20:13 UTC 2011

Modified Files:
src/lib/libc/gdtoa: misc.c

Log Message:
Release dtoa lock before returning, pointed out by enami.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/gdtoa/misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/misc.c
diff -u src/lib/libc/gdtoa/misc.c:1.9 src/lib/libc/gdtoa/misc.c:1.10
--- src/lib/libc/gdtoa/misc.c:1.9	Fri Nov 18 04:17:23 2011
+++ src/lib/libc/gdtoa/misc.c	Fri Nov 18 08:20:13 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: misc.c,v 1.9 2011/11/18 04:17:23 christos Exp $ */
+/* $NetBSD: misc.c,v 1.10 2011/11/18 08:20:13 martin Exp $ */
 
 /
 
@@ -444,8 +444,10 @@ pow5mult
 			ACQUIRE_DTOA_LOCK(1);
 			if (!(p51 = p5-next)) {
 p51 = p5-next = mult(p5,p5);
-if (p51 == NULL)
+if (p51 == NULL) {
+	FREE_DTOA_LOCK(1);
 	return NULL;
+}
 p51-next = 0;
 }
 			FREE_DTOA_LOCK(1);



CVS commit: src/lib/libc/gdtoa

2011-11-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 18 02:38:18 UTC 2011

Modified Files:
src/lib/libc/gdtoa: misc.c

Log Message:
PR/45627: Martin Husemann: Plug memory leak


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/gdtoa/misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/misc.c
diff -u src/lib/libc/gdtoa/misc.c:1.7 src/lib/libc/gdtoa/misc.c:1.8
--- src/lib/libc/gdtoa/misc.c:1.7	Mon Mar 21 00:52:09 2011
+++ src/lib/libc/gdtoa/misc.c	Thu Nov 17 21:38:17 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: misc.c,v 1.7 2011/03/21 04:52:09 christos Exp $ */
+/* $NetBSD: misc.c,v 1.8 2011/11/18 02:38:17 christos Exp $ */
 
 /
 
@@ -432,6 +432,7 @@ pow5mult
 			b1 = mult(b, p5);
 			if (b1 == NULL)
 return NULL;
+			Bfree(b);
 			b = b1;
 			}
 		if (!(k = (unsigned int)k  1))



CVS commit: src/lib/libc/gdtoa

2011-11-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 18 04:17:23 UTC 2011

Modified Files:
src/lib/libc/gdtoa: misc.c

Log Message:
unlock before returning on error, thanks enami.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/gdtoa/misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/misc.c
diff -u src/lib/libc/gdtoa/misc.c:1.8 src/lib/libc/gdtoa/misc.c:1.9
--- src/lib/libc/gdtoa/misc.c:1.8	Thu Nov 17 21:38:17 2011
+++ src/lib/libc/gdtoa/misc.c	Thu Nov 17 23:17:23 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: misc.c,v 1.8 2011/11/18 02:38:17 christos Exp $ */
+/* $NetBSD: misc.c,v 1.9 2011/11/18 04:17:23 christos Exp $ */
 
 /
 
@@ -415,8 +415,10 @@ pow5mult
 		ACQUIRE_DTOA_LOCK(1);
 		if (!(p5 = p5s)) {
 			p5 = p5s = i2b(625);
-			if (p5 == NULL)
+			if (p5 == NULL) {
+FREE_DTOA_LOCK(1);
 return NULL;
+			}
 			p5-next = 0;
 			}
 		FREE_DTOA_LOCK(1);



CVS commit: src/lib/libc/gdtoa

2011-06-30 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Fri Jul  1 03:20:06 UTC 2011

Modified Files:
src/lib/libc/gdtoa: strtof_vaxf.c

Log Message:
Fix some bugs [exceed array bounds].  Simplify.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/gdtoa/strtof_vaxf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/strtof_vaxf.c
diff -u src/lib/libc/gdtoa/strtof_vaxf.c:1.5 src/lib/libc/gdtoa/strtof_vaxf.c:1.6
--- src/lib/libc/gdtoa/strtof_vaxf.c:1.5	Fri Mar 28 00:56:54 2008
+++ src/lib/libc/gdtoa/strtof_vaxf.c	Fri Jul  1 03:20:06 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: strtof_vaxf.c,v 1.5 2008/03/28 00:56:54 he Exp $ */
+/* $NetBSD: strtof_vaxf.c,v 1.6 2011/07/01 03:20:06 matt Exp $ */
 
 /
 
@@ -56,14 +56,13 @@
 	k = strtodg(s, sp, fpi, expt, bits);
 	if (k == STRTOG_NoMemory) {
 		errno = ERANGE;
-		u.L[0] = Big0;
-		u.L[1] = Big1;
-		return u.f;
+		return HUGE_VALF;
 	}
 	switch(k  STRTOG_Retmask) {
 	  case STRTOG_NoNumber:
 	  case STRTOG_Zero:
-		u.L[0] = 0;
+	  default:
+		u.f = 0.0;
 		break;
 
 	  case STRTOG_Normal:
@@ -73,11 +72,11 @@
 		break;
 
 	  case STRTOG_Infinite:
-		u.L[0] = 0x7fff;
+		u.f = HUGE_VALF;
 		break;
 
 	  }
 	if (k  STRTOG_Neg)
 		u.L[0] |= 0x8000L;
 	return u.f;
-	}
+}



CVS commit: src/lib/libc/gdtoa

2011-06-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jun  4 14:18:10 UTC 2011

Modified Files:
src/lib/libc/gdtoa: gdtoaimp.h

Log Message:
remove string placed by error(1)


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/gdtoa/gdtoaimp.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/gdtoaimp.h
diff -u src/lib/libc/gdtoa/gdtoaimp.h:1.11 src/lib/libc/gdtoa/gdtoaimp.h:1.12
--- src/lib/libc/gdtoa/gdtoaimp.h:1.11	Mon Mar 21 18:33:29 2011
+++ src/lib/libc/gdtoa/gdtoaimp.h	Sat Jun  4 10:18:10 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: gdtoaimp.h,v 1.11 2011/03/21 22:33:29 christos Exp $ */
+/* $NetBSD: gdtoaimp.h,v 1.12 2011/06/04 14:18:10 christos Exp $ */
 
 /
 
@@ -624,8 +624,6 @@
  extern double strtod ANSI((const char *s00, char **se));
  extern Bigint *sum ANSI((Bigint*, Bigint*));
  extern int trailz ANSI((CONST Bigint*));
-/*###626 [lint] syntax error '*' [249]%%%*/
-/*###626 [lint] incomplete or misplaced function definition [22]%%%*/
  extern double ulp ANSI((U*));
 
 #ifdef __cplusplus



CVS commit: src/lib/libc/gdtoa

2011-03-27 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Sun Mar 27 11:21:55 UTC 2011

Modified Files:
src/lib/libc/gdtoa: strtod.c

Log Message:
Fix this so that it builds for vax; where the compiler balks at the
mixture of a union and a double in an expression (imagine that!)
I see other similar uses, and how they pass through for other ports
is beyond me, but I have not touched them in this round.

OK'ed by christos@


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/gdtoa/strtod.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/strtod.c
diff -u src/lib/libc/gdtoa/strtod.c:1.7 src/lib/libc/gdtoa/strtod.c:1.8
--- src/lib/libc/gdtoa/strtod.c:1.7	Mon Mar 21 12:53:50 2011
+++ src/lib/libc/gdtoa/strtod.c	Sun Mar 27 11:21:54 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: strtod.c,v 1.7 2011/03/21 12:53:50 christos Exp $ */
+/* $NetBSD: strtod.c,v 1.8 2011/03/27 11:21:54 he Exp $ */
 
 /
 
@@ -1000,7 +1000,7 @@
 dval(rv0) = dval(rv);
 word0(rv) += P*Exp_msk1;
 dval(adj) = dval(aadj1) * ulp(rv);
-dval(rv) += adj;
+dval(rv) += dval(adj);
 #ifdef IBM
 if ((word0(rv)  Exp_mask)   P*Exp_msk1)
 #else
@@ -1019,7 +1019,7 @@
 }
 			else {
 dval(adj) = dval(aadj1) * ulp(rv);
-dval(rv) += adj;
+dval(rv) += dval(adj);
 }
 #else /*Sudden_Underflow*/
 			/* Compute dval(adj) so that the IEEE rounding rules will



CVS commit: src/lib/libc/gdtoa

2011-03-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar 21 12:53:51 UTC 2011

Modified Files:
src/lib/libc/gdtoa: g__fmt.c strtod.c strtodg.c

Log Message:
more de-linting.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 src/lib/libc/gdtoa/g__fmt.c
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/gdtoa/strtod.c
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/gdtoa/strtodg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/g__fmt.c
diff -u src/lib/libc/gdtoa/g__fmt.c:1.1.1.2 src/lib/libc/gdtoa/g__fmt.c:1.2
--- src/lib/libc/gdtoa/g__fmt.c:1.1.1.2	Sat Mar 19 12:26:37 2011
+++ src/lib/libc/gdtoa/g__fmt.c	Mon Mar 21 08:53:50 2011
@@ -56,7 +56,7 @@
 	if (!(s0 = decimalpoint_cache)) {
 		s0 = localeconv()-decimal_point;
 		dlen = strlen(s0);
-		if ((decimalpoint_cache = (char*)MALLOC(strlen(s0) + 1))) {
+		if ((decimalpoint_cache = MALLOC(strlen(s0) + 1)) != NULL) {
 			strcpy(decimalpoint_cache, s0);
 			s0 = decimalpoint_cache;
 			}

Index: src/lib/libc/gdtoa/strtod.c
diff -u src/lib/libc/gdtoa/strtod.c:1.6 src/lib/libc/gdtoa/strtod.c:1.7
--- src/lib/libc/gdtoa/strtod.c:1.6	Sun Mar 20 19:15:35 2011
+++ src/lib/libc/gdtoa/strtod.c	Mon Mar 21 08:53:50 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: strtod.c,v 1.6 2011/03/20 23:15:35 christos Exp $ */
+/* $NetBSD: strtod.c,v 1.7 2011/03/21 12:53:50 christos Exp $ */
 
 /
 
@@ -122,7 +122,7 @@
 	static int dplen;
 	if (!(s0 = decimalpoint_cache)) {
 		s0 = localeconv()-decimal_point;
-		if ((decimalpoint_cache = MALLOC(strlen(s0) + 1))) {
+		if ((decimalpoint_cache = MALLOC(strlen(s0) + 1)) != NULL) {
 			strcpy(decimalpoint_cache, s0);
 			s0 = decimalpoint_cache;
 			}

Index: src/lib/libc/gdtoa/strtodg.c
diff -u src/lib/libc/gdtoa/strtodg.c:1.7 src/lib/libc/gdtoa/strtodg.c:1.8
--- src/lib/libc/gdtoa/strtodg.c:1.7	Sun Mar 20 19:15:35 2011
+++ src/lib/libc/gdtoa/strtodg.c	Mon Mar 21 08:53:50 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: strtodg.c,v 1.7 2011/03/20 23:15:35 christos Exp $ */
+/* $NetBSD: strtodg.c,v 1.8 2011/03/21 12:53:50 christos Exp $ */
 
 /
 
@@ -349,7 +349,7 @@
 	static int dplen;
 	if (!(s0 = decimalpoint_cache)) {
 		s0 = localeconv()-decimal_point;
-		if ((decimalpoint_cache = MALLOC(strlen(s0) + 1))) {
+		if ((decimalpoint_cache = MALLOC(strlen(s0) + 1)) != NULL) {
 			strcpy(decimalpoint_cache, s0);
 			s0 = decimalpoint_cache;
 			}
@@ -640,7 +640,7 @@
 			e2 += ((word0(rv)  Exp_mask)  Exp_shift1) - Bias;
 			word0(rv) = ~Exp_mask;
 			word0(rv) |= Bias  Exp_shift1;
-			for(j = 0; e1  0; j++, e1 = 1)
+			for(j = 0; e1  0; j++, e1 = (unsigned int)e1  1)
 if (e1  1)
 	dval(rv) *= bigtens[j];
 			}
@@ -651,7 +651,6 @@
 			dval(rv) /= tens[i];
 		if (e1 = ~15) {
 			e1 = (unsigned int)e1  4;
-			e1 = 4;
 			while(e1 = (1  (n_bigtens-1))) {
 e2 += ((word0(rv)  Exp_mask)
 	 Exp_shift1) - Bias;
@@ -663,7 +662,7 @@
 			e2 += ((word0(rv)  Exp_mask)  Exp_shift1) - Bias;
 			word0(rv) = ~Exp_mask;
 			word0(rv) |= Bias  Exp_shift1;
-			for(j = 0; e1  0; j++, e1 = 1)
+			for(j = 0; e1  0; j++, e1 = (unsigned int)e1  1)
 if (e1  1)
 	dval(rv) *= tinytens[j];
 			}
@@ -1073,10 +1072,10 @@
 		irv = STRTOG_Normal | STRTOG_Inexlo;
 		*expt = fpi-emax;
 		b = bits;
-		be = b + ((fpi-nbits + 31)  5);
+		be = b + ((unsigned int)(fpi-nbits + 31)  5);
 		while(b  be)
-			*b++ = -1;
-		if ((j = fpi-nbits  0x1f))
+			*b++ = (unsigned int)-1;
+		if ((j = fpi-nbits  0x1f) != 0)
 			*--be = (32 - j);
 		goto ret;
  huge:



CVS commit: src/lib/libc/gdtoa

2011-03-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar 21 19:46:41 UTC 2011

Modified Files:
src/lib/libc/gdtoa: dtoa.c

Log Message:
fix vax typo.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/gdtoa/dtoa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/dtoa.c
diff -u src/lib/libc/gdtoa/dtoa.c:1.6 src/lib/libc/gdtoa/dtoa.c:1.7
--- src/lib/libc/gdtoa/dtoa.c:1.6	Sun Mar 20 19:15:35 2011
+++ src/lib/libc/gdtoa/dtoa.c	Mon Mar 21 15:46:41 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dtoa.c,v 1.6 2011/03/20 23:15:35 christos Exp $ */
+/* $NetBSD: dtoa.c,v 1.7 2011/03/21 19:46:41 christos Exp $ */
 
 /
 
@@ -712,7 +712,7 @@
 		return NULL;
 	jj1 = cmp(b, S);
 #ifdef ROUND_BIASED
-	if (jjj1 = 0 /*)*/
+	if (jj1 = 0 /*)*/
 #else
 	if ((jj1  0 || (jj1 == 0  dig  1))
 #endif



CVS commit: src/lib/libc/gdtoa

2011-03-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar 21 22:33:29 UTC 2011

Modified Files:
src/lib/libc/gdtoa: gdtoaimp.h

Log Message:
Add Emin for the vax. Need to check


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/gdtoa/gdtoaimp.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/gdtoaimp.h
diff -u src/lib/libc/gdtoa/gdtoaimp.h:1.10 src/lib/libc/gdtoa/gdtoaimp.h:1.11
--- src/lib/libc/gdtoa/gdtoaimp.h:1.10	Mon Mar 21 00:52:09 2011
+++ src/lib/libc/gdtoa/gdtoaimp.h	Mon Mar 21 18:33:29 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: gdtoaimp.h,v 1.10 2011/03/21 04:52:09 christos Exp $ */
+/* $NetBSD: gdtoaimp.h,v 1.11 2011/03/21 22:33:29 christos Exp $ */
 
 /
 
@@ -406,6 +406,7 @@
 #define Exp_mask  0x7f80
 #define P 56
 #define Bias 129
+#define Emin (-127)	/* XXX: Check this */
 #define Exp_1  0x4080
 #define Exp_11 0x4080
 #define Ebits 8



CVS commit: src/lib/libc/gdtoa

2011-03-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar 21 22:33:46 UTC 2011

Modified Files:
src/lib/libc/gdtoa: hdtoa.c

Log Message:
pacify lint.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/gdtoa/hdtoa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/hdtoa.c
diff -u src/lib/libc/gdtoa/hdtoa.c:1.6 src/lib/libc/gdtoa/hdtoa.c:1.7
--- src/lib/libc/gdtoa/hdtoa.c:1.6	Fri Mar 21 19:13:48 2008
+++ src/lib/libc/gdtoa/hdtoa.c	Mon Mar 21 18:33:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hdtoa.c,v 1.6 2008/03/21 23:13:48 christos Exp $	*/
+/*	$NetBSD: hdtoa.c,v 1.7 2011/03/21 22:33:46 christos Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2005 David Schultz d...@freebsd.org
@@ -30,7 +30,7 @@
 #if 0
 __FBSDID($FreeBSD: src/lib/libc/gdtoa/_hdtoa.c,v 1.4 2007/01/03 04:57:58 das Exp $);
 #else
-__RCSID($NetBSD: hdtoa.c,v 1.6 2008/03/21 23:13:48 christos Exp $);
+__RCSID($NetBSD: hdtoa.c,v 1.7 2011/03/21 22:33:46 christos Exp $);
 #endif
 
 #include float.h
@@ -161,8 +161,15 @@
 		*decpt = 1;
 		return (nrv_alloc(0, rve, 1));
 	case FP_SUBNORMAL:
+#ifdef __vax__
+		/* (DBL_MAX_EXP=127 / 2) + 2 = 65? */
+		u.dblu_d *= 0x1p65;
+		*decpt = u.dblu_dbl.dbl_exp - (65 + DBL_ADJ);
+#endif
+		/* (DBL_MAX_EXP=1024 / 2) + 2 = 514? */
 		u.dblu_d *= 0x1p514;
 		*decpt = u.dblu_dbl.dbl_exp - (514 + DBL_ADJ);
+#endif
 		break;
 	case FP_INFINITE:
 		*decpt = INT_MAX;



CVS commit: src/lib/libc/gdtoa

2011-03-21 Thread enami tsugutomo
Module Name:src
Committed By:   enami
Date:   Mon Mar 21 23:37:42 UTC 2011

Modified Files:
src/lib/libc/gdtoa: hdtoa.c

Log Message:
Don't use #endif where #else is expected.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/gdtoa/hdtoa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/hdtoa.c
diff -u src/lib/libc/gdtoa/hdtoa.c:1.7 src/lib/libc/gdtoa/hdtoa.c:1.8
--- src/lib/libc/gdtoa/hdtoa.c:1.7	Mon Mar 21 22:33:46 2011
+++ src/lib/libc/gdtoa/hdtoa.c	Mon Mar 21 23:37:42 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hdtoa.c,v 1.7 2011/03/21 22:33:46 christos Exp $	*/
+/*	$NetBSD: hdtoa.c,v 1.8 2011/03/21 23:37:42 enami Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2005 David Schultz d...@freebsd.org
@@ -30,7 +30,7 @@
 #if 0
 __FBSDID($FreeBSD: src/lib/libc/gdtoa/_hdtoa.c,v 1.4 2007/01/03 04:57:58 das Exp $);
 #else
-__RCSID($NetBSD: hdtoa.c,v 1.7 2011/03/21 22:33:46 christos Exp $);
+__RCSID($NetBSD: hdtoa.c,v 1.8 2011/03/21 23:37:42 enami Exp $);
 #endif
 
 #include float.h
@@ -165,7 +165,7 @@
 		/* (DBL_MAX_EXP=127 / 2) + 2 = 65? */
 		u.dblu_d *= 0x1p65;
 		*decpt = u.dblu_dbl.dbl_exp - (65 + DBL_ADJ);
-#endif
+#else
 		/* (DBL_MAX_EXP=1024 / 2) + 2 = 514? */
 		u.dblu_d *= 0x1p514;
 		*decpt = u.dblu_dbl.dbl_exp - (514 + DBL_ADJ);



CVS commit: src/lib/libc/gdtoa

2011-03-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar 21 04:52:09 UTC 2011

Modified Files:
src/lib/libc/gdtoa: gdtoaimp.h hexnan.c misc.c

Log Message:
fix some lint on i386


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/gdtoa/gdtoaimp.h
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/gdtoa/hexnan.c
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/gdtoa/misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/gdtoaimp.h
diff -u src/lib/libc/gdtoa/gdtoaimp.h:1.9 src/lib/libc/gdtoa/gdtoaimp.h:1.10
--- src/lib/libc/gdtoa/gdtoaimp.h:1.9	Sun Mar 20 19:15:35 2011
+++ src/lib/libc/gdtoa/gdtoaimp.h	Mon Mar 21 00:52:09 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: gdtoaimp.h,v 1.9 2011/03/20 23:15:35 christos Exp $ */
+/* $NetBSD: gdtoaimp.h,v 1.10 2011/03/21 04:52:09 christos Exp $ */
 
 /
 
@@ -581,7 +581,7 @@
  extern CONST double bigtens[], tens[], tinytens[];
  extern unsigned char hexdig[];
 
- extern Bigint *Balloc ANSI((size_t));
+ extern Bigint *Balloc ANSI((int));
  extern void Bfree ANSI((Bigint*));
  extern void ULtof ANSI((ULong*, ULong*, Long, int));
  extern void ULtod ANSI((ULong*, ULong*, Long, int));

Index: src/lib/libc/gdtoa/hexnan.c
diff -u src/lib/libc/gdtoa/hexnan.c:1.4 src/lib/libc/gdtoa/hexnan.c:1.5
--- src/lib/libc/gdtoa/hexnan.c:1.4	Sun Mar 20 19:15:35 2011
+++ src/lib/libc/gdtoa/hexnan.c	Mon Mar 21 00:52:09 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: hexnan.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */
+/* $NetBSD: hexnan.c,v 1.5 2011/03/21 04:52:09 christos Exp $ */
 
 /
 
@@ -79,7 +79,7 @@
 	if (s[1] == '0'  (s[2] == 'x' || s[2] == 'X')
 	  *(CONST unsigned char*)(s+3)  ' ')
 		s += 2;
-	while((c = *(CONST unsigned char*)++s)) {
+	while((c = *(CONST unsigned char*)++s) != '\0') {
 		if (!(h = hexdig[c])) {
 			if (c = ' ') {
 if (hd0  havedig) {
@@ -111,7 +111,7 @@
 	*sp = s + 1;
 	break;
 	}
-} while((c = *++s));
+} while((c = *++s) != '\0');
 #endif
 			return STRTOG_NaN;
 			}

Index: src/lib/libc/gdtoa/misc.c
diff -u src/lib/libc/gdtoa/misc.c:1.6 src/lib/libc/gdtoa/misc.c:1.7
--- src/lib/libc/gdtoa/misc.c:1.6	Sun Mar 20 19:15:35 2011
+++ src/lib/libc/gdtoa/misc.c	Mon Mar 21 00:52:09 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: misc.c,v 1.6 2011/03/20 23:15:35 christos Exp $ */
+/* $NetBSD: misc.c,v 1.7 2011/03/21 04:52:09 christos Exp $ */
 
 /
 
@@ -45,9 +45,9 @@
  Bigint *
 Balloc
 #ifdef KR_headers
-	(k) size_t k;
+	(k) int k;
 #else
-	(size_t k)
+	(int k)
 #endif
 {
 	int x;
@@ -59,17 +59,17 @@
 	ACQUIRE_DTOA_LOCK(0);
 	/* The k  Kmax case does not need ACQUIRE_DTOA_LOCK(0), */
 	/* but this case seems very unlikely. */
-	if (k = Kmax  (rv = freelist[k]) !=0) {
+	if ((size_t)k = Kmax  (rv = freelist[k]) !=0) {
 		freelist[k] = rv-next;
 		}
 	else {
-		x = 1  (int)k;
+		x = 1  k;
 #ifdef Omit_Private_Memory
 		rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
 #else
 		len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
 			/sizeof(double);
-		if (k = Kmax  pmem_next - private_mem + len = PRIVATE_mem) {
+		if ((size_t)k = Kmax  pmem_next - private_mem + len = PRIVATE_mem) {
 			rv = (Bigint*)(void *)pmem_next;
 			pmem_next += len;
 			}
@@ -78,7 +78,7 @@
 #endif
 		if (rv == NULL)
 			return NULL;
-		rv-k = (int)k;
+		rv-k = k;
 		rv-maxwds = x;
 		}
 	FREE_DTOA_LOCK(0);



CVS commit: src/lib/libc/gdtoa

2011-03-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 19 16:26:49 UTC 2011

Update of /cvsroot/src/lib/libc/gdtoa
In directory ivanova.netbsd.org:/tmp/cvs-serv23231

Log Message:
from www.netlib.org

Status:

Vendor Tag: DMG
Release Tags:   gdtoa-2011-03-19

C src/lib/libc/gdtoa/arithchk.c
U src/lib/libc/gdtoa/README
C src/lib/libc/gdtoa/g_ddfmt.c
C src/lib/libc/gdtoa/dmisc.c
C src/lib/libc/gdtoa/dtoa.c
C src/lib/libc/gdtoa/g_Qfmt.c
U src/lib/libc/gdtoa/g__fmt.c
C src/lib/libc/gdtoa/g_xLfmt.c
C src/lib/libc/gdtoa/g_dfmt.c
C src/lib/libc/gdtoa/g_ffmt.c
N src/lib/libc/gdtoa/gdtoa_fltrnds.h
C src/lib/libc/gdtoa/g_xfmt.c
C src/lib/libc/gdtoa/gdtoa.c
C src/lib/libc/gdtoa/gdtoa.h
C src/lib/libc/gdtoa/strtoIQ.c
C src/lib/libc/gdtoa/qnan.c
C src/lib/libc/gdtoa/gdtoaimp.h
C src/lib/libc/gdtoa/gethex.c
C src/lib/libc/gdtoa/gmisc.c
C src/lib/libc/gdtoa/hd_init.c
C src/lib/libc/gdtoa/hexnan.c
C src/lib/libc/gdtoa/makefile
C src/lib/libc/gdtoa/misc.c
N src/lib/libc/gdtoa/printf.c
N src/lib/libc/gdtoa/printf.c0
C src/lib/libc/gdtoa/smisc.c
N src/lib/libc/gdtoa/stdio1.h
C src/lib/libc/gdtoa/strtoId.c
C src/lib/libc/gdtoa/strtoIdd.c
C src/lib/libc/gdtoa/strtoIf.c
C src/lib/libc/gdtoa/strtoIg.c
C src/lib/libc/gdtoa/strtoIx.c
C src/lib/libc/gdtoa/strtoIxL.c
C src/lib/libc/gdtoa/strtod.c
C src/lib/libc/gdtoa/strtodI.c
C src/lib/libc/gdtoa/strtodg.c
C src/lib/libc/gdtoa/strtodnrp.c
C src/lib/libc/gdtoa/strtof.c
C src/lib/libc/gdtoa/strtopQ.c
C src/lib/libc/gdtoa/strtopd.c
C src/lib/libc/gdtoa/strtopdd.c
C src/lib/libc/gdtoa/strtopf.c
C src/lib/libc/gdtoa/strtopx.c
C src/lib/libc/gdtoa/strtopxL.c
C src/lib/libc/gdtoa/strtorQ.c
C src/lib/libc/gdtoa/strtord.c
C src/lib/libc/gdtoa/strtordd.c
C src/lib/libc/gdtoa/strtorf.c
C src/lib/libc/gdtoa/strtorx.c
C src/lib/libc/gdtoa/strtorxL.c
C src/lib/libc/gdtoa/sum.c
U src/lib/libc/gdtoa/xsum0.out
C src/lib/libc/gdtoa/ulp.c
N src/lib/libc/gdtoa/test/getround.c
N src/lib/libc/gdtoa/test/Q.ou0
N src/lib/libc/gdtoa/test/Q.ou1
N src/lib/libc/gdtoa/test/Qtest.c
N src/lib/libc/gdtoa/test/README
N src/lib/libc/gdtoa/test/d.out
N src/lib/libc/gdtoa/test/dI.out
N src/lib/libc/gdtoa/test/dIsi.out
N src/lib/libc/gdtoa/test/dItest.c
N src/lib/libc/gdtoa/test/dd.out
N src/lib/libc/gdtoa/test/ddsi.out
N src/lib/libc/gdtoa/test/ddtest.c
N src/lib/libc/gdtoa/test/dt.c
N src/lib/libc/gdtoa/test/dtest.c
N src/lib/libc/gdtoa/test/dtst.out
N src/lib/libc/gdtoa/test/f.out
N src/lib/libc/gdtoa/test/ftest.c
N src/lib/libc/gdtoa/test/makefile
N src/lib/libc/gdtoa/test/pfLqtestnos
N src/lib/libc/gdtoa/test/pftest.c
N src/lib/libc/gdtoa/test/pftestQ.out
N src/lib/libc/gdtoa/test/pftestx.out
N src/lib/libc/gdtoa/test/pftestLq.out
N src/lib/libc/gdtoa/test/pftestnos
N src/lib/libc/gdtoa/test/rtestnos
N src/lib/libc/gdtoa/test/testnos
N src/lib/libc/gdtoa/test/strtoIdSI.c
N src/lib/libc/gdtoa/test/strtoIddSI.c
N src/lib/libc/gdtoa/test/strtodISI.c
N src/lib/libc/gdtoa/test/strtodt.c
N src/lib/libc/gdtoa/test/strtopddSI.c
N src/lib/libc/gdtoa/test/strtorddSI.c
N src/lib/libc/gdtoa/test/testnos1
N src/lib/libc/gdtoa/test/testnos3
N src/lib/libc/gdtoa/test/x.ou0
N src/lib/libc/gdtoa/test/x.ou1
N src/lib/libc/gdtoa/test/xL.ou0
N src/lib/libc/gdtoa/test/xL.ou1
N src/lib/libc/gdtoa/test/xLtest.c
N src/lib/libc/gdtoa/test/xQtest.c
N src/lib/libc/gdtoa/test/xsum0.out
N src/lib/libc/gdtoa/test/xtest.c
N src/lib/libc/gdtoa/test/obad/strtodt.out
N src/lib/libc/gdtoa/test/obad/xL.out

46 conflicts created by this import.
Use the following command to help the merge:

cvs checkout -jDMG:yesterday -jDMG src/lib/libc/gdtoa



CVS commit: src/lib/libc/gdtoa

2011-03-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 19 21:26:02 UTC 2011

Removed Files:
src/lib/libc/gdtoa: printf.c printf.c0 stdio1.h

Log Message:
don't need these and they break the build


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r0 src/lib/libc/gdtoa/printf.c \
src/lib/libc/gdtoa/printf.c0 src/lib/libc/gdtoa/stdio1.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/gdtoa

2011-01-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 21 23:36:50 UTC 2011

Modified Files:
src/lib/libc/gdtoa: gdtoaimp.h

Log Message:
add may alias attribute to the double union because gcc-4.5.x produces
incorrect code on ARMv7a. From nikunj badjatya


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/gdtoa/gdtoaimp.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/gdtoaimp.h
diff -u src/lib/libc/gdtoa/gdtoaimp.h:1.7 src/lib/libc/gdtoa/gdtoaimp.h:1.8
--- src/lib/libc/gdtoa/gdtoaimp.h:1.7	Thu May  7 16:31:44 2009
+++ src/lib/libc/gdtoa/gdtoaimp.h	Fri Jan 21 18:36:49 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: gdtoaimp.h,v 1.7 2009/05/07 20:31:44 christos Exp $ */
+/* $NetBSD: gdtoaimp.h,v 1.8 2011/01/21 23:36:49 christos Exp $ */
 
 /
 
@@ -276,7 +276,7 @@
 Exactly one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be defined.
 #endif
 
-typedef union { double d; ULong L[2]; } U;
+typedef union { double d; ULong L[2]; } __attribute__((__may_alias__)) U;
 
 #ifdef YES_ALIAS
 #define dval(x) x



CVS commit: src/lib/libc/gdtoa

2010-01-17 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Jan 17 23:06:31 UTC 2010

Modified Files:
src/lib/libc/gdtoa: arithchk.c

Log Message:
Close file handle after using it. Found by cppcheck.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/gdtoa/arithchk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gdtoa/arithchk.c
diff -u src/lib/libc/gdtoa/arithchk.c:1.2 src/lib/libc/gdtoa/arithchk.c:1.3
--- src/lib/libc/gdtoa/arithchk.c:1.2	Wed Jan 25 15:27:42 2006
+++ src/lib/libc/gdtoa/arithchk.c	Sun Jan 17 23:06:31 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: arithchk.c,v 1.2 2006/01/25 15:27:42 kleink Exp $ */
+/* $NetBSD: arithchk.c,v 1.3 2010/01/17 23:06:31 wiz Exp $ */
 
 /
 Copyright (C) 1997, 1998 Lucent Technologies
@@ -178,8 +178,14 @@
 			fprintf(f, #define NO_LONG_LONG\n);
 		if (a-kind = 2  fzcheck())
 			fprintf(f, #define Sudden_Underflow\n);
+#ifdef WRITE_ARITH_H
+		fclose(f);
+#endif
 		return 0;
 		}
 	fprintf(f, /* Unknown arithmetic */\n);
+#ifdef WRITE_ARITH_H
+	fclose(f);
+#endif
 	return 1;
 	}