Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/arch/hppa/gen * Use the common ieee754_* routines (...
details: https://anonhg.NetBSD.org/src/rev/ed0e75732724
branches: trunk
changeset: 538700:ed0e75732724
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Oct 26 06:44:54 2002 +0000
description:
* Use the common ieee754_* routines (and add ones we were missing).
* Note that several routines are still missing for hppa.
diffstat:
lib/libc/arch/hppa/gen/Makefile.inc | 17 ++-
lib/libc/arch/hppa/gen/infinity.c | 16 ---
lib/libc/arch/hppa/gen/isinf.c | 64 --------------
lib/libc/arch/hppa/gen/isnan.c | 64 --------------
lib/libc/arch/hppa/gen/ldexp.c | 154 ------------------------------------
5 files changed, 12 insertions(+), 303 deletions(-)
diffs (truncated from 337 to 300 lines):
diff -r 9b5e97162502 -r ed0e75732724 lib/libc/arch/hppa/gen/Makefile.inc
--- a/lib/libc/arch/hppa/gen/Makefile.inc Sat Oct 26 06:03:50 2002 +0000
+++ b/lib/libc/arch/hppa/gen/Makefile.inc Sat Oct 26 06:44:54 2002 +0000
@@ -1,7 +1,14 @@
-# $NetBSD: Makefile.inc,v 1.2 2002/07/01 16:00:51 fredette Exp $
+# $NetBSD: Makefile.inc,v 1.3 2002/10/26 06:44:54 thorpej Exp $
-# $OpenBSD: Makefile.inc,v 1.2 1999/09/14 00:21:15 mickey Exp $
+SRCS+= bswap16.c bswap32.c bswap64.c __sigsetjmp14.S __setjmp14.S _setjmp.S
-SRCS+= isnan.c isinf.c infinity.c ldexp.c \
- bswap16.c bswap32.c bswap64.c \
- __sigsetjmp14.S __setjmp14.S _setjmp.S
+# Common ieee754 constants and functions
+SRCS+= ieee754_infinity.c ieee754_nanf.c
+SRCS+= ieee754_frexp.c ieee754_ldexp.c
+SRCS+= ieee754_isinf.c
+SRCS+= ieee754_isnan.c
+SRCS+= ieee754_modf.c
+
+# XXX Missing:
+# fabs, flt_rounds, fpgetmask, fpgetround, fpgetsticky
+# fpsetmask, fpsetround, fpsetsticky
diff -r 9b5e97162502 -r ed0e75732724 lib/libc/arch/hppa/gen/infinity.c
--- a/lib/libc/arch/hppa/gen/infinity.c Sat Oct 26 06:03:50 2002 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-/* $NetBSD: infinity.c,v 1.1 2002/06/06 20:31:21 fredette Exp $ */
-
-/* $OpenBSD: infinity.c,v 1.2 2001/01/24 08:19:02 mickey Exp $ */
-
-/* infinity.c */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$OpenBSD: infinity.c,v 1.2 2001/01/24 08:19:02 mickey Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include <math.h>
-
-/* bytes for +Infinity on a hppa */
-__const union __double_u __infinity __attribute__((__aligned__(sizeof(double)))) =
- { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } };
diff -r 9b5e97162502 -r ed0e75732724 lib/libc/arch/hppa/gen/isinf.c
--- a/lib/libc/arch/hppa/gen/isinf.c Sat Oct 26 06:03:50 2002 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/* $NetBSD: isinf.c,v 1.1 2002/06/06 20:31:21 fredette Exp $ */
-
-/* $OpenBSD: isinf.c,v 1.2 2001/09/10 22:38:11 millert Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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("$OpenBSD: isinf.c,v 1.2 2001/09/10 22:38:11 millert Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include "namespace.h"
-#include <sys/types.h>
-#include <machine/ieee.h>
-#include <math.h>
-
-#ifdef __weak_alias
-__weak_alias(isinf,_isinf)
-#endif
-
-int
-isinf(d)
- double d;
-{
- struct ieee_double *p = (struct ieee_double *)&d;
-
- return (p->dbl_exp == DBL_EXP_INFNAN &&
- p->dbl_frach == 0 && p->dbl_fracl == 0);
-}
diff -r 9b5e97162502 -r ed0e75732724 lib/libc/arch/hppa/gen/isnan.c
--- a/lib/libc/arch/hppa/gen/isnan.c Sat Oct 26 06:03:50 2002 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/* $NetBSD: isnan.c,v 1.1 2002/06/06 20:31:21 fredette Exp $ */
-
-/* $OpenBSD: isnan.c,v 1.2 2001/09/10 22:38:11 millert Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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("$OpenBSD: isnan.c,v 1.2 2001/09/10 22:38:11 millert Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include "namespace.h"
-#include <sys/types.h>
-#include <machine/ieee.h>
-#include <math.h>
-
-#ifdef __weak_alias
-__weak_alias(isnan,_isnan)
-#endif
-
-int
-isnan(d)
- double d;
-{
- struct ieee_double *p = (struct ieee_double *)&d;
-
- return (p->dbl_exp == DBL_EXP_INFNAN &&
- (p->dbl_frach != 0 || p->dbl_fracl != 0));
-}
diff -r 9b5e97162502 -r ed0e75732724 lib/libc/arch/hppa/gen/ldexp.c
--- a/lib/libc/arch/hppa/gen/ldexp.c Sat Oct 26 06:03:50 2002 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/* $NetBSD: ldexp.c,v 1.1 2002/06/06 20:31:21 fredette 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * 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.c,v 1.1 2002/06/06 20:31:21 fredette 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^exponent.
- */
-double
-ldexp(val, expo)
- double val;
- int expo;
-{
- register int oldexp, newexp;
- union {
- double v;
- struct ieee_double s;
- } u, mul;
-
- u.v = val;
- oldexp = u.s.dbl_exp;
-
- /*
- * If input is zero, Inf or NaN, just return it.
- */
- if (u.v == 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 (expo <= DBL_EXP_BIAS) {
- /*
- * Optimization: if the scaling can be done in a single
- * multiply, or underflows, just do it now.
- */
- if (expo <= -DBL_FRACBITS) {
- errno = ERANGE;
- return (0.0);
- }
- mul.v = 0.0;
- mul.s.dbl_exp = expo + DBL_EXP_BIAS;
- u.v *= mul.v;
- if (u.v == 0.0) {
- errno = ERANGE;
- return (0.0);
- }
- return (u.v);
- } else {
- /*
- * We know that expo 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.v = 0.0;
- mul.s.dbl_exp = DBL_FRACBITS + DBL_EXP_BIAS;
- u.v *= mul.v;
- expo -= DBL_FRACBITS;
- oldexp = u.s.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 + expo;
-
- if (newexp <= 0) {
- /*
- * The output number is either denormal or underflows (see
- * comments in machine/ieee.h).
Home |
Main Index |
Thread Index |
Old Index