From e68a749109ce3b7c4e8748c93d741fa7988f7a7d Mon Sep 17 00:00:00 2001 From: Martynas Venckus Date: Sat, 9 Jul 2011 02:13:54 +0000 Subject: Don't reimplement the same thing twice. OK matthew@. --- lib/libm/Makefile | 8 +++---- lib/libm/arch/amd64/s_scalbn.S | 21 ------------------ lib/libm/arch/i387/s_scalbn.S | 14 ------------ lib/libm/arch/mc68881/s_scalbn.S | 47 ---------------------------------------- lib/libm/src/s_scalbn.c | 31 +------------------------- 5 files changed, 5 insertions(+), 116 deletions(-) delete mode 100644 lib/libm/arch/amd64/s_scalbn.S delete mode 100644 lib/libm/arch/i387/s_scalbn.S delete mode 100644 lib/libm/arch/mc68881/s_scalbn.S (limited to 'lib') diff --git a/lib/libm/Makefile b/lib/libm/Makefile index 1e7d5c65c8b..987a53d2ab8 100644 --- a/lib/libm/Makefile +++ b/lib/libm/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.91 2011/07/08 22:58:54 martynas Exp $ +# $OpenBSD: Makefile,v 1.92 2011/07/09 02:13:52 martynas Exp $ # $NetBSD: Makefile,v 1.28 1995/11/20 22:06:19 jtc Exp $ # # @(#)Makefile 5.1beta 93/09/24 @@ -29,7 +29,7 @@ ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_fmod.S e_log.S e_log10.S \ s_cos.S s_cosf.S s_floor.S s_floorf.S \ s_ilogb.S s_ilogbf.S s_log1p.S s_log1pf.S s_logb.S s_logbf.S \ s_llrint.S s_llrintf.S s_lrint.S s_lrintf.S s_rint.S s_rintf.S\ - s_scalbn.S s_scalbnf.S s_significand.S s_significandf.S \ + s_scalbnf.S s_significand.S s_significandf.S \ s_sin.S s_sinf.S s_tan.S s_tanf.S .elif (${MACHINE_ARCH} == "amd64") .PATH: ${.CURDIR}/arch/amd64 @@ -42,7 +42,7 @@ ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_fmod.S e_log.S e_log10.S \ s_cos.S s_cosf.S s_floor.S s_floorf.S \ s_ilogb.S s_ilogbf.S s_log1p.S s_log1pf.S s_logb.S s_logbf.S \ s_llrint.S s_llrintf.S s_lrint.S s_lrintf.S \ - s_rint.S s_rintf.S s_scalbn.S s_scalbnf.S s_significand.S \ + s_rint.S s_rintf.S s_scalbnf.S s_significand.S \ s_significandf.S s_sin.S s_sinf.S s_tan.S s_tanf.S .elif (${MACHINE_ARCH} == "m68k") .PATH: ${.CURDIR}/arch/mc68881 @@ -54,7 +54,7 @@ ARCH_SRCS = e_acos.S e_acosf.S e_acosl.S e_asin.S e_asinf.S e_asinl.S \ s_copysign.S s_copysignf.S s_copysignl.S s_cos.S s_cosf.S s_cosl.S \ s_expm1.S s_expm1f.S s_floor.S s_floorf.S s_log1p.S s_log1pf.S \ s_logb.S s_logbf.S s_logbl.S s_rint.S s_rintf.S s_rintl.S \ - s_scalbn.S s_scalbnf.S s_scalbnl.S s_sin.S s_sinf.S s_sinl.S \ + s_scalbnf.S s_scalbnl.S s_sin.S s_sinf.S s_sinl.S \ s_tan.S s_tanf.S s_tanl.S s_tanh.S s_tanhf.S .elif (${MACHINE_ARCH} == "hppa") .PATH: ${.CURDIR}/arch/hppa diff --git a/lib/libm/arch/amd64/s_scalbn.S b/lib/libm/arch/amd64/s_scalbn.S deleted file mode 100644 index 3bdea28efaf..00000000000 --- a/lib/libm/arch/amd64/s_scalbn.S +++ /dev/null @@ -1,21 +0,0 @@ -/* $OpenBSD: s_scalbn.S,v 1.3 2009/04/25 11:03:35 martynas Exp $ */ -/* - * Written by J.T. Conklin . - * Public domain. - */ - -#include - -#include "abi.h" - -ENTRY(scalbn) - movsd %xmm0,-8(%rsp) - movl %edi,-12(%rsp) - fildl -12(%rsp) - fldl -8(%rsp) - fscale - fstp %st(1) /* bug fix for fp stack overflow */ - fstpl -8(%rsp) - movsd -8(%rsp),%xmm0 - ret - diff --git a/lib/libm/arch/i387/s_scalbn.S b/lib/libm/arch/i387/s_scalbn.S deleted file mode 100644 index a1881926615..00000000000 --- a/lib/libm/arch/i387/s_scalbn.S +++ /dev/null @@ -1,14 +0,0 @@ -/* $OpenBSD: s_scalbn.S,v 1.3 2005/08/02 11:17:31 espie Exp $ */ -/* - * Written by J.T. Conklin . - * Public domain. - */ - -#include - -ENTRY(scalbn) - fildl 12(%esp) - fldl 4(%esp) - fscale - fstp %st(1) /* bug fix for fp stack overflow */ - ret diff --git a/lib/libm/arch/mc68881/s_scalbn.S b/lib/libm/arch/mc68881/s_scalbn.S deleted file mode 100644 index 98713a09370..00000000000 --- a/lib/libm/arch/mc68881/s_scalbn.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: s_scalbn.S,v 1.3 2005/08/02 11:17:32 espie Exp $ */ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. 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 - -| scalbn(x, N) -| returns x * (2**N), for integer values N. -ENTRY(scalbn) - fmoved sp@(4),fp0 - fbeq Ldone - fscalel sp@(12),fp0 -Ldone: - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/src/s_scalbn.c b/lib/libm/src/s_scalbn.c index aa9973d43f6..da5be29c36c 100644 --- a/lib/libm/src/s_scalbn.c +++ b/lib/libm/src/s_scalbn.c @@ -23,39 +23,10 @@ #include #include -#include "math_private.h" - -static const double -two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ -twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ -huge = 1.0e+300, -tiny = 1.0e-300; - double scalbn (double x, int n) { - int32_t k,hx,lx; - EXTRACT_WORDS(hx,lx,x); - k = (hx&0x7ff00000)>>20; /* extract exponent */ - if (k==0) { /* 0 or subnormal x */ - if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */ - x *= two54; - GET_HIGH_WORD(hx,x); - k = ((hx&0x7ff00000)>>20) - 54; - if (n< -50000) return tiny*x; /*underflow*/ - } - if (k==0x7ff) return x+x; /* NaN or Inf */ - k = k+n; - if (k > 0x7fe) return huge*copysign(huge,x); /* overflow */ - if (k > 0) /* normal result */ - {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;} - if (k <= -54) - if (n > 50000) /* in case integer overflow in n+k */ - return huge*copysign(huge,x); /*overflow*/ - else return tiny*copysign(tiny,x); /*underflow*/ - k += 54; /* subnormal result */ - SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); - return x*twom54; + ldexp(x, n); } #if LDBL_MANT_DIG == 53 -- cgit v1.2.3