Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/arch/ns32k/gen Use the C version. The assembler ve...



details:   https://anonhg.NetBSD.org/src/rev/acf368a6f760
branches:  trunk
changeset: 475904:acf368a6f760
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Sun Aug 29 18:32:36 1999 +0000

description:
Use the C version.  The assembler version was just transliterated (and buggy)
anyway.

diffstat:

 lib/libc/arch/ns32k/gen/Makefile.inc |   6 +-
 lib/libc/arch/ns32k/gen/frexp.S      |  66 ---------------------------
 lib/libc/arch/ns32k/gen/frexp.c      |  85 ++++++++++++++++++++++++++++++++++++
 3 files changed, 88 insertions(+), 69 deletions(-)

diffs (178 lines):

diff -r bee58e67e630 -r acf368a6f760 lib/libc/arch/ns32k/gen/Makefile.inc
--- a/lib/libc/arch/ns32k/gen/Makefile.inc      Sun Aug 29 18:32:15 1999 +0000
+++ b/lib/libc/arch/ns32k/gen/Makefile.inc      Sun Aug 29 18:32:36 1999 +0000
@@ -1,7 +1,7 @@
-#      $NetBSD: Makefile.inc,v 1.10 1999/08/29 18:11:28 mycroft Exp $
+#      $NetBSD: Makefile.inc,v 1.11 1999/08/29 18:32:36 mycroft Exp $
 
 # objects built from assembler sources (need lint stubs)
-ASSRCS+=alloca.S fabs.S frexp.S ldexp.S modf.S
+ASSRCS+=alloca.S fabs.S ldexp.S modf.S
 
 ASSRCS+=__setjmp14.S
 ASSRCS+=_setjmp.S
@@ -12,4 +12,4 @@
 
 # objects built from C sources
 SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
-       fpsetround.c fpsetsticky.c infinity.c isinf.c isnan.c bswap64.c
+       fpsetround.c fpsetsticky.c infinity.c frexp.c isinf.c isnan.c bswap64.c
diff -r bee58e67e630 -r acf368a6f760 lib/libc/arch/ns32k/gen/frexp.S
--- a/lib/libc/arch/ns32k/gen/frexp.S   Sun Aug 29 18:32:15 1999 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*     $NetBSD: frexp.S,v 1.2 1997/05/08 13:38:38 matthias Exp $       */
-
-/* 
- * Copyright (c) 1992 Helsinki University of Technology
- * All Rights Reserved.
- * 
- * 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.
- * 
- * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN
- * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY
- * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE
- * USE OF THIS SOFTWARE.
- */
-/*
- * HISTORY
- * 29-Apr-92  Tero Kivinen (kivinen) at Helsinki University of Technology
- *     Created.
- */
-
-/*
- * double frexp(value, eptr)
- * double value;
- * int *eptr;
- *
- * The frexp subroutine returns the mantissa of a double value
- * as a double quantity, x, of magnitude less than one and
- * greater than or equal to 0.5 (0.5 <= |x| < 1) and stores an
- * integer n such that value = x*2**n indirectly through eptr.
- *
- * One exception: if the given value is 0, then x and *eptr are made
- * zero. 
- */
-
-#include <machine/asm.h>
-
-#if defined(LIBC_SCCS)
-       RCSID("$NetBSD: frexp.S,v 1.2 1997/05/08 13:38:38 matthias Exp $")
-#endif
-
-ENTRY(frexp)
-       enter   [],8
-       movd    12(fp),r1       /* value, high 32 bit */
-       cmpd    0,r1            /* check if 0 */ 
-       beq     0f              /* we do not support denormalized values */
-       movd    r1,r2
-       bicd    0x7ff00000,r2   /* clear exponent */
-       ord     0x3fe00000,r2   /* set it to 1024 == exponent -11 == .5-1 */
-       lshd    -20,r1          /* extract exponent */
-       andd    0x7ff,r1        /* 11 lower bits */
-       subd    1022,r1         /* unbias exponent */
-       movd    r1,0(16(fp))
-       movd    8(fp),-8(fp)    /* value, low 32 bit */
-       movd    r2,-4(fp)       /* value without exponent, high 32 bit */
-       movl    -8(fp),f0       /* load return value */
-       exit    []
-       ret     0
-
-0:     movqd   0,0(16(fp))     /* return exp = 0, mantissa = 9 */
-       movdl   0,f0
-       exit    []
-       ret     0
-
diff -r bee58e67e630 -r acf368a6f760 lib/libc/arch/ns32k/gen/frexp.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/ns32k/gen/frexp.c   Sun Aug 29 18:32:36 1999 +0000
@@ -0,0 +1,85 @@
+/*     $NetBSD: frexp.c,v 1.1 1999/08/29 18:32:36 mycroft 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.
+ *
+ * from: Header: frexp.c,v 1.1 91/07/07 04:45:01 torek Exp
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)frexp.c    8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: frexp.c,v 1.1 1999/08/29 18:32:36 mycroft Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <machine/ieee.h>
+#include <math.h>
+
+/*
+ * Split the given value into a fraction in the range [0.5, 1.0) and
+ * an exponent, such that frac * (2^exp) == value.  If value is 0,
+ * return 0.
+ */
+double
+frexp(value, eptr)
+       double value;
+       int *eptr;
+{
+       union {
+                double v;
+               struct ieee_double s;
+       } u;
+
+       if (value) {
+               /*
+                * Fractions in [0.5..1.0) have an exponent of 2^-1.
+                * Leave Inf and NaN alone, however.
+                * WHAT ABOUT DENORMS?
+                */
+               u.v = value;
+               if (u.s.dbl_exp != DBL_EXP_INFNAN) {
+                       *eptr = u.s.dbl_exp - (DBL_EXP_BIAS - 1);
+                       u.s.dbl_exp = DBL_EXP_BIAS - 1;
+               }
+               return (u.v);
+       } else {
+               *eptr = 0;
+               return (0.0);
+       }
+}



Home | Main Index | Thread Index | Old Index