diff options
author | 2011-06-08 22:14:17 +0000 | |
---|---|---|
committer | 2011-06-08 22:14:17 +0000 | |
commit | b29f7ea2fd993ca09c73f7d93dc5dc04e417d2cf (patch) | |
tree | df03f84cbfde88b6b4663889e411198f6eeba8e5 /lib/libc | |
parent | On ARM, make GCC generate code which uses our library fabs, fabsf, (diff) | |
download | wireguard-openbsd-b29f7ea2fd993ca09c73f7d93dc5dc04e417d2cf.tar.xz wireguard-openbsd-b29f7ea2fd993ca09c73f7d93dc5dc04e417d2cf.zip |
- The 0x1p514 was wrong on VAX, but remove FP_SUBNORMAL, FP_INFINITE,
and FP_NAN cases altogether, since they are not supported, and
fpclassify() will never return that. (Leftovers when this was cloned.)
- Kill unused INFSTR, NANSTR, LDBL_ADJ.
- Teach hdtoa() that rv_alloc can fail.
- Move STRTOG_NoMemory above STRTOG_Infinite (fallthru).
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/arch/vax/gdtoa/hdtoa.c | 19 | ||||
-rw-r--r-- | lib/libc/arch/vax/gdtoa/strtof.c | 7 |
2 files changed, 6 insertions, 20 deletions
diff --git a/lib/libc/arch/vax/gdtoa/hdtoa.c b/lib/libc/arch/vax/gdtoa/hdtoa.c index dc95c0e2eae..a844e251767 100644 --- a/lib/libc/arch/vax/gdtoa/hdtoa.c +++ b/lib/libc/arch/vax/gdtoa/hdtoa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hdtoa.c,v 1.1 2008/09/07 20:36:08 martynas Exp $ */ +/* $OpenBSD: hdtoa.c,v 1.2 2011/06/08 22:14:17 martynas Exp $ */ /*- * Copyright (c) 2004, 2005 David Schultz <das@FreeBSD.ORG> * All rights reserved. @@ -33,12 +33,7 @@ #include "gdtoaimp.h" -/* Strings values used by dtoa() */ -#define INFSTR "Infinity" -#define NANSTR "NaN" - #define DBL_ADJ (DBL_MAX_EXP - 2 + ((DBL_MANT_DIG - 1) % 4)) -#define LDBL_ADJ (LDBL_MAX_EXP - 2 + ((LDBL_MANT_DIG - 1) % 4)) /* * Round up the given digit string. If the digit string is fff...f, @@ -137,16 +132,6 @@ __hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign, case FP_ZERO: *decpt = 1; return (nrv_alloc("0", rve, 1)); - case FP_SUBNORMAL: - d *= 0x1p514; - *decpt = p->dflt_exp - (514 + DBL_ADJ); - break; - case FP_INFINITE: - *decpt = INT_MAX; - return (nrv_alloc(INFSTR, rve, sizeof(INFSTR) - 1)); - case FP_NAN: - *decpt = INT_MAX; - return (nrv_alloc(NANSTR, rve, sizeof(NANSTR) - 1)); default: abort(); } @@ -162,6 +147,8 @@ __hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign, */ bufsize = (sigfigs > ndigits) ? sigfigs : ndigits; s0 = rv_alloc(bufsize); + if (s0 == NULL) + return (NULL); /* * We work from right to left, first adding any requested zero diff --git a/lib/libc/arch/vax/gdtoa/strtof.c b/lib/libc/arch/vax/gdtoa/strtof.c index 11105f0effd..7406440582c 100644 --- a/lib/libc/arch/vax/gdtoa/strtof.c +++ b/lib/libc/arch/vax/gdtoa/strtof.c @@ -62,13 +62,12 @@ strtof(CONST char *s, char **sp) ((exp + 128 + 1 + 23) << 7); /* Exp */ break; + case STRTOG_NoMemory: + errno = ERANGE; + /* FALLTHROUGH */ case STRTOG_Infinite: u.L[0] = 0xffff7fff; break; - - case STRTOG_NoMemory: - errno = ERANGE; - return (HUGE_VALF); } if (k & STRTOG_Neg) u.L[0] |= 0x00008000L; |