Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc Sync with compat and remove dup implementations of ...
details: https://anonhg.NetBSD.org/src/rev/c07b30392397
branches: trunk
changeset: 348167:c07b30392397
user: christos <christos%NetBSD.org@localhost>
date: Fri Oct 07 11:10:43 2016 +0000
description:
Sync with compat and remove dup implementations of ldexp and modf, switching
mips and m68k to the compat copies.
diffstat:
lib/libc/arch/m68k/gen/Makefile.inc | 6 +-
lib/libc/arch/mips/gen/Makefile.inc | 4 +-
lib/libc/compat/gen/compat_modf_ieee754.c | 4 +-
lib/libc/gen/ldexp_ieee754.c | 142 ------------------------------
lib/libc/gen/modf_ieee754.c | 102 ---------------------
5 files changed, 7 insertions(+), 251 deletions(-)
diffs (truncated from 312 to 300 lines):
diff -r b9330b28564d -r c07b30392397 lib/libc/arch/m68k/gen/Makefile.inc
--- a/lib/libc/arch/m68k/gen/Makefile.inc Fri Oct 07 10:58:03 2016 +0000
+++ b/lib/libc/arch/m68k/gen/Makefile.inc Fri Oct 07 11:10:43 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.33 2014/03/18 18:20:37 riastradh Exp $
+# $NetBSD: Makefile.inc,v 1.34 2016/10/07 11:10:44 christos Exp $
SRCS+= alloca.S fabs.S
@@ -32,7 +32,7 @@
# much of the (soft)float and integer support that would
# otherwise be compiled here.
.if (${MACHINE_ARCH} == "m68000" || ${MKSOFTFLOAT} == "yes")
-SRCS+= modf_ieee754.c # generic ieee754 version
+SRCS+= compat_modf_ieee754.c # generic ieee754 version
SRCS+= flt_rounds_softfloat.S
.if ${MKSOFTFLOAT} != "yes"
SRCS+= fpfake.c
@@ -49,7 +49,7 @@
SRCS+= makecontext.c resumecontext.S swapcontext.S
-SRCS+= ldexp_ieee754.c # generic ieee754 version
+SRCS+= compat_ldexp_ieee754.c # generic ieee754 version
LSRCS.m68k.gen= Lint_bswap16.c Lint_bswap32.c Lint_bswap64.c \
Lint_resumecontext.c Lint_swapcontext.c
diff -r b9330b28564d -r c07b30392397 lib/libc/arch/mips/gen/Makefile.inc
--- a/lib/libc/arch/mips/gen/Makefile.inc Fri Oct 07 10:58:03 2016 +0000
+++ b/lib/libc/arch/mips/gen/Makefile.inc Fri Oct 07 11:10:43 2016 +0000
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile.inc,v 1.34 2016/01/24 16:01:56 christos Exp $
+# $NetBSD: Makefile.inc,v 1.35 2016/10/07 11:10:44 christos Exp $
.if ${MKSOFTFLOAT} == "no"
SRCS+= fabs.S ldexp.S modf.S
.else
-SRCS+= fabs_ieee754.c ldexp_ieee754.c modf_ieee754.c
+SRCS+= fabs_ieee754.c compat_ldexp_ieee754.c compat_modf_ieee754.c
.endif
# Common ieee754 constants and functions
diff -r b9330b28564d -r c07b30392397 lib/libc/compat/gen/compat_modf_ieee754.c
--- a/lib/libc/compat/gen/compat_modf_ieee754.c Fri Oct 07 10:58:03 2016 +0000
+++ b/lib/libc/compat/gen/compat_modf_ieee754.c Fri Oct 07 11:10:43 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_modf_ieee754.c,v 1.4 2010/04/23 19:04:54 drochner Exp $ */
+/* $NetBSD: compat_modf_ieee754.c,v 1.5 2016/10/07 11:10:44 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
@@ -93,7 +93,7 @@
frac = ((u_int64_t)v.dblu_dbl.dbl_frach << 32) + v.dblu_dbl.dbl_fracl;
frac >>= DBL_FRACBITS - (u.dblu_dbl.dbl_exp - DBL_EXP_BIAS);
frac <<= DBL_FRACBITS - (u.dblu_dbl.dbl_exp - DBL_EXP_BIAS);
- v.dblu_dbl.dbl_fracl = (unsigned int)frac & 0xffffffff;
+ v.dblu_dbl.dbl_fracl = (unsigned int)(frac & 0xffffffffULL);
v.dblu_dbl.dbl_frach = (unsigned int)(frac >> 32);
*iptr = v.dblu_d;
diff -r b9330b28564d -r c07b30392397 lib/libc/gen/ldexp_ieee754.c
--- a/lib/libc/gen/ldexp_ieee754.c Fri Oct 07 10:58:03 2016 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/* $NetBSD: ldexp_ieee754.c,v 1.5 2008/04/28 20:22:59 martin Exp $ */
-
-/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: ldexp_ieee754.c,v 1.5 2008/04/28 20:22:59 martin Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <machine/ieee.h>
-#include <errno.h>
-#include <math.h>
-
-/*
- * Multiply the given value by 2^expon.
- */
-double
-ldexp(double val, int expon)
-{
- int oldexp, newexp;
- union ieee_double_u u, mul;
-
- u.dblu_d = val;
- oldexp = u.dblu_dbl.dbl_exp;
-
- /*
- * If input is zero, Inf or NaN, just return it.
- */
- if (u.dblu_d == 0.0 || oldexp == DBL_EXP_INFNAN)
- return (val);
-
- if (oldexp == 0) {
- /*
- * u.v is denormal. We must adjust it so that the exponent
- * arithmetic below will work.
- */
- if (expon <= DBL_EXP_BIAS) {
- /*
- * Optimization: if the scaling can be done in a single
- * multiply, or underflows, just do it now.
- */
- if (expon <= -DBL_FRACBITS) {
- errno = ERANGE;
- return (val < 0.0 ? -0.0 : 0.0);
- }
- mul.dblu_d = 0.0;
- mul.dblu_dbl.dbl_exp = expon + DBL_EXP_BIAS;
- u.dblu_d *= mul.dblu_d;
- if (u.dblu_d == 0.0) {
- errno = ERANGE;
- return (val < 0.0 ? -0.0 : 0.0);
- }
- return (u.dblu_d);
- } else {
- /*
- * We know that expon is very large, and therefore the
- * result cannot be denormal (though it may be Inf).
- * Shift u.v by just enough to make it normal.
- */
- mul.dblu_d = 0.0;
- mul.dblu_dbl.dbl_exp = DBL_FRACBITS + DBL_EXP_BIAS;
- u.dblu_d *= mul.dblu_d;
- expon -= DBL_FRACBITS;
- oldexp = u.dblu_dbl.dbl_exp;
- }
- }
-
- /*
- * u.v is now normalized and oldexp has been adjusted if necessary.
- * Calculate the new exponent and check for underflow and overflow.
- */
- newexp = oldexp + expon;
-
- if (newexp <= 0) {
- /*
- * The output number is either denormal or underflows (see
- * comments in machine/ieee.h).
- */
- if (newexp <= -DBL_FRACBITS) {
- errno = ERANGE;
- return (val < 0.0 ? -0.0 : 0.0);
- }
- /*
- * Denormalize the result. We do this with a multiply. If
- * expon is very large, it won't fit in a double, so we have
- * to adjust the exponent first. This is safe because we know
- * that u.v is normal at this point.
- */
- if (expon <= -DBL_EXP_BIAS) {
- u.dblu_dbl.dbl_exp = 1;
- expon += oldexp - 1;
- }
- mul.dblu_d = 0.0;
- mul.dblu_dbl.dbl_exp = expon + DBL_EXP_BIAS;
- u.dblu_d *= mul.dblu_d;
- return (u.dblu_d);
- } else if (newexp >= DBL_EXP_INFNAN) {
- /*
- * The result overflowed; return +/-Inf.
- */
- u.dblu_dbl.dbl_exp = DBL_EXP_INFNAN;
- u.dblu_dbl.dbl_frach = 0;
- u.dblu_dbl.dbl_fracl = 0;
- errno = ERANGE;
- return (u.dblu_d);
- } else {
- /*
- * The result is normal; just replace the old exponent with the
- * new one.
- */
- u.dblu_dbl.dbl_exp = newexp;
- return (u.dblu_d);
- }
-}
diff -r b9330b28564d -r c07b30392397 lib/libc/gen/modf_ieee754.c
--- a/lib/libc/gen/modf_ieee754.c Fri Oct 07 10:58:03 2016 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/* $NetBSD: modf_ieee754.c,v 1.4 2012/03/22 13:25:45 he Exp $ */
-
-/*
- * Copyright (c) 1994, 1995 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Author: Chris G. Demetriou
- *
- * Permission to use, copy, modify and distribute this software and
- * its documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution%CS.CMU.EDU@localhost
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- */
-
-#include <sys/types.h>
-#include <machine/ieee.h>
-#include <errno.h>
-#include <math.h>
-
-/*
- * double modf(double val, double *iptr)
- * returns: f and i such that |f| < 1.0, (f + i) = val, and
- * sign(f) == sign(i) == sign(val).
- *
- * Beware signedness when doing subtraction, and also operand size!
- */
-double
-modf(double val, double *iptr)
-{
- union ieee_double_u u, v;
- u_int64_t frac;
-
- /*
- * If input is +/-Inf or NaN, return +/-0 or NaN.
- */
- u.dblu_d = val;
- if (u.dblu_dbl.dbl_exp == DBL_EXP_INFNAN) {
- *iptr = u.dblu_d;
- return (0.0 / u.dblu_d);
- }
-
- /*
- * If input can't have a fractional part, return
- * (appropriately signed) zero, and make i be the input.
- */
- if ((int)u.dblu_dbl.dbl_exp - DBL_EXP_BIAS > DBL_FRACBITS - 1) {
- *iptr = u.dblu_d;
- v.dblu_d = 0.0;
- v.dblu_dbl.dbl_sign = u.dblu_dbl.dbl_sign;
- return (v.dblu_d);
- }
-
- /*
- * If |input| < 1.0, return it, and set i to the appropriately
- * signed zero.
- */
- if (u.dblu_dbl.dbl_exp < DBL_EXP_BIAS) {
- v.dblu_d = 0.0;
- v.dblu_dbl.dbl_sign = u.dblu_dbl.dbl_sign;
- *iptr = v.dblu_d;
- return (u.dblu_d);
- }
-
- /*
- * There can be a fractional part of the input.
- * If you look at the math involved for a few seconds, it's
- * plain to see that the integral part is the input, with the
- * low (DBL_FRACBITS - (exponent - DBL_EXP_BIAS)) bits zeroed,
- * the fractional part is the part with the rest of the
- * bits zeroed. Just zeroing the high bits to get the
- * fractional part would yield a fraction in need of
- * normalization. Therefore, we take the easy way out, and
- * just use subtraction to get the fractional part.
- */
- v.dblu_d = u.dblu_d;
Home |
Main Index |
Thread Index |
Old Index