Index: Makefile =================================================================== RCS file: /cvsroot/src/lib/libm/Makefile,v retrieving revision 1.92 diff -u -r1.92 Makefile --- Makefile 11 Jan 2010 16:28:39 -0000 1.92 +++ Makefile 22 Mar 2010 22:50:42 -0000 @@ -152,12 +152,34 @@ .endif # math routines for non-IEEE architectures. -NOIEEE_SRCS = n_asincos.c n_acosh.c n_asinh.c n_atan.c n_atanh.c n_cosh.c \ - n_erf.c n_exp.c n_exp__E.c n_expm1.c n_floor.c n_fmod.c n_gamma.c \ - n_lgamma.c n_j0.c n_j1.c n_jn.c n_log.c n_log10.c n_log1p.c \ - n_log__L.c n_pow.c n_sinh.c n_tanh.c \ - n_sincos.c n_tan.c \ - n_round.c n_roundf.c +NOIEEE_SRCS+= n_asincos.c +NOIEEE_SRCS+= n_acosh.c +NOIEEE_SRCS+= n_asinh.c n_asinhf.c n_asinhl.c +NOIEEE_SRCS+= n_atan.c +NOIEEE_SRCS+= n_atanh.c +NOIEEE_SRCS+= n_cosh.c +NOIEEE_SRCS+= n_erf.c +NOIEEE_SRCS+= n_exp.c +NOIEEE_SRCS+= n_exp__E.c +NOIEEE_SRCS+= n_expm1.c +NOIEEE_SRCS+= n_floor.c +NOIEEE_SRCS+= n_fmod.c +NOIEEE_SRCS+= n_gamma.c +NOIEEE_SRCS+= n_lgamma.c +NOIEEE_SRCS+= n_j0.c +NOIEEE_SRCS+= n_j1.c +NOIEEE_SRCS+= n_jn.c +NOIEEE_SRCS+= n_log.c +NOIEEE_SRCS+= n_log10.c +NOIEEE_SRCS+= n_log1p.c n_log1pf.c +NOIEEE_SRCS+= n_log__L.c +NOIEEE_SRCS+= n_pow.c +NOIEEE_SRCS+= n_sinh.c +NOIEEE_SRCS+= n_tanh.c +NOIEEE_SRCS+= n_sincos.c +NOIEEE_SRCS+= n_tan.c +NOIEEE_SRCS+= n_round.c +NOIEEE_SRCS+= n_roundf.c # n_sqrt.c n_argred.c n_infnan.c n_atan2.c n_cabs.c n_cbrt.c n_support.c Index: arch/vax/n_argred.S =================================================================== RCS file: /cvsroot/src/lib/libm/arch/vax/n_argred.S,v retrieving revision 1.9 diff -u -r1.9 n_argred.S --- arch/vax/n_argred.S 19 Apr 2007 00:37:20 -0000 1.9 +++ arch/vax/n_argred.S 22 Mar 2010 22:50:43 -0000 @@ -121,11 +121,7 @@ even: rsb -#ifdef __ELF__ .section .rodata -#else - .text -#endif _ALIGN_TEXT sin_coef: Index: arch/vax/n_atan2.S =================================================================== RCS file: /cvsroot/src/lib/libm/arch/vax/n_atan2.S,v retrieving revision 1.8 diff -u -r1.8 n_atan2.S --- arch/vax/n_atan2.S 20 Mar 2008 18:49:39 -0000 1.8 +++ arch/vax/n_atan2.S 22 Mar 2010 22:50:43 -0000 @@ -72,19 +72,16 @@ * atan2(y,x) returns the exact ARG(x+iy) nearly rounded. */ -#ifdef WEAK_ALIAS WEAK_ALIAS(atan2f, _atan2f) -#endif - ENTRY(_atan2f, 0) cvtfd 4(%ap),-(%sp) calls $2,_C_LABEL(_atan2) cvtdf %r0,%r0 ret -#ifdef WEAK_ALIAS WEAK_ALIAS(atan2, _atan2) -#endif +WEAK_ALIAS(atan2l, _atan2) +STRONG_ALIAS(_atan2l, _atan2) ENTRY(_atan2, 0x0fc0) movq 4(%ap),%r2 # %r2 = y @@ -211,6 +208,7 @@ movq $0x8000,%r0 # propagate the reserved operand ret + .section .rodata _ALIGN_TEXT ptable: .quad 0xb50f5ce96e7abd60 Index: arch/vax/n_cabs.S =================================================================== RCS file: /cvsroot/src/lib/libm/arch/vax/n_cabs.S,v retrieving revision 1.6 diff -u -r1.6 n_cabs.S --- arch/vax/n_cabs.S 20 Mar 2008 16:41:26 -0000 1.6 +++ arch/vax/n_cabs.S 22 Mar 2010 22:50:43 -0000 @@ -32,6 +32,8 @@ #include + RCSID("$NetBSD$") + .globl _C_LABEL(__libm_dsqrt_r5) /* * double precision complex absolute value @@ -43,9 +45,7 @@ */ /* entry for c functions cabs and hypot */ -#ifdef WEAK_ALIAS WEAK_ALIAS(hypotf, _hypotf) -#endif ENTRY(_hypotf, 0) cvtfd 4(%ap),-(%sp) @@ -53,11 +53,10 @@ cvtdf %r0,%r0 ret -#ifdef WEAK_ALIAS WEAK_ALIAS(hypot, _hypot) -#endif +WEAK_ALIAS(hypotl, _hypot) +STRONG_ALIAS(_hypotl, _hypot) -ALTENTRY(cabs) ENTRY(_hypot, 0x8040) # save %r6, enable floating overflow movq 4(%ap),%r0 # %r0:1 = x movq 12(%ap),%r2 # %r2:3 = y @@ -67,7 +66,7 @@ ENTRY(z_abs, 0x8040) # save %r6, enable floating overflow movl 4(%ap),%r2 # indirect addressing is necessary here movq (%r2)+,%r0 # %r0:1 = x - movq (%r2),%r2 # %r2:3 = y + movq (%r2),%r2 # %r2:3 = y cabs2: bicw3 $0x7f,%r0,%r4 # %r4 has signed biased exp of x Index: arch/vax/n_cbrt.S =================================================================== RCS file: /cvsroot/src/lib/libm/arch/vax/n_cbrt.S,v retrieving revision 1.6 diff -u -r1.6 n_cbrt.S --- arch/vax/n_cbrt.S 7 Aug 2003 16:44:45 -0000 1.6 +++ arch/vax/n_cbrt.S 22 Mar 2010 22:50:43 -0000 @@ -32,6 +32,9 @@ #include + + RCSID("$NetBSD$") + /* * double cbrt(double arg) * W. Kahan, 10/13/80. revised 1/13/84 for keeping sign symmetry @@ -39,9 +42,10 @@ * Revised and tested by K.C. Ng, 5/2/85 * Max error less than 0.667 ulps (unit in the last places) */ +WEAK_ALIAS(cbrtl, cbrt) +STRONG_ALIAS(__c99_cbrtl, cbrt) -ALTENTRY(cbrt) -ENTRY(d_cbrt, 0x00c0) # save %r6 & %r7 +ENTRY(cbrt, 0x00c0) # save %r6 & %r7 movq 4(%ap),%r0 # %r0 = argument x jbr dcbrt2 @@ -81,6 +85,13 @@ return: ret # error less than 0.667 ulps +ENTRY(cbrtf, 0) + cvtfd 4(%ap),-(%sp) + calls $2, _C_LABEL(cbrt) + cvtdf %r0, %r0 + ret + + .section .rodata _ALIGN_TEXT B : .long 721142941 # (86-0.03306235651)*(2^23) C : .float 0f0.5428571429 # 19/35 Index: arch/vax/n_copysign.S =================================================================== RCS file: arch/vax/n_copysign.S diff -N arch/vax/n_copysign.S --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ arch/vax/n_copysign.S 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,77 @@ +/* $NetBSD: n_support.S,v 1.6 2003/08/07 16:44:45 agc Exp $ */ +/* + * Copyright (c) 1985, 1993 + * The Regents of the University of California. All rights reserved. + * + * 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. + * + * @(#)support.s 8.1 (Berkeley) 6/4/93 + */ +#include + + RCSID("$NetBSD$"); + +/* + * copysign(x,y), + * logb(x), + * scalb(x,N), + * scalbn(x,N), + * frexp(x,p); + * finite(x), + * drem(x,y), + * Coded in vax assembly language by K.C. Ng, 3/14/85. + * Revised by K.C. Ng on 4/9/85. + */ + +/* + * float copysignf(float x, float y) + */ + +WEAK_ALIAS(_copysignf, copysignf) +ENTRY(_copysignf, 0) + movq 4(%ap),%r0 # load x into %r0 and y into %r1 + xorw3 %r0,%r1,%r2 # xor sign bits together + bbc $15,%r2,1f # same? done. + bicw3 $0x807f,%r0,%r2 # mask off the exponent of x + beql 1f # if zero or reserved op then return x + xorw3 $0x8000,%r0 # invert the sign bit of x +1: ret +END(_copysignf) + +/* + * double copysign(double x,double y) + */ +WEAK_ALIAS(copysignl, copysign) +STRONG_ALIAS(_copysignl, copysign) + +ENTRY(copysign, 0) + movd 4(%ap),%r0 # load x into %r0 + xorw3 %r0,12(%ap),%r2 # xor sign bits together + bbc $15,%r2,1f # same? done. + bicw3 $0x807f,%r0,%r2 # mask off the exponent of x + beql 1f # if zero or reserved op then return x + xorw3 $0x8000,%r0 # invert the sign bit of x +1: ret +END(copysign) Index: arch/vax/n_drem.S =================================================================== RCS file: arch/vax/n_drem.S diff -N arch/vax/n_drem.S --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ arch/vax/n_drem.S 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,130 @@ +/* $NetBSD: n_support.S,v 1.6 2003/08/07 16:44:45 agc Exp $ */ +/* + * Copyright (c) 1985, 1993 + * The Regents of the University of California. All rights reserved. + * + * 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. + * + * @(#)support.s 8.1 (Berkeley) 6/4/93 + */ +#include + + RCSID("$NetBSD$"); + +/* + * drem(x,y), + * Coded in vax assembly language by K.C. Ng, 3/14/85. + * Revised by K.C. Ng on 4/9/85. + */ + +/* + * DREM(X,Y) + * RETURN X REM Y =X-N*Y, N=[X/Y] ROUNDED (ROUNDED TO EVEN IN THE HALF WAY CASE) + * DOUBLE PRECISION (VAX D format 56 bits) + * CODED IN VAX ASSEMBLY LANGUAGE BY K.C. NG, 4/8/85. + */ + .set EDOM,33 + +ENTRY(drem, 0x0fc0) + subl2 $12,%sp + movd 4(%ap),%r0 #%r0=x + movd 12(%ap),%r2 #%r2=y + jeql Rop #if y=0 then generate reserved op fault + bicw3 $0x007f,%r0,%r4 #check if x is Rop + cmpw %r4,$0x8000 + jeql Ret #if x is Rop then return Rop + bicl3 $0x007f,%r2,%r4 #check if y is Rop + cmpw %r4,$0x8000 + jeql Ret #if y is Rop then return Rop + bicw2 $0x8000,%r2 #y := |y| + movw $0,-4(%fp) #-4(%fp) = nx := 0 + cmpw %r2,$0x1c80 #yexp ? 57 + bgtr C1 #if yexp > 57 goto C1 + addw2 $0x1c80,%r2 #scale up y by 2**57 + movw $0x1c80,-4(%fp) #nx := 57 (exponent field) +C1: + movw -4(%fp),-8(%fp) #-8(%fp) = nf := nx + bicw3 $0x7fff,%r0,-12(%fp) #-12(%fp) = sign of x + bicw2 $0x8000,%r0 #x := |x| + movd %r2,%r10 #y1 := y + bicl2 $0xffff07ff,%r11 #clear the last 27 bits of y1 +loop: + cmpd %r0,%r2 #x ? y + bleq E1 #if x <= y goto E1 + /* begin argument reduction */ + movd %r2,%r4 #t =y + movd %r10,%r6 #t1=y1 + bicw3 $0x807f,%r0,%r8 #xexp= exponent of x + bicw3 $0x807f,%r2,%r9 #yexp= exponent fo y + subw2 %r9,%r8 #xexp-yexp + subw2 $0x0c80,%r8 #k=xexp-yexp-25(exponent bit field) + blss C2 #if k<0 goto C2 + addw2 %r8,%r4 #t +=k + addw2 %r8,%r6 #t1+=k, scale up t and t1 +C2: + divd3 %r4,%r0,%r8 #x/t + cvtdl %r8,%r8 #n=[x/t] truncated + cvtld %r8,%r8 #float(n) + subd2 %r6,%r4 #t:=t-t1 + muld2 %r8,%r4 #n*(t-t1) + muld2 %r8,%r6 #n*t1 + subd2 %r6,%r0 #x-n*t1 + subd2 %r4,%r0 #(x-n*t1)-n*(t-t1) + jbr loop +E1: + movw -4(%fp),%r6 #%r6=nx + beql C3 #if nx=0 goto C3 + addw2 %r6,%r0 #x:=x*2**57 scale up x by nx + movw $0,-4(%fp) #clear nx + jbr loop +C3: + movq %r2,%r4 #%r4 = y + subw2 $0x80,%r4 #%r4 = y/2 + cmpd %r0,%r4 #x:y/2 + blss E2 #if x < y/2 goto E2 + bgtr C4 #if x > y/2 goto C4 + cvtdl %r8,%r8 #ifix(float(n)) + blbc %r8,E2 #if the last bit is zero, goto E2 +C4: + subd2 %r2,%r0 #x-y +E2: + xorw2 -12(%fp),%r0 #x^sign (exclusive or) + movw -8(%fp),%r6 #%r6=nf + bicw3 $0x807f,%r0,%r8 #%r8=exponent of x + bicw2 $0x7f80,%r0 #clear the exponent of x + subw2 %r6,%r8 #%r8=xexp-nf + bgtr C5 #if xexp-nf is positive goto C5 + movw $0,%r8 #clear %r8 + movq $0,%r0 #x underflow to zero +C5: + bisw2 %r8,%r0 /* put %r8 into x's exponent field */ + ret +Rop: #Reserved operand + pushl $EDOM + calls $1,_C_LABEL(infnan) #generate reserved op fault + ret +Ret: + movq $0x8000,%r0 #propagate reserved op + ret Index: arch/vax/n_finite.S =================================================================== RCS file: arch/vax/n_finite.S diff -N arch/vax/n_finite.S --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ arch/vax/n_finite.S 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,66 @@ +/* $NetBSD: n_support.S,v 1.6 2003/08/07 16:44:45 agc Exp $ */ +/* + * Copyright (c) 1985, 1993 + * The Regents of the University of California. All rights reserved. + * + * 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. + * + * @(#)support.s 8.1 (Berkeley) 6/4/93 + */ +#include + + RCSID("$NetBSD$"); + +/* + * int finitef(float x); + * int finite(double x); + * int finitel(long double x); + */ +WEAK_ALIAS(finitef, finite) +WEAK_ALIAS(finitel, finite) +STRONG_ALIAS(_finitel, finite) +ENTRY(finite, 0) + clrl %r0 + bicw3 $0x7f,4(%ap),%r1 # mask off the mantissa + cmpw %r1,$0x8000 # to see if x is the reserved op + beql 1f # if so, return FALSE (0) + incl %r0 # else return TRUE (1) +1: ret +END(finite) + +/* + * int isnan(double x); + * int isnanf(float x); + * int isnanl(long double x); + */ +WEAK_ALIAS(isnan, _isnan) +WEAK_ALIAS(isnanl, _isnan) +WEAK_ALIAS(isnanf, _isnan) +STRONG_ALIAS(_isnanl, _isnan) +STRONG_ALIAS(_isnanf, _isnan) +ENTRY(_isnan, 0) + clrl %r0 + ret +END(_isnan) Index: arch/vax/n_ilogb.S =================================================================== RCS file: arch/vax/n_ilogb.S diff -N arch/vax/n_ilogb.S --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ arch/vax/n_ilogb.S 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,57 @@ +/* $NetBSD: n_support.S,v 1.6 2003/08/07 16:44:45 agc Exp $ */ +/* + * Copyright (c) 1985, 1993 + * The Regents of the University of California. All rights reserved. + * + * 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. + * + * @(#)support.s 8.1 (Berkeley) 6/4/93 + */ +#include + + RCSID("$NetBSD$"); + +/* + * int ilogb(double x); + * int ilogbf(float x); + * int ilogbl(long double x); + */ +STRONG_ALIAS(_ilogbl, _ilogb) +STRONG_ALIAS(_ilogbf, _ilogb) +WEAK_ALIAS(ilogbl, _ilogb) +WEAK_ALIAS(ilogbf, _ilogb) +WEAK_ALIAS(ilogb, _ilogb) +ENTRY(_ilogb, 0) + ashl $-7,4(%ap),%r0 # shift the exponent of x + movzbl %r0,%r0 # grab only the exponent of x + beql 1f + subl2 $129,%r0 # get the unbiased exponent + ret +1: bbs $15,%4(ap),2f # was sign bit set? + ashl $31,$1,%r0 # return INT_MIN + ret +2: movl $0x7fffffff,%r0 # return INT_MAX + ret +END(_ilogb) Index: arch/vax/n_infnan.S =================================================================== RCS file: /cvsroot/src/lib/libm/arch/vax/n_infnan.S,v retrieving revision 1.6 diff -u -r1.6 n_infnan.S --- arch/vax/n_infnan.S 7 Aug 2003 16:44:45 -0000 1.6 +++ arch/vax/n_infnan.S 22 Mar 2010 22:50:43 -0000 @@ -31,9 +31,7 @@ */ #include - .text -_sccsid: - .asciz "@(#)infnan.s\t1.1 (Berkeley) 8/21/85; 8.1 (ucb.elefunt) 6/4/93" +RCSID("$NetBSD$") /* * infnan(arg) int arg; Index: arch/vax/n_logb.S =================================================================== RCS file: arch/vax/n_logb.S diff -N arch/vax/n_logb.S --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ arch/vax/n_logb.S 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,69 @@ +/* $NetBSD: n_support.S,v 1.6 2003/08/07 16:44:45 agc Exp $ */ +/* + * Copyright (c) 1985, 1993 + * The Regents of the University of California. All rights reserved. + * + * 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. + * + * @(#)support.s 8.1 (Berkeley) 6/4/93 + */ +#include + + RCSID("$NetBSD$"); + +/* + * float logbf(float x); + */ +WEAK_ALIAS(logbf, _logbf) +ENTRY(_logbf, 0) + ashl $-7,4(%ap),%r0 # shift the exponent of x + movzbl %r0,%r0 # grab only the exponent of x + beql 1f + subw2 $129,%r0 # get the unbias exponent + cvtwf %r0,%r0 # return the answer in float + ret +1: movf 4(%ap),%r0 # %r0 = x (zero or reserved op) + bneq 2f # simply return if reserved op + movf $0f-2147583647.0,%r0 +2: ret +END(_logbf) + +/* + * double logb(double x); + */ +WEAK_ALIAS(logbl, logb) +STRONG_ALIAS(_logbl, logb) +ENTRY(logb, 0) + ashl $-7,4(%ap),%r0 # shift the exponent of x + movzbl %r0,%r0 # grab only the exponent of x + beql 1f + subw2 $129,%r0 # get the unbias exponent + cvtwd %r0,%r0 # return the answer in float + ret +1: movd 4(%ap),%r0 # %r0:1 = x (zero or reserved op) + bneq 2f # simply return if reserved op + movd $0d-2147483647.0,%r0 +2: ret +END(logb) Index: arch/vax/n_scalbn.S =================================================================== RCS file: arch/vax/n_scalbn.S diff -N arch/vax/n_scalbn.S --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ arch/vax/n_scalbn.S 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,78 @@ +/* $NetBSD: n_support.S,v 1.6 2003/08/07 16:44:45 agc Exp $ */ +/* + * Copyright (c) 1985, 1993 + * The Regents of the University of California. All rights reserved. + * + * 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. + * + * @(#)support.s 8.1 (Berkeley) 6/4/93 + */ +#include + + RCSID("$NetBSD$"); + +/* + * double scalb(double x, double n); + * double scalbn(double x, int n); + * float scalbnf(float x, int n); + * long double scalbnl(long double x, int n); + */ + .set ERANGE,34 +ENTRY(scalb, 0) + cvtdl 12(%ap),%r2 + jbr .Lscalbn_common + +WEAK_ALIAS(scalbnf, _scalbnf) +ENTRY(_scalbnf, 0) + movl 8(%ap),%r2 + jbr .Lscalbn_common + +STRONG_ALIAS(_scalbnl, _scalbn) +WEAK_ALIAS(scalbn, _scalbn) +WEAK_ALIAS(scalbnl, _scalbn) +ENTRY(_scalbn, 0) + movl 12(%ap), %r2 +.Lscalbn_common: + movd 4(%ap),%r0 + bicl3 $0xffff807f,%r0,%r3 + beql 3f # 0 or reserved operand + cmpl %r2,$300 # why 2^300? + bgeq 1f + cmpl %r2,$-300 + bleq 2f + ashl $7,%r2,%r2 + addl2 %r2,%r3 + bleq 2f + cmpl %r3,$0x8000 # did it over/under flow into the sign? + bgeq 1f + addl2 %r2,%r0 # r1 is already correct + ret +1: pushl $ERANGE + calls $1,_C_LABEL(infnan) # if it returns + bicw3 $0x7fff,4(%ap),%r2 # get the sign of input arg + bisw2 %r2,%r0 # re-attach the sign to %r0/1 + ret +2: movd $0,%r0 # 0.0 is same for float or double +3: ret Index: arch/vax/n_sincos.S =================================================================== RCS file: /cvsroot/src/lib/libm/arch/vax/n_sincos.S,v retrieving revision 1.8 diff -u -r1.8 n_sincos.S --- arch/vax/n_sincos.S 7 Aug 2003 16:44:45 -0000 1.8 +++ arch/vax/n_sincos.S 22 Mar 2010 22:50:43 -0000 @@ -46,12 +46,18 @@ */ #include -ENTRY(sinf, 0) + RCSID("$NetBSD$") + +WEAK_ALIAS(sinf, _sinf) +ENTRY(_sinf, 0) cvtfd 4(%ap),-(%sp) calls $2,_C_LABEL(sin) cvtdf %r0,%r0 ret +STRONG_ALIAS(_sinl, sin) +WEAK_ALIAS(sinl, sin) + ENTRY(sin, 0xfc0) movq 4(%ap),%r0 bicw3 $0x807f,%r0,%r2 @@ -81,12 +87,16 @@ * S. McDonald, April 4, 1985 */ -ENTRY(cosf, 0) +WEAK_ALIAS(cosf, _cosf) +ENTRY(_cosf, 0) cvtfd 4(%ap),-(%sp) calls $2,_C_LABEL(cos) cvtdf %r0,%r0 ret +STRONG_ALIAS(_cosl, cos) +WEAK_ALIAS(cosl, cos) + ENTRY(cos, 0x0fc0) movq 4(%ap),%r0 bicw3 $0x7f,%r0,%r2 Index: arch/vax/n_sqrt.S =================================================================== RCS file: /cvsroot/src/lib/libm/arch/vax/n_sqrt.S,v retrieving revision 1.8 diff -u -r1.8 n_sqrt.S --- arch/vax/n_sqrt.S 18 Apr 2007 04:46:13 -0000 1.8 +++ arch/vax/n_sqrt.S 22 Mar 2010 22:50:43 -0000 @@ -32,6 +32,8 @@ #include + RCSID("$NetBSD$"); + /* * double sqrt(arg) revised August 15,1982 * double arg; @@ -45,6 +47,9 @@ */ .set EDOM,33 +WEAK_ALIAS(sqrtl, sqrt) +STRONG_ALIAS(__c99_sqrtl, sqrt) + ENTRY(d_sqrt, 0x003c) # save %r5,%r4,%r3,%r2 movq *4(%ap),%r0 jbr dsqrt2 Index: arch/vax/n_tan.S =================================================================== RCS file: /cvsroot/src/lib/libm/arch/vax/n_tan.S,v retrieving revision 1.6 diff -u -r1.6 n_tan.S --- arch/vax/n_tan.S 7 Aug 2003 16:44:45 -0000 1.6 +++ arch/vax/n_tan.S 22 Mar 2010 22:50:43 -0000 @@ -32,6 +32,8 @@ #include + RCSID("$NetBSD$") + /* This is the implementation of Peter Tang's double precision * tangent for the VAX using Bob Corbett's argument reduction. * @@ -44,6 +46,9 @@ * method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett * S. McDonald, April 4, 1985 */ +STRONG_ALIAS(_tanl, tan) +WEAK_ALIAS(tanl, tan) + ENTRY(tan, 0x0fc0) # save %r6-%r11 movq 4(%ap),%r0 bicw3 $0x807f,%r0,%r2 @@ -87,3 +92,10 @@ divd3 %r0,%r10,%r0 bispsw (%sp)+ 1: ret + +WEAK_ALIAS(tanf, _tanf) +ENTRY(_tanf, 0) + cvtfd 4(%ap),-(%sp) + calls $2, _C_LABEL(tan) + cvtdf %r0, %r0 + ret Index: complex/Makefile.inc =================================================================== RCS file: /cvsroot/src/lib/libm/complex/Makefile.inc,v retrieving revision 1.2 diff -u -r1.2 Makefile.inc --- complex/Makefile.inc 8 Mar 2008 14:21:41 -0000 1.2 +++ complex/Makefile.inc 22 Mar 2010 22:50:43 -0000 @@ -2,14 +2,13 @@ .PATH: ${.CURDIR}/complex -SRCS+= cabs.c cabsf.c carg.c cargf.c -SRCS+= creal.c crealf.c cimag.c cimagf.c conj.c conjf.c -SRCS+= csqrt.c cexp.c clog.c cpow.c -SRCS+= cephes_subr.c csin.c ccos.c ctan.c csinh.c ccosh.c ctanh.c -SRCS+= casin.c cacos.c catan.c casinh.c cacosh.c catanh.c -SRCS+= csqrtf.c cexpf.c clogf.c cpowf.c -SRCS+= cephes_subrf.c csinf.c ccosf.c ctanf.c csinhf.c ccoshf.c ctanhf.c -SRCS+= casinf.c cacosf.c catanf.c casinhf.c cacoshf.c catanhf.c +SRCS+= cabs.c cacos.c cacosh.c carg.c casin.c casinh.c catan.c +SRCS+= catanh.c ccos.c ccosh.c cephes_subr.c cexp.c cimag.c clog.c +SRCS+= conj.c cpow.c creal.c csqrt.c csin.c csinh.c ctan.c ctanh.c + +SRCS+= cabsf.c cacosf.c cacoshf.c cargf.c casinf.c casinhf.c catanf.c +SRCS+= catanhf.c ccosf.c ccoshf.c cephes_subrf.c cexpf.c cimagf.c clogf.c +SRCS+= conjf.c cpowf.c crealf.c csqrtf.c csinf.c csinhf.c ctanf.c ctanhf.c MAN+= cabs.3 cacos.3 cacosh.3 carg.3 casin.3 casinh.3 catan.3 catanh.3 MAN+= ccos.3 ccosh.3 cexp.3 cimag.3 clog.3 conj.3 cpow.3 creal.3 @@ -22,3 +21,17 @@ MLINKS+= clog.3 clogf.3 conj.3 conjf.3 cpow.3 cpowf.3 MLINKS+= creal.3 crealf.3 csin.3 csinf.3 csinh.3 csinhf.3 MLINKS+= csqrt.3 csqrtf.3 ctan.3 ctanf.3 ctanh.3 ctanhf.3 + +.if ${MACHINE_ARCH} == "vax" +SRCS+= cabsl.c cacosl.c cacoshl.c cargl.c casinl.c casinhl.c catanl.c +SRCS+= catanhl.c ccosl.c ccoshl.c cephes_subrl.c cexpl.c cimagl.c clogl.c +SRCS+= conjl.c cpowl.c creall.c csqrtl.c csinl.c csinhl.c ctanl.c ctanhl.c + +MLINKS+= cabs.3 cabsl.3 cacos.3 cacosl.3 cacosh.3 cacoshl.3 +MLINKS+= carg.3 cargl.3 casin.3 casinl.3 casinh.3 casinhl.3 +MLINKS+= catan.3 catanl.3 catanh.3 catanhl.3 ccos.3 ccosl.3 +MLINKS+= ccosh.3 ccoshl.3 cexp.3 cexpl.3 cimag.3 cimagl.3 +MLINKS+= clog.3 clogl.3 conj.3 conjl.3 cpow.3 cpowl.3 +MLINKS+= creal.3 creall.3 csin.3 csinl.3 csinh.3 csinhl.3 +MLINKS+= csqrt.3 csqrtl.3 ctan.3 ctanl.3 ctanh.3 ctanhl.3 +.endif Index: complex/cabs.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cabs.c,v retrieving revision 1.1 diff -u -r1.1 cabs.c --- complex/cabs.c 20 Aug 2007 16:01:30 -0000 1.1 +++ complex/cabs.c 22 Mar 2010 22:50:43 -0000 @@ -9,9 +9,9 @@ #include #include -double -cabs(double complex z) +TYPE +CABS(TYPE complex z) { - return hypot(__real__ z, __imag__ z); + return HYPOT(__real__ z, __imag__ z); } Index: complex/cabsf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cabsf.c,v retrieving revision 1.1 diff -u -r1.1 cabsf.c --- complex/cabsf.c 20 Aug 2007 16:01:30 -0000 1.1 +++ complex/cabsf.c 22 Mar 2010 22:50:43 -0000 @@ -5,13 +5,7 @@ * Public domain. */ -#include "../src/namespace.h" -#include -#include +#define SFX(a) a ## f +#define TYPE float -float -cabsf(float complex z) -{ - - return hypotf(__real__ z, __imag__ z); -} +#include "cabs.c" Index: complex/cabsl.c =================================================================== RCS file: complex/cabsl.c diff -N complex/cabsl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/cabsl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,11 @@ +/* $NetBSD: cabsf.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */ + +/* + * Written by Matthias Drochner . + * Public domain. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "cabs.c" Index: complex/cacos.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cacos.c,v retrieving revision 1.1 diff -u -r1.1 cacos.c --- complex/cacos.c 20 Aug 2007 16:01:30 -0000 1.1 +++ complex/cacos.c 22 Mar 2010 22:50:43 -0000 @@ -33,12 +33,12 @@ #include #include -double complex -cacos(double complex z) +TYPE complex +CACOS(TYPE complex z) { - double complex w; + TYPE complex w; - w = casin(z); - w = (M_PI_2 - creal(w)) - cimag(w) * I; + w = CASIN(z); + w = ((TYPE)M_PI_2 - CREAL(w)) - CIMAG(w) * I; return w; } Index: complex/cacosf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cacosf.c,v retrieving revision 1.1 diff -u -r1.1 cacosf.c --- complex/cacosf.c 20 Aug 2007 16:01:30 -0000 1.1 +++ complex/cacosf.c 22 Mar 2010 22:50:43 -0000 @@ -29,16 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include -#include +#define SFX(a) a ## f +#define TYPE float -float complex -cacosf(float complex z) -{ - float complex w; - - w = casinf(z); - w = ((float)M_PI_2 - crealf(w)) - cimagf(w) * I; - return w; -} +#include "cacos.c" Index: complex/cacosh.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cacosh.c,v retrieving revision 1.2 diff -u -r1.2 cacosh.c --- complex/cacosh.c 3 Aug 2009 19:41:32 -0000 1.2 +++ complex/cacosh.c 22 Mar 2010 22:50:43 -0000 @@ -29,17 +29,18 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "../src/namespace.h" #include -double complex -cacosh(double complex z) +TYPE complex +CACOSH(TYPE complex z) { - double complex w; + TYPE complex w; #if 0 /* does not give the principal value */ w = I * cacos(z); #else - w = clog(z + csqrt(z + 1) * csqrt(z - 1)); + w = CLOG(z + CSQRT(z + 1) * CSQRT(z - 1)); #endif return w; } Index: complex/cacoshf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cacoshf.c,v retrieving revision 1.2 diff -u -r1.2 cacoshf.c --- complex/cacoshf.c 3 Aug 2009 19:41:32 -0000 1.2 +++ complex/cacoshf.c 22 Mar 2010 22:50:43 -0000 @@ -29,17 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#define SFX(a) a ## f +#define TYPE float -float complex -cacoshf(float complex z) -{ - float complex w; - -#if 0 /* does not give the principal value */ - w = I * cacosf(z); -#else - w = clogf(z + csqrtf(z + 1) * csqrtf(z - 1)); -#endif - return w; -} +#include "cacosh.c" Index: complex/cacoshl.c =================================================================== RCS file: complex/cacoshl.c diff -N complex/cacoshl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/cacoshl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,35 @@ +/* $NetBSD: cacoshf.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "cacosh.c" Index: complex/cacosl.c =================================================================== RCS file: complex/cacosl.c diff -N complex/cacosl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/cacosl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,35 @@ +/* $NetBSD: cacosf.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "cacos.c" Index: complex/carg.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/carg.c,v retrieving revision 1.1 diff -u -r1.1 carg.c --- complex/carg.c 20 Aug 2007 16:01:31 -0000 1.1 +++ complex/carg.c 22 Mar 2010 22:50:43 -0000 @@ -9,9 +9,8 @@ #include #include -double -carg(double complex z) +TYPE +CARG(TYPE complex z) { - - return atan2(__imag__ z, __real__ z); + return ATAN2(__imag__ z, __real__ z); } Index: complex/cargf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cargf.c,v retrieving revision 1.1 diff -u -r1.1 cargf.c --- complex/cargf.c 20 Aug 2007 16:01:31 -0000 1.1 +++ complex/cargf.c 22 Mar 2010 22:50:43 -0000 @@ -5,13 +5,7 @@ * Public domain. */ -#include "../src/namespace.h" -#include -#include +#define SFX(a) a ## f +#define TYPE float -float -cargf(float complex z) -{ - - return atan2f(__imag__ z, __real__ z); -} +#include "carg.c" Index: complex/cargl.c =================================================================== RCS file: complex/cargl.c diff -N complex/cargl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/cargl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,11 @@ +/* $NetBSD: cargf.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */ + +/* + * Written by Matthias Drochner . + * Public domain. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "carg.c" Index: complex/casin.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/casin.c,v retrieving revision 1.1 diff -u -r1.1 casin.c --- complex/casin.c 20 Aug 2007 16:01:31 -0000 1.1 +++ complex/casin.c 22 Mar 2010 22:50:43 -0000 @@ -29,48 +29,52 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include + +#ifndef SFX +#ifndef lint +__weak_alias(casin, _casin); +#endif +#endif + #include "../src/namespace.h" #include #include -#ifdef __weak_alias -__weak_alias(casin, _casin) -#endif - -double complex -casin(double complex z) +TYPE complex +CASIN(TYPE complex z) { - double complex w; - double complex ca, ct, zz, z2; - double x, y; + TYPE complex w; + TYPE complex ca, ct, zz, z2; + TYPE x, y; - x = creal(z); - y = cimag(z); + x = CREAL(z); + y = CIMAG(z); #if 0 /* MD: test is incorrect, casin(>1) is defined */ - if (y == 0.0) { - if (fabs(x) > 1.0) { - w = M_PI_2 + 0.0 * I; + if (y == NUM(0.0)) { + if (FABS(x) > ONE) { + w = M_PI_2 + NUM(0.0) * I; #if 0 mtherr ("casin", DOMAIN); #endif } else { - w = asin(x) + 0.0 * I; + w = ASIN(x) + NUM(0.0) * I; } return w; } #endif /* Power series expansion */ -/* -b = cabs(z); -if( b < 0.125 ) +#if 0 +b = CABS(z); +if( b < NUM(0.125) ) { z2.r = (x - y) * (x + y); -z2.i = 2.0 * x * y; +z2.i = TWO * x * y; -cn = 1.0; -n = 1.0; +cn = ONE: +n = ONE: ca.r = x; ca.i = y; sum.r = x; @@ -83,38 +87,38 @@ ca.i = ct.i; cn *= n; - n += 1.0; + n += ONE: cn /= n; - n += 1.0; + n += ONE: b = cn/n; ct.r *= b; ct.i *= b; sum.r += ct.r; sum.i += ct.i; - b = fabs(ct.r) + fabs(ct.i); + b = FABS(ct.r) + FABS(ct.i); } while( b > MACHEP ); w->r = sum.r; w->i = sum.i; return; } -*/ +#endif ca = x + y * I; ct = ca * I; /* sqrt( 1 - z*z) */ /* cmul( &ca, &ca, &zz ) */ - /*x * x - y * y */ - zz = (x - y) * (x + y) + (2.0 * x * y) * I; + /* x * x - y * y */ + zz = (x - y) * (x + y) + (TWO * x * y) * I; - zz = 1.0 - creal(zz) - cimag(zz) * I; - z2 = csqrt(zz); + zz = ONE - CREAL(zz) - CIMAG(zz) * I; + z2 = CSQRT(zz); zz = ct + z2; - zz = clog(zz); + zz = CLOG(zz); /* multiply by 1/i = -i */ - w = zz * (-1.0 * I); + w = zz * (-ONE * I); return w; } Index: complex/casinf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/casinf.c,v retrieving revision 1.1 diff -u -r1.1 casinf.c --- complex/casinf.c 20 Aug 2007 16:01:31 -0000 1.1 +++ complex/casinf.c 22 Mar 2010 22:50:43 -0000 @@ -29,92 +29,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include -#include +#include -#ifdef __weak_alias -__weak_alias(casinf, _casinf) +#define SFX(a) a##f +#define TYPE float +#ifndef lint +__weak_alias(casinf, _casinf); #endif -float complex -casinf(float complex z) -{ - float complex w; - float complex ca, ct, zz, z2; - float x, y; - - x = crealf(z); - y = cimagf(z); - -#if 0 /* MD: test is incorrect, casin(>1) is defined */ - if (y == 0.0f) { - if (fabsf(x) > 1.0) { - w = M_PI_2 + 0.0f * I; -#if 0 - mtherr ("casin", DOMAIN); -#endif - } else { - w = asinf(x) + 0.0f * I; - } - return w; - } -#endif - -/* Power series expansion */ -/* -b = cabsf(z); -if( b < 0.125 ) -{ -z2.r = (x - y) * (x + y); -z2.i = 2.0 * x * y; - -cn = 1.0; -n = 1.0; -ca.r = x; -ca.i = y; -sum.r = x; -sum.i = y; -do - { - ct.r = z2.r * ca.r - z2.i * ca.i; - ct.i = z2.r * ca.i + z2.i * ca.r; - ca.r = ct.r; - ca.i = ct.i; - - cn *= n; - n += 1.0; - cn /= n; - n += 1.0; - b = cn/n; - - ct.r *= b; - ct.i *= b; - sum.r += ct.r; - sum.i += ct.i; - b = fabsf(ct.r) + fabsf(ct.i); - } -while( b > MACHEP ); -w->r = sum.r; -w->i = sum.i; -return; -} -*/ - - - ca = x + y * I; - ct = ca * I; - /* sqrt( 1 - z*z) */ - /* cmul( &ca, &ca, &zz ) */ - /*x * x - y * y */ - zz = (x - y) * (x + y) + (2.0f * x * y) * I; - - zz = 1.0f - crealf(zz) - cimagf(zz) * I; - z2 = csqrtf(zz); - - zz = ct + z2; - zz = clogf(zz); - /* multiply by 1/i = -i */ - w = zz * (-1.0f * I); - return w; -} +#include "casin.c" Index: complex/casinh.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/casinh.c,v retrieving revision 1.1 diff -u -r1.1 casinh.c --- complex/casinh.c 20 Aug 2007 16:01:31 -0000 1.1 +++ complex/casinh.c 22 Mar 2010 22:50:43 -0000 @@ -32,11 +32,8 @@ #include "../src/namespace.h" #include -double complex -casinh(double complex z) +TYPE complex +CASINH(TYPE complex z) { - double complex w; - - w = -1.0 * I * casin(z * I); - return w; + return -ONE * I * CASIN(z * I); } Index: complex/casinhf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/casinhf.c,v retrieving revision 1.1 diff -u -r1.1 casinhf.c --- complex/casinhf.c 20 Aug 2007 16:01:32 -0000 1.1 +++ complex/casinhf.c 22 Mar 2010 22:50:43 -0000 @@ -29,14 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include +#define SFX(a) a ## f +#define TYPE float -float complex -casinhf(float complex z) -{ - float complex w; - - w = -1.0f * I * casinf(z * I); - return w; -} +#include "casinh.c" Index: complex/casinhl.c =================================================================== RCS file: complex/casinhl.c diff -N complex/casinhl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/casinhl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,35 @@ +/* $NetBSD: casinh.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "casinh.c" Index: complex/casinl.c =================================================================== RCS file: complex/casinl.c diff -N complex/casinl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/casinl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,41 @@ +/* $NetBSD: casinf.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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 + +#define SFX(a) a##l +#define TYPE long double + +#ifndef lint +__weak_alias(casinl, _casinl); +#endif + +#include "casin.c" Index: complex/catan.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/catan.c,v retrieving revision 1.1 diff -u -r1.1 catan.c --- complex/catan.c 20 Aug 2007 16:01:32 -0000 1.1 +++ complex/catan.c 22 Mar 2010 22:50:43 -0000 @@ -29,45 +29,50 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include + +#ifndef SFX +#define MAXNUM DBL_MAX + +#ifndef lint +__weak_alias(catan, _catan); +#endif +#endif + #include "../src/namespace.h" #include #include +#include #include "cephes_subr.h" -#ifdef __weak_alias -__weak_alias(catan, _catan) -#endif - -#define MAXNUM 1.0e308 - -double complex -catan(double complex z) +TYPE complex +CATAN(TYPE complex z) { - double complex w; - double a, t, x, x2, y; + TYPE complex w; + TYPE a, t, x, x2, y; - x = creal(z); - y = cimag(z); + x = CREAL(z); + y = CIMAG(z); - if ((x == 0.0) && (y > 1.0)) + if ((x == 0.0) && (y > ONE)) goto ovrf; x2 = x * x; - a = 1.0 - x2 - (y * y); + a = ONE - x2 - (y * y); if (a == 0.0) goto ovrf; - t = 0.5 * atan2(2.0 * x, a); - w = _redupi(t); + t = NUM(0.5) * ATAN2(TWO * x, a); + w = _REDUPI(t); - t = y - 1.0; + t = y - ONE; a = x2 + (t * t); if (a == 0.0) goto ovrf; - t = y + 1.0; + t = y + ONE; a = (x2 + (t * t))/a; - w = w + (0.25 * log(a)) * I; + w = w + (NUM(0.25) * LOG(a)) * I; return w; ovrf: Index: complex/catanf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/catanf.c,v retrieving revision 1.1 diff -u -r1.1 catanf.c --- complex/catanf.c 20 Aug 2007 16:01:32 -0000 1.1 +++ complex/catanf.c 22 Mar 2010 22:50:43 -0000 @@ -1,4 +1,4 @@ -/* $NetBSD: catanf.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */ +/* $NetBSD: catan.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -29,51 +29,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include -#include -#include "cephes_subrf.h" +#include -#ifdef __weak_alias -__weak_alias(catanf, _catanf) -#endif - -#define MAXNUMF 1.0e38F - -float complex -catanf(float complex z) -{ - float complex w; - float a, t, x, x2, y; - - x = crealf(z); - y = cimagf(z); - - if ((x == 0.0f) && (y > 1.0f)) - goto ovrf; +#define SFX(a) a ## f +#define TYPE float +#define MAXNUM FLT_MAX - x2 = x * x; - a = 1.0f - x2 - (y * y); - if (a == 0.0f) - goto ovrf; - - t = 0.5f * atan2f(2.0f * x, a); - w = _redupif(t); - - t = y - 1.0f; - a = x2 + (t * t); - if (a == 0.0f) - goto ovrf; - - t = y + 1.0f; - a = (x2 + (t * t))/a; - w = w + (0.25f * logf(a)) * I; - return w; - -ovrf: -#if 0 - mtherr ("catan", OVERFLOW); +#ifndef lint +__weak_alias(catanf, _catanf); #endif - w = MAXNUMF + MAXNUMF * I; - return w; -} + +#include "catan.c" Index: complex/catanh.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/catanh.c,v retrieving revision 1.1 diff -u -r1.1 catanh.c --- complex/catanh.c 20 Aug 2007 16:01:32 -0000 1.1 +++ complex/catanh.c 22 Mar 2010 22:50:43 -0000 @@ -32,11 +32,8 @@ #include "../src/namespace.h" #include -double complex -catanh(double complex z) +TYPE complex +CATANH(TYPE complex z) { - double complex w; - - w = -1.0 * I * catan(z * I); - return w; + return -ONE * I * CATAN(z * I); } Index: complex/catanhf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/catanhf.c,v retrieving revision 1.1 diff -u -r1.1 catanhf.c --- complex/catanhf.c 20 Aug 2007 16:01:32 -0000 1.1 +++ complex/catanhf.c 22 Mar 2010 22:50:43 -0000 @@ -29,14 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include +#define SFX(a) a ## f +#define TYPE float -float complex -catanhf(float complex z) -{ - float complex w; - - w = -1.0f * I * catanf(z * I); - return w; -} +#include "catanh.c" Index: complex/catanhl.c =================================================================== RCS file: complex/catanhl.c diff -N complex/catanhl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/catanhl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,35 @@ +/* $NetBSD: catanhf.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "catanh.c" Index: complex/catanl.c =================================================================== RCS file: complex/catanl.c diff -N complex/catanl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/catanl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,42 @@ +/* $NetBSD: catan.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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 + +#define SFX(a) a ## l +#define TYPE long double +#define MAXNUM LDBL_MAX + +#ifndef lint +__weak_alias(catanl, _catanl); +#endif + +#include "catan.c" Index: complex/ccos.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/ccos.c,v retrieving revision 1.1 diff -u -r1.1 ccos.c --- complex/ccos.c 20 Aug 2007 16:01:32 -0000 1.1 +++ complex/ccos.c 22 Mar 2010 22:50:43 -0000 @@ -34,13 +34,13 @@ #include #include "cephes_subr.h" -double complex -ccos(double complex z) +TYPE complex +CCOS(TYPE complex z) { - double complex w; - double ch, sh; + TYPE complex w; + TYPE ch, sh; - _cchsh(cimag(z), &ch, &sh); - w = cos(creal(z)) * ch - (sin(creal(z)) * sh) * I; + _CCHSH(CIMAG(z), &ch, &sh); + w = COS(CREAL(z)) * ch - (SIN(CREAL(z)) * sh) * I; return w; } Index: complex/ccosf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/ccosf.c,v retrieving revision 1.1 diff -u -r1.1 ccosf.c --- complex/ccosf.c 20 Aug 2007 16:01:33 -0000 1.1 +++ complex/ccosf.c 22 Mar 2010 22:50:43 -0000 @@ -29,18 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include -#include -#include "cephes_subrf.h" +#define SFX(a) a ## f +#define TYPE float -float complex -ccosf(float complex z) -{ - float complex w; - float ch, sh; - - _cchshf(cimagf(z), &ch, &sh); - w = cosf(crealf(z)) * ch - (sinf(crealf(z)) * sh) * I; - return w; -} +#include "ccos.c" Index: complex/ccosh.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/ccosh.c,v retrieving revision 1.1 diff -u -r1.1 ccosh.c --- complex/ccosh.c 20 Aug 2007 16:01:33 -0000 1.1 +++ complex/ccosh.c 22 Mar 2010 22:50:43 -0000 @@ -33,14 +33,14 @@ #include #include -double complex -ccosh(double complex z) +TYPE complex +CCOSH(TYPE complex z) { - double complex w; - double x, y; + TYPE complex w; + TYPE x, y; - x = creal(z); - y = cimag(z); - w = cosh(x) * cos(y) + (sinh(x) * sin(y)) * I; + x = CREAL(z); + y = CIMAG(z); + w = COSH(x) * COS(y) + (SINH(x) * SIN(y)) * I; return w; } Index: complex/ccoshf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/ccoshf.c,v retrieving revision 1.1 diff -u -r1.1 ccoshf.c --- complex/ccoshf.c 20 Aug 2007 16:01:33 -0000 1.1 +++ complex/ccoshf.c 22 Mar 2010 22:50:43 -0000 @@ -29,18 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include -#include +#define SFX(a) a ## f +#define TYPE float -float complex -ccoshf(float complex z) -{ - float complex w; - float x, y; - - x = crealf(z); - y = cimagf(z); - w = coshf(x) * cosf(y) + (sinhf(x) * sinf(y)) * I; - return w; -} +#include "ccosh.c" Index: complex/ccoshl.c =================================================================== RCS file: complex/ccoshl.c diff -N complex/ccoshl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/ccoshl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,35 @@ +/* $NetBSD: ccosh.c,v 1.1 2007/08/20 16:01:33 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "ccosh.c" Index: complex/ccosl.c =================================================================== RCS file: complex/ccosl.c diff -N complex/ccosl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/ccosl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,35 @@ +/* $NetBSD: ccos.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "ccos.c" Index: complex/cephes_subr.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cephes_subr.c,v retrieving revision 1.1 diff -u -r1.1 cephes_subr.c --- complex/cephes_subr.c 20 Aug 2007 16:01:33 -0000 1.1 +++ complex/cephes_subr.c 22 Mar 2010 22:50:43 -0000 @@ -29,6 +29,17 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#ifndef SFX +#define SFX(a) a +#define TYPE double +#define MACHEP 1.1e-16 + /* extended precision value of PI: */ + /* 3.14159265358979323846264338327950288419716939937510 */ +#define DP1 3.14159265160560607910E0 +#define DP2 0.198418714791870343106E-8 +#define DP3 0.11442377452219502884197-16 +#endif + #include "../src/namespace.h" #include #include @@ -37,17 +48,17 @@ /* calculate cosh and sinh */ void -_cchsh(double x, double *c, double *s) +_CCHSH(TYPE x, TYPE *c, TYPE *s) { - double e, ei; + TYPE e, ei; - if (fabs(x) <= 0.5) { - *c = cosh(x); - *s = sinh(x); + if (FABS(x) <= NUM(0.5)) { + *c = COSH(x); + *s = SINH(x); } else { - e = exp(x); - ei = 0.5 / e; - e = 0.5 * e; + e = EXP(x); + ei = NUM(0.5) / e; + e = NUM(0.5) * e; *s = e - ei; *c = e + ei; } @@ -55,54 +66,50 @@ /* Program to subtract nearest integer multiple of PI */ -/* extended precision value of PI: */ -static const double DP1 = 3.14159265160560607910E0; -static const double DP2 = 1.98418714791870343106E-9; -static const double DP3 = 1.14423774522196636802E-17; -#define MACHEP 1.1e-16 - -double -_redupi(double x) +TYPE +_REDUPI(TYPE x) { - double t; + TYPE t; long i; - t = x / M_PI; + t = x / (TYPE)M_PI; if (t >= 0.0) - t += 0.5; + t += NUM(0.5); else - t -= 0.5; + t -= NUM(0.5); i = t; /* the multiple */ t = i; + /* t = x - t * (DP1 + DP2 + DP3) */; + /* (DP1 + DP2 + DP3) == M_PI */; t = ((x - t * DP1) - t * DP2) - t * DP3; return t; } /* Taylor series expansion for cosh(2y) - cos(2x) */ -double -_ctans(double complex z) +TYPE +_CTANS(TYPE complex z) { - double f, x, x2, y, y2, rn, t; - double d; + TYPE f, x, x2, y, y2, rn, t; + TYPE d; - x = fabs(2.0 * creal(z)); - y = fabs(2.0 * cimag(z)); + x = FABS(TWO * CREAL(z)); + y = FABS(TWO * CIMAG(z)); - x = _redupi(x); + x = _REDUPI(x); x = x * x; y = y * y; - x2 = 1.0; - y2 = 1.0; - f = 1.0; + x2 = ONE; + y2 = ONE; + f = ONE; rn = 0.0; d = 0.0; do { - rn += 1.0; + rn += ONE; f *= rn; - rn += 1.0; + rn += ONE; f *= rn; x2 *= x; y2 *= y; @@ -110,15 +117,15 @@ t /= f; d += t; - rn += 1.0; + rn += ONE; f *= rn; - rn += 1.0; + rn += ONE; f *= rn; x2 *= x; y2 *= y; t = y2 - x2; t /= f; d += t; - } while (fabs(t/d) > MACHEP); + } while (FABS(t/d) > MACHEP); return d; } Index: complex/cephes_subr.h =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cephes_subr.h,v retrieving revision 1.1 diff -u -r1.1 cephes_subr.h --- complex/cephes_subr.h 20 Aug 2007 16:01:33 -0000 1.1 +++ complex/cephes_subr.h 22 Mar 2010 22:50:43 -0000 @@ -1,5 +1,13 @@ /* $NetBSD: cephes_subr.h,v 1.1 2007/08/20 16:01:33 drochner Exp $ */ +void _cchshf(float, float *, float *); +float _redupif(float); +float _ctansf(float complex); + void _cchsh(double, double *, double *); double _redupi(double); double _ctans(double complex); + +void _cchshl(long double, long double *, long double *); +long double _redupil(long double); +long double _ctansl(long double complex); Index: complex/cephes_subrf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cephes_subrf.c,v retrieving revision 1.1 diff -u -r1.1 cephes_subrf.c --- complex/cephes_subrf.c 20 Aug 2007 16:01:34 -0000 1.1 +++ complex/cephes_subrf.c 22 Mar 2010 22:50:43 -0000 @@ -29,95 +29,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include -#include -#include "cephes_subrf.h" - -/* calculate cosh and sinh */ - -void -_cchshf(float x, float *c, float *s) -{ - float e, ei; - - if (fabsf(x) <= 0.5f) { - *c = coshf(x); - *s = sinhf(x); - } else { - e = expf(x); - ei = 0.5f / e; - e = 0.5f * e; - *s = e - ei; - *c = e + ei; - } -} - -/* Program to subtract nearest integer multiple of PI */ - +#define SFX(a) a ## f +#define TYPE float /* extended precision value of PI: */ -static const double DP1 = 3.140625; -static const double DP2 = 9.67502593994140625E-4; -static const double DP3 = 1.509957990978376432E-7; -#define MACHEPF 3.0e-8 - -float -_redupif(float x) -{ - float t; - long i; - - t = x / (float)M_PI; - if (t >= 0.0f) - t += 0.5f; - else - t -= 0.5f; - - i = t; /* the multiple */ - t = i; - t = ((x - t * DP1) - t * DP2) - t * DP3; - return t; -} - -/* Taylor series expansion for cosh(2y) - cos(2x) */ - -float -_ctansf(float complex z) -{ - float f, x, x2, y, y2, rn, t, d; - - x = fabsf(2.0f * crealf(z)); - y = fabsf(2.0f * cimagf(z)); - - x = _redupif(x); - - x = x * x; - y = y * y; - x2 = 1.0f; - y2 = 1.0f; - f = 1.0f; - rn = 0.0f; - d = 0.0f; - do { - rn += 1.0f; - f *= rn; - rn += 1.0f; - f *= rn; - x2 *= x; - y2 *= y; - t = y2 + x2; - t /= f; - d += t; + /* 3.14159265358979323846264338 */ +#define DP1 3.140625E0 +#define DP2 0.967502593994140625E-3 +#define DP3 0.1509957990978376434E-6 +#define MACHEP 3.0e-8 - rn += 1.0f; - f *= rn; - rn += 1.0f; - f *= rn; - x2 *= x; - y2 *= y; - t = y2 - x2; - t /= f; - d += t; - } while (fabsf(t/d) > MACHEPF); - return d; -} +#include "cephes_subr.c" Index: complex/cephes_subrl.c =================================================================== RCS file: complex/cephes_subrl.c diff -N complex/cephes_subrl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/cephes_subrl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,41 @@ +/* $NetBSD: cephes_subrf.c,v 1.1 2007/08/20 16:01:34 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double + /* extended precision value of PI: */ + /* 3.14159265358979323846264338327950288419716939937510 */ +#define DP1 3.14159265160560607910E0 +#define DP2 0.198418714791870343106E-8 +#define DP3 0.11442377452219502884197-16 +#define MACHEP 1.1e-16 + +#include "cephes_subr.c" Index: complex/cexp.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cexp.c,v retrieving revision 1.1 diff -u -r1.1 cexp.c --- complex/cexp.c 20 Aug 2007 16:01:34 -0000 1.1 +++ complex/cexp.c 22 Mar 2010 22:50:43 -0000 @@ -33,15 +33,15 @@ #include #include -double complex -cexp(double complex z) +TYPE complex +CEXP(TYPE complex z) { - double complex w; - double r, x, y; + TYPE complex w; + TYPE r, x, y; - x = creal(z); - y = cimag(z); - r = exp(x); - w = r * cos(y) + r * sin(y) * I; + x = CREAL(z); + y = CIMAG(z); + r = EXP(x); + w = r * COS(y) + r * SIN(y) * I; return w; } Index: complex/cexpf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cexpf.c,v retrieving revision 1.1 diff -u -r1.1 cexpf.c --- complex/cexpf.c 20 Aug 2007 16:01:34 -0000 1.1 +++ complex/cexpf.c 22 Mar 2010 22:50:43 -0000 @@ -29,19 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include -#include +#define SFX(a) a ## f +#define TYPE float -float complex -cexpf(float complex z) -{ - float complex w; - float r, x, y; - - x = crealf(z); - y = cimagf(z); - r = expf(x); - w = r * cosf(y) + r * sinf(y) * I; - return w; -} +#include "cexp.c" Index: complex/cexpl.c =================================================================== RCS file: complex/cexpl.c diff -N complex/cexpl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/cexpl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,36 @@ +/* $NetBSD: cexpf.c,v 1.1 2007/08/20 16:01:34 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + + +#define SFX(a) a ## l +#define TYPE long double + +#include "cexp.c" Index: complex/cimag.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cimag.c,v retrieving revision 1.1 diff -u -r1.1 cimag.c --- complex/cimag.c 20 Aug 2007 16:01:34 -0000 1.1 +++ complex/cimag.c 22 Mar 2010 22:50:43 -0000 @@ -5,11 +5,11 @@ * Public domain. */ +#include "../src/namespace.h" #include -double -cimag(double complex z) +TYPE +CIMAG(TYPE complex z) { - return __imag__ z; } Index: complex/cimagf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cimagf.c,v retrieving revision 1.1 diff -u -r1.1 cimagf.c --- complex/cimagf.c 20 Aug 2007 16:01:35 -0000 1.1 +++ complex/cimagf.c 22 Mar 2010 22:50:43 -0000 @@ -5,11 +5,7 @@ * Public domain. */ -#include +#define SFX(a) a ## f +#define TYPE float -float -cimagf(float complex z) -{ - - return __imag__ z; -} +#include "cimag.c" Index: complex/cimagl.c =================================================================== RCS file: complex/cimagl.c diff -N complex/cimagl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/cimagl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,11 @@ +/* $NetBSD: cimagf.c,v 1.1 2007/08/20 16:01:35 drochner Exp $ */ + +/* + * Written by Matthias Drochner . + * Public domain. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "cimag.c" Index: complex/clog.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/clog.c,v retrieving revision 1.1 diff -u -r1.1 clog.c --- complex/clog.c 20 Aug 2007 16:01:35 -0000 1.1 +++ complex/clog.c 22 Mar 2010 22:50:43 -0000 @@ -33,15 +33,15 @@ #include #include -double complex -clog(double complex z) +TYPE complex +CLOG(TYPE complex z) { - double complex w; - double p, rr; + TYPE complex w; + TYPE p, rr; - rr = cabs(z); - p = log(rr); - rr = atan2(cimag(z), creal(z)); + rr = CABS(z); + p = LOG(rr); + rr = ATAN2(CIMAG(z), CREAL(z)); w = p + rr * I; return w; } Index: complex/clogf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/clogf.c,v retrieving revision 1.1 diff -u -r1.1 clogf.c --- complex/clogf.c 20 Aug 2007 16:01:35 -0000 1.1 +++ complex/clogf.c 22 Mar 2010 22:50:43 -0000 @@ -29,19 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include -#include +#define SFX(a) a ## f +#define TYPE float -float complex -clogf(float complex z) -{ - float complex w; - float p, rr; - - rr = cabsf(z); - p = logf(rr); - rr = atan2f(cimagf(z), crealf(z)); - w = p + rr * I; - return w; -} +#include "clog.c" Index: complex/clogl.c =================================================================== RCS file: complex/clogl.c diff -N complex/clogl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/clogl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,35 @@ +/* $NetBSD: clog.c,v 1.1 2007/08/20 16:01:35 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "clog.c" Index: complex/conj.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/conj.c,v retrieving revision 1.1 diff -u -r1.1 conj.c --- complex/conj.c 20 Aug 2007 16:01:35 -0000 1.1 +++ complex/conj.c 22 Mar 2010 22:50:43 -0000 @@ -5,11 +5,11 @@ * Public domain. */ +#include "../src/namespace.h" #include -double complex -conj(double complex z) +TYPE complex +CONJ(TYPE complex z) { - return ~z; } Index: complex/conjf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/conjf.c,v retrieving revision 1.1 diff -u -r1.1 conjf.c --- complex/conjf.c 20 Aug 2007 16:01:35 -0000 1.1 +++ complex/conjf.c 22 Mar 2010 22:50:43 -0000 @@ -5,11 +5,7 @@ * Public domain. */ -#include +#define SFX(a) a ## f +#define TYPE float -float complex -conjf(float complex z) -{ - - return ~z; -} +#include "conj.c" Index: complex/conjl.c =================================================================== RCS file: complex/conjl.c diff -N complex/conjl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/conjl.c 22 Mar 2010 22:50:43 -0000 @@ -0,0 +1,11 @@ +/* $NetBSD: conj.c,v 1.1 2007/08/20 16:01:35 drochner Exp $ */ + +/* + * Written by Matthias Drochner . + * Public domain. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "conj.c" Index: complex/cpow.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cpow.c,v retrieving revision 1.1 diff -u -r1.1 cpow.c --- complex/cpow.c 20 Aug 2007 16:01:35 -0000 1.1 +++ complex/cpow.c 22 Mar 2010 22:50:43 -0000 @@ -33,25 +33,25 @@ #include #include -double complex -cpow(double complex a, double complex z) +TYPE complex +CPOW(TYPE complex a, TYPE complex z) { - double complex w; - double x, y, r, theta, absa, arga; + TYPE complex w; + TYPE x, y, r, theta, absa, arga; - x = creal(z); - y = cimag(z); - absa = cabs(a); + x = CREAL(z); + y = CIMAG(z); + absa = CABS(a); if (absa == 0.0) { return (0.0 + 0.0 * I); } - arga = carg(a); - r = pow(absa, x); + arga = CARG(a); + r = POW(absa, x); theta = x * arga; if (y != 0.0) { - r = r * exp(-y * arga); - theta = theta + y * log(absa); + r = r * EXP(-y * arga); + theta = theta + y * LOG(absa); } - w = r * cos(theta) + (r * sin(theta)) * I; + w = r * COS(theta) + (r * SIN(theta)) * I; return w; } Index: complex/cpowf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/cpowf.c,v retrieving revision 1.1 diff -u -r1.1 cpowf.c --- complex/cpowf.c 20 Aug 2007 16:01:36 -0000 1.1 +++ complex/cpowf.c 22 Mar 2010 22:50:44 -0000 @@ -29,29 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include -#include +#define SFX(a) a ## f +#define TYPE float -float complex -cpowf(float complex a, float complex z) -{ - float complex w; - float x, y, r, theta, absa, arga; - - x = crealf(z); - y = cimagf(z); - absa = cabsf(a); - if (absa == 0.0f) { - return (0.0f + 0.0f * I); - } - arga = cargf(a); - r = powf(absa, x); - theta = x * arga; - if (y != 0.0f) { - r = r * expf(-y * arga); - theta = theta + y * logf(absa); - } - w = r * cosf(theta) + (r * sinf(theta)) * I; - return w; -} +#include "cpow.c" Index: complex/cpowl.c =================================================================== RCS file: complex/cpowl.c diff -N complex/cpowl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/cpowl.c 22 Mar 2010 22:50:44 -0000 @@ -0,0 +1,35 @@ +/* $NetBSD: cpowf.c,v 1.1 2007/08/20 16:01:36 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "cpow.c" Index: complex/creal.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/creal.c,v retrieving revision 1.1 diff -u -r1.1 creal.c --- complex/creal.c 20 Aug 2007 16:01:36 -0000 1.1 +++ complex/creal.c 22 Mar 2010 22:50:44 -0000 @@ -5,11 +5,11 @@ * Public domain. */ +#include "../src/namespace.h" #include -double -creal(double complex z) +TYPE +CREAL(TYPE complex z) { - return __real__ z; } Index: complex/crealf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/crealf.c,v retrieving revision 1.1 diff -u -r1.1 crealf.c --- complex/crealf.c 20 Aug 2007 16:01:36 -0000 1.1 +++ complex/crealf.c 22 Mar 2010 22:50:44 -0000 @@ -5,11 +5,7 @@ * Public domain. */ -#include +#define SFX(a) a ## f +#define TYPE float -float -crealf(float complex z) -{ - - return __real__ z; -} +#include "creal.c" Index: complex/creall.c =================================================================== RCS file: complex/creall.c diff -N complex/creall.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/creall.c 22 Mar 2010 22:50:44 -0000 @@ -0,0 +1,11 @@ +/* $NetBSD: crealf.c,v 1.1 2007/08/20 16:01:36 drochner Exp $ */ + +/* + * Written by Matthias Drochner . + * Public domain. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "creal.c" Index: complex/csin.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/csin.c,v retrieving revision 1.1 diff -u -r1.1 csin.c --- complex/csin.c 20 Aug 2007 16:01:36 -0000 1.1 +++ complex/csin.c 22 Mar 2010 22:50:44 -0000 @@ -34,13 +34,13 @@ #include #include "cephes_subr.h" -double complex -csin(double complex z) +TYPE complex +CSIN(TYPE complex z) { - double complex w; - double ch, sh; + TYPE complex w; + TYPE ch, sh; - _cchsh(cimag(z), &ch, &sh); - w = sin(creal(z)) * ch + (cos(creal(z)) * sh) * I; + _CCHSH(CIMAG(z), &ch, &sh); + w = SIN(CREAL(z)) * ch + (COS(CREAL(z)) * sh) * I; return w; } Index: complex/csinf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/csinf.c,v retrieving revision 1.1 diff -u -r1.1 csinf.c --- complex/csinf.c 20 Aug 2007 16:01:36 -0000 1.1 +++ complex/csinf.c 22 Mar 2010 22:50:44 -0000 @@ -29,18 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include -#include -#include "cephes_subrf.h" +#define SFX(a) a ## f +#define TYPE float -float complex -csinf(float complex z) -{ - float complex w; - float ch, sh; - - _cchshf(cimagf(z), &ch, &sh); - w = sinf(crealf(z)) * ch + (cosf(crealf(z)) * sh) * I; - return w; -} +#include "csin.c" Index: complex/csinh.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/csinh.c,v retrieving revision 1.1 diff -u -r1.1 csinh.c --- complex/csinh.c 20 Aug 2007 16:01:36 -0000 1.1 +++ complex/csinh.c 22 Mar 2010 22:50:44 -0000 @@ -33,14 +33,14 @@ #include #include -double complex -csinh(double complex z) +TYPE complex +CSINH(TYPE complex z) { - double complex w; - double x, y; + TYPE complex w; + TYPE x, y; - x = creal(z); - y = cimag(z); - w = sinh(x) * cos(y) + (cosh(x) * sin(y)) * I; + x = CREAL(z); + y = CIMAG(z); + w = SINH(x) * COS(y) + (COSH(x) * SIN(y)) * I; return w; } Index: complex/csinhf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/csinhf.c,v retrieving revision 1.1 diff -u -r1.1 csinhf.c --- complex/csinhf.c 20 Aug 2007 16:01:37 -0000 1.1 +++ complex/csinhf.c 22 Mar 2010 22:50:44 -0000 @@ -29,18 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include -#include +#define SFX(a) a ## f +#define TYPE float -float complex -csinhf(float complex z) -{ - float complex w; - float x, y; - - x = crealf(z); - y = cimagf(z); - w = sinhf(x) * cosf(y) + (coshf(x) * sinf(y)) * I; - return w; -} +#include "csinh.c" Index: complex/csinhl.c =================================================================== RCS file: complex/csinhl.c diff -N complex/csinhl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/csinhl.c 22 Mar 2010 22:50:44 -0000 @@ -0,0 +1,35 @@ +/* $NetBSD: csinhf.c,v 1.1 2007/08/20 16:01:37 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "csinh.c" Index: complex/csinl.c =================================================================== RCS file: complex/csinl.c diff -N complex/csinl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/csinl.c 22 Mar 2010 22:50:44 -0000 @@ -0,0 +1,35 @@ +/* $NetBSD: csinf.c,v 1.1 2007/08/20 16:01:36 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "csin.c" Index: complex/csqrt.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/csqrt.c,v retrieving revision 1.1 diff -u -r1.1 csqrt.c --- complex/csqrt.c 20 Aug 2007 16:01:37 -0000 1.1 +++ complex/csqrt.c 22 Mar 2010 22:50:44 -0000 @@ -29,24 +29,30 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#ifndef SCALE +#define SCALE2 1.8014398509481984e16 /* 2^54 */ +#define SCALE 7.450580596923828125e-9 /* 2^-27 */ +#endif + +#include "../src/namespace.h" #include #include -double complex -csqrt(double complex z) +TYPE complex +CSQRT(TYPE complex z) { - double complex w; - double x, y, r, t, scale; + TYPE complex w; + TYPE x, y, r, t, scale; - x = creal (z); - y = cimag (z); + x = CREAL (z); + y = CIMAG (z); if (y == 0.0) { if (x == 0.0) { w = 0.0 + y * I; } else { - r = fabs(x); - r = sqrt(r); + r = FABS(x); + r = SQRT(r); if (x < 0.0) { w = 0.0 + r * I; } else { @@ -56,8 +62,8 @@ return w; } if (x == 0.0) { - r = fabs(y); - r = sqrt(0.5 * r); + r = FABS(y); + r = SQRT(NUM(0.5) * r); if (y > 0) w = r + r * I; else @@ -65,30 +71,30 @@ return w; } /* Rescale to avoid internal overflow or underflow. */ - if ((fabs(x) > 4.0) || (fabs(y) > 4.0)) { - x *= 0.25; - y *= 0.25; - scale = 2.0; + if ((FABS(x) > NUM(4.0)) || (FABS(y) > NUM(4.0))) { + x *= NUM(0.25); + y *= NUM(0.25); + scale = TWO; } else { #if 1 - x *= 1.8014398509481984e16; /* 2^54 */ - y *= 1.8014398509481984e16; - scale = 7.450580596923828125e-9; /* 2^-27 */ + x *= SCALE2; + y *= SCALE2; + scale = SCALE; #else - x *= 4.0; - y *= 4.0; - scale = 0.5; + x *= NUM(4.0); + y *= NUM(4.0); + scale = NUM(0.5); #endif } w = x + y * I; - r = cabs(w); + r = CABS(w); if (x > 0) { - t = sqrt(0.5 * r + 0.5 * x); - r = scale * fabs((0.5 * y) / t ); + t = SQRT(NUM(0.5) * r + NUM(0.5) * x); + r = scale * FABS((NUM(0.5) * y) / t ); t *= scale; } else { - r = sqrt(0.5 * r - 0.5 * x); - t = scale * fabs((0.5 * y) / r); + r = SQRT(NUM(0.5) * r - NUM(0.5) * x); + t = scale * FABS((NUM(0.5) * y) / r); r *= scale; } if (y < 0) Index: complex/csqrtf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/csqrtf.c,v retrieving revision 1.1 diff -u -r1.1 csqrtf.c --- complex/csqrtf.c 20 Aug 2007 16:01:37 -0000 1.1 +++ complex/csqrtf.c 22 Mar 2010 22:50:44 -0000 @@ -29,71 +29,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#define SFX(a) a ## f +#define TYPE float +#define SCALE2 6.7108864e7f /* 2^26 */ +#define SCALE 1.220703125e-4f /* 2^-13 */ -float complex -csqrtf(float complex z) -{ - float complex w; - float x, y, r, t, scale; - - x = crealf (z); - y = cimagf (z); - - if (y == 0.0f) { - if (x < 0.0f) { - w = 0.0f + sqrtf(-x) * I; - return w; - } else if (x == 0.0f) { - return (0.0f + y * I); - } else { - w = sqrtf(x) + y * I; - return w; - } - } - - if (x == 0.0f) { - r = fabsf(y); - r = sqrtf(0.5f * r); - if (y > 0) - w = r + r * I; - else - w = r - r * I; - return w; - } - - /* Rescale to avoid internal overflow or underflow. */ - if ((fabsf(x) > 4.0f) || (fabsf(y) > 4.0f)) { - x *= 0.25f; - y *= 0.25f; - scale = 2.0f; - } else { -#if 1 - x *= 6.7108864e7f; /* 2^26 */ - y *= 6.7108864e7f; - scale = 1.220703125e-4f; /* 2^-13 */ -#else - x *= 4.0f; - y *= 4.0f; - scale = 0.5f; -#endif - } - w = x + y * I; - r = cabsf(w); - if( x > 0 ) { - t = sqrtf(0.5f * r + 0.5f * x); - r = scale * fabsf((0.5f * y) / t); - t *= scale; - } else { - r = sqrtf(0.5f * r - 0.5f * x); - t = scale * fabsf((0.5f * y) / r); - r *= scale; - } - - if (y < 0) - w = t - r * I; - else - w = t + r * I; - return w; -} +#include "csqrt.c" Index: complex/csqrtl.c =================================================================== RCS file: complex/csqrtl.c diff -N complex/csqrtl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/csqrtl.c 22 Mar 2010 22:50:44 -0000 @@ -0,0 +1,35 @@ +/* $NetBSD: csqrtf.c,v 1.1 2007/08/20 16:01:37 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "csqrt.c" Index: complex/ctan.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/ctan.c,v retrieving revision 1.1 diff -u -r1.1 ctan.c --- complex/ctan.c 20 Aug 2007 16:01:37 -0000 1.1 +++ complex/ctan.c 22 Mar 2010 22:50:44 -0000 @@ -29,23 +29,26 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#ifndef MAXNUM +#define MAXNUM DBL_MAX +#endif + #include "../src/namespace.h" #include #include +#include #include "cephes_subr.h" -#define MAXNUM 1.0e308 - -double complex -ctan(double complex z) +TYPE complex +CTAN(TYPE complex z) { - double complex w; - double d; + TYPE complex w; + TYPE d; - d = cos(2.0 * creal(z)) + cosh(2.0 * cimag(z)); + d = COS(TWO * CREAL(z)) + COSH(TWO * CIMAG(z)); - if (fabs(d) < 0.25) - d = _ctans(z); + if (FABS(d) < NUM(0.25)) + d = _CTANS(z); if (d == 0.0) { /* mtherr ("ctan", OVERFLOW); */ @@ -53,6 +56,6 @@ return w; } - w = sin(2.0 * creal(z)) / d + (sinh(2.0 * cimag(z)) / d) * I; + w = SIN(TWO * CREAL(z)) / d + (SINH(TWO * CIMAG(z)) / d) * I; return w; } Index: complex/ctanf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/ctanf.c,v retrieving revision 1.1 diff -u -r1.1 ctanf.c --- complex/ctanf.c 20 Aug 2007 16:01:38 -0000 1.1 +++ complex/ctanf.c 22 Mar 2010 22:50:44 -0000 @@ -29,30 +29,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include -#include -#include "cephes_subrf.h" +#define SFX(a) a ## f +#define TYPE float +#define MAXNUM FLT_MAX -#define MAXNUMF 1.0e38f - -float complex -ctanf(float complex z) -{ - float complex w; - float d; - - d = cosf(2.0f * crealf(z)) + coshf(2.0f * cimagf(z)); - - if (fabsf(d) < 0.25f) - d = _ctansf(z); - - if (d == 0.0f) { - /* mtherr ("ctan", OVERFLOW); */ - w = MAXNUMF + MAXNUMF * I; - return w; - } - - w = sinf(2.0f * crealf(z)) / d + (sinhf(2.0f * cimagf(z)) / d) * I; - return w; -} +#include "ctan.c" Index: complex/ctanh.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/ctanh.c,v retrieving revision 1.1 diff -u -r1.1 ctanh.c --- complex/ctanh.c 20 Aug 2007 16:01:38 -0000 1.1 +++ complex/ctanh.c 22 Mar 2010 22:50:44 -0000 @@ -33,16 +33,16 @@ #include #include -double complex -ctanh(double complex z) +TYPE complex +CTANH(TYPE complex z) { - double complex w; - double x, y, d; + TYPE complex w; + TYPE x, y, d; - x = creal(z); - y = cimag(z); - d = cosh(2.0 * x) + cos(2.0 * y); - w = sinh(2.0 * x) / d + (sin(2.0 * y) / d) * I; + x = CREAL(z); + y = CIMAG(z); + d = COSH(TWO * x) + COS(TWO * y); + w = SINH(TWO * x) / d + (SIN(TWO * y) / d) * I; return w; } Index: complex/ctanhf.c =================================================================== RCS file: /cvsroot/src/lib/libm/complex/ctanhf.c,v retrieving revision 1.1 diff -u -r1.1 ctanhf.c --- complex/ctanhf.c 20 Aug 2007 16:01:38 -0000 1.1 +++ complex/ctanhf.c 22 Mar 2010 22:50:44 -0000 @@ -29,20 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../src/namespace.h" -#include -#include +#define SFX(a) a ## f +#define TYPE float -float complex -ctanhf(float complex z) -{ - float complex w; - float x, y, d; - - x = crealf(z); - y = cimagf(z); - d = coshf(2.0f * x) + cosf(2.0f * y); - w = sinhf(2.0f * x) / d + (sinf(2.0f * y) / d) * I; - - return w; -} +#include "ctanh.c" Index: complex/ctanhl.c =================================================================== RCS file: complex/ctanhl.c diff -N complex/ctanhl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/ctanhl.c 22 Mar 2010 22:50:44 -0000 @@ -0,0 +1,35 @@ +/* $NetBSD: ctanhf.c,v 1.1 2007/08/20 16:01:38 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "ctanh.c" Index: complex/ctanl.c =================================================================== RCS file: complex/ctanl.c diff -N complex/ctanl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ complex/ctanl.c 22 Mar 2010 22:50:44 -0000 @@ -0,0 +1,36 @@ +/* $NetBSD: ctanf.c,v 1.1 2007/08/20 16:01:38 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double +#define MAXNUM LDBL_MAX + +#include "ctan.c" Index: noieee_src/mathimpl.h =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/mathimpl.h,v retrieving revision 1.9 diff -u -r1.9 mathimpl.h --- noieee_src/mathimpl.h 1 May 2008 15:33:15 -0000 1.9 +++ noieee_src/mathimpl.h 22 Mar 2010 22:50:44 -0000 @@ -103,12 +103,27 @@ /* * Functions internal to the math package, yet not static. */ -extern double __exp__E(double, double); -extern double __log__L(double); -extern int infnan(int); +double __exp__E(double, double); +static inline float +__exp__Ef(float a, float b) +{ + return __exp__E((double)a, (double)b); +} +double __log__L(double); +static inline float +__log__Lf(float a) +{ + return __log__L((double) a); +} +int infnan(int); -struct Double {double a, b;}; double __exp__D(double, double); +static inline float +__exp__Df(float a, float b) +{ + return __exp__D((double)a, (double)b); +} +struct Double {double a, b;}; struct Double __log__D(double); #endif /* _NOIEEE_SRC_MATHIMPL_H_ */ Index: noieee_src/n_asincos.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_asincos.c,v retrieving revision 1.7 diff -u -r1.7 n_asincos.c --- noieee_src/n_asincos.c 7 Aug 2003 16:44:50 -0000 1.7 +++ noieee_src/n_asincos.c 22 Mar 2010 22:50:44 -0000 @@ -86,6 +86,7 @@ * 1.99 ulps. */ +#include "../src/namespace.h" #include "mathimpl.h" double Index: noieee_src/n_asinh.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_asinh.c,v retrieving revision 1.7 diff -u -r1.7 n_asinh.c --- noieee_src/n_asinh.c 29 Apr 2008 15:10:02 -0000 1.7 +++ noieee_src/n_asinh.c 22 Mar 2010 22:50:44 -0000 @@ -66,36 +66,46 @@ * from decimal to binary accurately enough to produce the hexadecimal values * shown. */ +#ifndef DIG +#define DIG DBL_DIG +#endif + #define _LIBM_STATIC +#include "../src/namespace.h" #include "mathimpl.h" +#include -vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) -vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) +#if DIG == 6 +#define SMALL NUM(1.0E-4) /* fl(1+small*small) == 1 */ +#define BIG NUM(1.0E8) /* fl(1+big) == big */ -ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) -ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76) +static const float ln2hi = 0.69314712285995483398; +static const float ln2lo = 0.576999887E-7; +#elif DIG == 16 || DIG == 15 +#define SMALL NUM(1.0E-9) /* fl(1+small*small) == 1 */ +#define BIG NUM(1.0E18) /* fl(1+big) == big */ -#ifdef vccast -#define ln2hi vccast(ln2hi) -#define ln2lo vccast(ln2lo) +static const double ln2hi = 0.69314718055829871446; +static const double ln2lo = 0.16465949523212145817E-11; +#else +#error unhandled case for DIG #endif -double -asinh(double x) +TYPE +ASINH(TYPE x) { - double t,s; - static const double small=1.0E-10, /* fl(1+small*small) == 1 */ - big =1.0E20, /* fl(1+big) == big */ - one =1.0 ; - -#if !defined(__vax__)&&!defined(tahoe) - if(x!=x) return(x); /* x is NaN */ -#endif /* !defined(__vax__)&&!defined(tahoe) */ - if((t=copysign(x,one))>small) - if(t big */ - {s=log1p(t)+ln2lo; return(copysign(s+ln2hi,x));} - else /* if |x| < small */ - return(x); + TYPE t,s; + + t = COPYSIGN(x, ONE); + if (t > SMALL) { + if (t < BIG) { + s = ONE/t; + return COPYSIGN(LOG1P(t + t/(s+SQRT(ONE + s*s))), x); + } else { /* if |x| > big */ + s = LOG1P(t) + ln2lo; + return COPYSIGN(s + ln2hi, x); + } + } else { /* if |x| < SMALL */ + return x; + } } Index: noieee_src/n_asinhf.c =================================================================== RCS file: noieee_src/n_asinhf.c diff -N noieee_src/n_asinhf.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ noieee_src/n_asinhf.c 22 Mar 2010 22:50:44 -0000 @@ -0,0 +1,36 @@ +/* $NetBSD: csinf.c,v 1.1 2007/08/20 16:01:36 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## f +#define TYPE float +#define DIG FLT_DIG + +#include "n_asinh.c" Index: noieee_src/n_asinhl.c =================================================================== RCS file: noieee_src/n_asinhl.c diff -N noieee_src/n_asinhl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ noieee_src/n_asinhl.c 22 Mar 2010 22:50:44 -0000 @@ -0,0 +1,35 @@ +/* $NetBSD: csinf.c,v 1.1 2007/08/20 16:01:36 drochner Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software written by Stephen L. Moshier. + * It is redistributed by the NetBSD Foundation by permission of the author. + * + * 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. + */ + +#define SFX(a) a ## l +#define TYPE long double + +#include "n_asinh.c" Index: noieee_src/n_atan.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_atan.c,v retrieving revision 1.5 diff -u -r1.5 n_atan.c --- noieee_src/n_atan.c 7 Aug 2003 16:44:50 -0000 1.5 +++ noieee_src/n_atan.c 22 Mar 2010 22:50:44 -0000 @@ -77,11 +77,22 @@ * maximum observed error in ulps (units in the last place) was * 0.85 ulps. */ +#include "../src/namespace.h" #include "mathimpl.h" +__weak_alias(atanl, atan); +__strong_alias(_atanl, atan); + double atan(double x) { - double one=1.0; - return(atan2(x,one)); + return atan2(x, ONE); +} + +__weak_alias(atanf, _atanf); + +float +atanf(float x) +{ + return atan2f(x, ONE); } Index: noieee_src/n_atan2.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_atan2.c,v retrieving revision 1.6 diff -u -r1.6 n_atan2.c --- noieee_src/n_atan2.c 7 Aug 2003 16:44:50 -0000 1.6 +++ noieee_src/n_atan2.c 22 Mar 2010 22:50:44 -0000 @@ -277,3 +277,15 @@ return(copysign((signx>zero)?z:PI-z,signy)); } + +float +atan2f(float y, float x) +{ + return atan2(y, x); +} + +long double +atan2l(long double y, long double x) +{ + return atan2(y, x); +} Index: noieee_src/n_atanh.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_atanh.c,v retrieving revision 1.7 diff -u -r1.7 n_atanh.c --- noieee_src/n_atanh.c 7 Aug 2003 16:44:50 -0000 1.7 +++ noieee_src/n_atanh.c 22 Mar 2010 22:50:44 -0000 @@ -60,11 +60,13 @@ * observed error was 1.87 ulps (units in the last place) at * x= -3.8962076028810414000e-03. */ +#include "../src/namespace.h" #include "mathimpl.h" -#if defined(__vax__)||defined(tahoe) #include -#endif /* defined(__vax__)||defined(tahoe) */ + +__weak_alias(atanhl, atanh); +__strong_alias(_atanhl, atanh); double atanh(double x) @@ -80,3 +82,10 @@ x = x/(1.0-x); return( z*log1p(x+x) ); } + +__weak_alias(atanhf, _atanhf); +float +atanhf(float x) +{ + return atanh((double) x); +} Index: noieee_src/n_cosh.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_cosh.c,v retrieving revision 1.8 diff -u -r1.8 n_cosh.c --- noieee_src/n_cosh.c 20 Mar 2008 16:41:26 -0000 1.8 +++ noieee_src/n_cosh.c 22 Mar 2010 22:50:44 -0000 @@ -85,10 +85,10 @@ #include "../src/namespace.h" #include "mathimpl.h" -#ifdef __weak_alias __weak_alias(cosh, _cosh); __weak_alias(coshf, _coshf); -#endif +__weak_alias(coshl, _cosh); +__strong_alias(_coshl, _cosh); vc(mln2hi, 8.8029691931113054792E1 ,0f33,43b0,2bdb,c7e2, 7, .B00F33C7E22BDB) vc(mln2lo,-4.9650192275318476525E-16 ,1b60,a70f,582a,279e, -50,-.8F1B60279E582A) Index: noieee_src/n_exp.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_exp.c,v retrieving revision 1.8 diff -u -r1.8 n_exp.c --- noieee_src/n_exp.c 20 Mar 2008 16:41:26 -0000 1.8 +++ noieee_src/n_exp.c 22 Mar 2010 22:50:44 -0000 @@ -80,9 +80,11 @@ #include "../src/namespace.h" #include "mathimpl.h" -#ifdef __weak_alias +#ifndef lint __weak_alias(exp, _exp); +__weak_alias(expl, _exp); __weak_alias(expf, _expf); +__strong_alias(_expl, _exp); #endif vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) Index: noieee_src/n_gamma.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_gamma.c,v retrieving revision 1.6 diff -u -r1.6 n_gamma.c --- noieee_src/n_gamma.c 24 Nov 2006 21:15:54 -0000 1.6 +++ noieee_src/n_gamma.c 22 Mar 2010 22:50:44 -0000 @@ -41,8 +41,9 @@ * acknowledged. */ -#include +#include "../src/namespace.h" #include "mathimpl.h" +#include #include /* METHOD: @@ -134,9 +135,16 @@ #define infnan(x) 0.0 #endif +#ifndef lint +__weak_alias(tgamma, _tgamma); +__weak_alias(gamma, _tgamma); +__weak_alias(gammal, _tgamma); +__weak_alias(tgammal, _tgamma); +__strong_alias(_tgammal, _tgamma); +#endif + double -gamma(x) - double x; +tgamma(double x) { double b; struct Double u; @@ -331,3 +339,14 @@ if (sgn < 0) y = -y; return (M_PI / (y*z)); } + +#ifndef lint +__weak_alias(gammaf, _tgammaf); +__weak_alias(tgammaf, _tgammaf); +#endif + +float +tgammaf(float x) +{ + return tgamma((double) x); +} Index: noieee_src/n_jn.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_jn.c,v retrieving revision 1.6 diff -u -r1.6 n_jn.c --- noieee_src/n_jn.c 7 Aug 2003 16:44:51 -0000 1.6 +++ noieee_src/n_jn.c 22 Mar 2010 22:50:44 -0000 @@ -309,3 +309,15 @@ return (infnan(-sign * ERANGE)); return ((sign > 0) ? b : -b); } + +float +jnf(int n, float x) +{ + return jn(n, (double) x); +} + +float +ynf(int n, float x) +{ + return yn(n, (double) x); +} Index: noieee_src/n_log.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_log.c,v retrieving revision 1.7 diff -u -r1.7 n_log.c --- noieee_src/n_log.c 20 Mar 2008 16:41:26 -0000 1.7 +++ noieee_src/n_log.c 22 Mar 2010 22:50:45 -0000 @@ -41,10 +41,10 @@ #include "mathimpl.h" -#ifdef __weak_alias __weak_alias(log, _log); +__weak_alias(logl, _log); __weak_alias(logf, _logf); -#endif +__strong_alias(_logl, _log); /* Table-driven natural logarithm. * Index: noieee_src/n_log10.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_log10.c,v retrieving revision 1.6 diff -u -r1.6 n_log10.c --- noieee_src/n_log10.c 7 Aug 2003 16:44:52 -0000 1.6 +++ noieee_src/n_log10.c 22 Mar 2010 22:50:45 -0000 @@ -71,25 +71,26 @@ * from decimal to binary accurately enough to produce the hexadecimal values * shown. */ - +#include #define _LIBM_STATIC +#include "../src/namespace.h" #include "mathimpl.h" -vc(ln10hi, 2.3025850929940456790E0 ,5d8d,4113,a8ac,ddaa, 2, .935D8DDDAAA8AC) - -ic(ivln10, 4.3429448190325181667E-1, -2, 1.BCB7B1526E50E) - -#ifdef vccast -#define ln10hi vccast(ln10hi) -#endif +#define LN10 2.3025850929940456790E0 +__weak_alias(log10, _log10); +__weak_alias(log10l, _log10); +__strong_alias(_log10l, _log10); +__weak_alias(log10f, _log10f); double log10(double x) { -#if defined(__vax__)||defined(tahoe) - return(log(x)/ln10hi); -#else /* defined(__vax__)||defined(tahoe) */ - return(ivln10*log(x)); -#endif /* defined(__vax__)||defined(tahoe) */ + return log(x) / LN10; +} + +float +log10f(float x) +{ + return logf(x) / (float)LN10; } Index: noieee_src/n_log1p.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_log1p.c,v retrieving revision 1.7 diff -u -r1.7 n_log1p.c --- noieee_src/n_log1p.c 29 Apr 2008 15:10:02 -0000 1.7 +++ noieee_src/n_log1p.c 22 Mar 2010 22:50:45 -0000 @@ -93,78 +93,81 @@ * shown. */ +#include + +#ifndef DIG +#define DIG DBL_DIG +#ifndef lint +__weak_alias(log1p, _log1p); +__weak_alias(log1pl, _log1p); +#endif +#ifndef lint +__strong_alias(_log1pl, _log1p); +#endif +#endif + #include #define _LIBM_STATIC +#include "../src/namespace.h" #include "mathimpl.h" +#include -vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) -vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) -vc(sqrt2, 1.4142135623730950622E0 ,04f3,40b5,de65,33f9, 1, .B504F333F9DE65) - -ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) -ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76) -ic(sqrt2, 1.4142135623730951455E0, 0, 1.6A09E667F3BCD) - -#ifdef vccast -#define ln2hi vccast(ln2hi) -#define ln2lo vccast(ln2lo) -#define sqrt2 vccast(sqrt2) + +#define SQRT2 NUM(1.4142135623730950622E0) +#define HALF NUM(0.5) + +#if DIG == 15 || DIG == 16 +#define LN2HI NUM(6.9314718055829871446E-1) +#define LN2LO NUM(1.6465949582897081279E-12) +#define SMALL NUM(1.0E-18) +#elif DIG == 6 +#define LN2HI NUM(6.9314575E-1) +#define LN2LO NUM(1.4286068E-6) +#define SMALL NUM(1.0E-8) +#else +#error unhandled DIG value #endif -double -log1p(double x) +TYPE +LOG1P(TYPE x) { - static const double zero=0.0, negone= -1.0, one=1.0, - half=1.0/2.0, small=1.0E-20; /* 1+small == 1 */ - double z,s,t,c; + TYPE z,s,t,c; int k; -#if !defined(__vax__)&&!defined(tahoe) - if(x!=x) return(x); /* x is NaN */ -#endif /* !defined(__vax__)&&!defined(tahoe) */ - - if(finite(x)) { - if( x > negone ) { - - /* argument reduction */ - if(copysign(x,one)= sqrt2 ) - { k += 1 ; z *= half; t *= half; } - t += negone; x = z + t; - c = (t-x)+z ; /* correction term for x */ - - /* compute log(1+x) */ - s = x/(2+x); t = x*x*half; - c += (k*ln2lo-c*x); - z = c+s*(t+__log__L(s*s)); - x += (z - t) ; - - return(k*ln2hi+x); - } - /* end of if (x > negone) */ - - else { -#if defined(__vax__)||defined(tahoe) - if ( x == negone ) - return (infnan(-ERANGE)); /* -INF */ - else - return (infnan(EDOM)); /* NaN */ -#else /* defined(__vax__)||defined(tahoe) */ - /* x = -1, return -INF with signal */ - if ( x == negone ) return( negone/zero ); - - /* negative argument for log, return NaN with signal */ - else return ( zero / zero ); -#endif /* defined(__vax__)||defined(tahoe) */ - } + if (FINITE(x)) { + if (x > -ONE) { + /* argument reduction */ + if (COPYSIGN(x, ONE) < SMALL) + return x; + k = LOGB(ONE + x); + z = SCALB(x, -k); + t = SCALB(ONE, -k); + if (z + t >= SQRT2) { + k += 1; + z *= HALF; + t *= HALF; + } + t -= ONE; + x = z + t; + c = (t-x)+z ; /* correction term for x */ + + /* compute log(1+x) */ + s = x / (TWO + x); + t = x * x * HALF; + c += k * LN2LO - c * x; + z = c + s * (t + __LOG__L(s * s)); + x += (z - t); + + return k * LN2HI + x; + } else if (x == -ONE) { + return infnan(-ERANGE); /* -INF */ + } else { + return infnan(EDOM); /* NaN */ + } + } else if (x < 0.0) { + const double zero = 0.0; + return zero/zero; /* log(-INF) is NaN */ + } else { + return x; /* log(+INF) is INF */ } - /* end of if (finite(x)) */ - - /* log(-INF) is NaN */ - else if(x<0) - return(zero/zero); - - /* log(+INF) is INF */ - else return(x); } Index: noieee_src/n_log1pf.c =================================================================== RCS file: noieee_src/n_log1pf.c diff -N noieee_src/n_log1pf.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ noieee_src/n_log1pf.c 22 Mar 2010 22:50:45 -0000 @@ -0,0 +1,38 @@ +/* $NetBSD: n_log1p.c,v 1.7 2008/04/29 15:10:02 uwe Exp $ */ +/* + * Copyright (c) 1985, 1993 + * The Regents of the University of California. All rights reserved. + * + * 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 + +#define SFX(a) a ## f +#define TYPE float +#define DIG FLT_DIG +__weak_alias(log1pf, _log1pf); + +#include "n_log1p.c" Index: noieee_src/n_pow.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_pow.c,v retrieving revision 1.7 diff -u -r1.7 n_pow.c --- noieee_src/n_pow.c 7 Aug 2003 16:44:52 -0000 1.7 +++ noieee_src/n_pow.c 22 Mar 2010 22:50:45 -0000 @@ -103,6 +103,7 @@ * shown. */ +#include "../src/namespace.h" #include #include @@ -122,12 +123,17 @@ static double pow_P (double, double); +__weak_alias(powf, _powf); + float powf(float x, float y) { - return pow((double) x, (double) (y)); + return pow((double) x, (double) (y)); } +__weak_alias(powl, pow); +__strong_alias(_powl, pow); + double pow(double x, double y) { Index: noieee_src/n_sincos.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_sincos.c,v retrieving revision 1.6 diff -u -r1.6 n_sincos.c --- noieee_src/n_sincos.c 7 Aug 2003 16:44:52 -0000 1.6 +++ noieee_src/n_sincos.c 22 Mar 2010 22:50:45 -0000 @@ -70,7 +70,13 @@ float sinf(float x) { - return sin(x); + return sin((double)x); +} + +long double +sinl(long double x) +{ + return sin((double)x); } double @@ -108,3 +114,9 @@ { return cos(x); } + +long double +cosl(long double x) +{ + return cos(x); +} Index: noieee_src/n_sinh.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_sinh.c,v retrieving revision 1.7 diff -u -r1.7 n_sinh.c --- noieee_src/n_sinh.c 20 Mar 2008 16:41:26 -0000 1.7 +++ noieee_src/n_sinh.c 22 Mar 2010 22:50:45 -0000 @@ -78,9 +78,11 @@ #include "../src/namespace.h" #include "mathimpl.h" -#ifdef __weak_alias +#ifndef lint __weak_alias(sinh, _sinh); +__weak_alias(sinhl, _sinh); __weak_alias(sinhf, _sinhf); +__strong_alias(_sinhl, _sinh); #endif vc(mln2hi, 8.8029691931113054792E1 ,0f33,43b0,2bdb,c7e2, 7, .B00F33C7E22BDB) Index: noieee_src/n_tan.c =================================================================== RCS file: /cvsroot/src/lib/libm/noieee_src/n_tan.c,v retrieving revision 1.5 diff -u -r1.5 n_tan.c --- noieee_src/n_tan.c 7 Aug 2003 16:44:52 -0000 1.5 +++ noieee_src/n_tan.c 22 Mar 2010 22:50:45 -0000 @@ -36,6 +36,7 @@ #include "mathimpl.h" #include "trig.h" + double tan(double x) { @@ -71,3 +72,15 @@ else return c/(x+x*ss); /* ... cos/sin */ } + +float +tanf(float x) +{ + return tan(x); +} + +long double +tanl(long double x) +{ + return tan(x); +} Index: noieee_src/n_tgamma.c =================================================================== RCS file: noieee_src/n_tgamma.c diff -N noieee_src/n_tgamma.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ noieee_src/n_tgamma.c 22 Mar 2010 22:50:45 -0000 @@ -0,0 +1,84 @@ +/*- + * Copyright (c) 2008 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Matt Thomas + * + * 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 +#include + +/* Coefficients used by the Lanczos Approximation. */ +static const double p[9] = { + 0.99999999999980993, + 676.5203681218851, + -1259.1392167224028, + 771.32342877765313, + -176.61502916214059, + 12.507343278686905, + -0.13857109526572012, + 9.9843695780195716e-6, + 1.5056327351493116e-7 +}; + +double +tgamma(double z) +{ + double x; + double t; + int i; + + if (z == 0.0) { + errno = ERANGE; + return HUGE_VAL; + } + if (z < 0.0) { + errno = EDOM; + return 0.0; + } + /* Reflection formula */ + if (z < 0.5) + return M_PI / (sin(M_PI * z) * tgamma(1.0-z)); + + z -= 1.0; + x = p[0]; + for (i = 1; i < __arraycount(p); i++) { + x += p[i]/(z+i); + } + t = z + (__arraycount(p)-2) + 0.5; + return sqrt(2*M_PI) * pow(t, z + 0.5) * exp(-t) * x; +} + +float +tgammaf(float z) +{ + return tgamma(z); +} + +long double +tgammal(long double z) +{ + return tgamma(z); +} Index: src/namespace.h =================================================================== RCS file: /cvsroot/src/lib/libm/src/namespace.h,v retrieving revision 1.2 diff -u -r1.2 namespace.h --- src/namespace.h 20 Aug 2007 16:01:39 -0000 1.2 +++ src/namespace.h 22 Mar 2010 22:50:45 -0000 @@ -1,29 +1,114 @@ /* $NetBSD: namespace.h,v 1.2 2007/08/20 16:01:39 drochner Exp $ */ +#ifndef lint +/*#define atan _atan */ +#define atanf _atanf +#define atanl _atanl #define atan2 _atan2 #define atan2f _atan2f +#define atan2l _atan2l +/* #define atanh _atanh */ +#define atanhf _atanhf +#define atanhl _atanhl #define hypot _hypot #define hypotf _hypotf +#define hypotl _hypotl #define exp _exp #define expf _expf +#define expl _expl #define log _log #define logf _logf +#define logl _logl +#define log10 _log10 +#define log10f _log10f +#define log10l _log10l +#define log1p _log1p +#define log1pf _log1pf +#define log1pl _log1pl #if 0 /* not yet - need to review use in machdep code first */ #define sin _sin #define sinf _sinf +#define sinl _sinl #define cos _cos #define cosf _cosf +#define cosl _cosl #endif /* notyet */ #define sinh _sinh #define sinhf _sinhf +#define sinhl _sinhl #define cosh _cosh #define coshf _coshf +#define coshl _coshl #define asin _asin #define asinf _asinf +#define asinl _asinl + +#define powf _powf #define casin _casin #define casinf _casinf +#define casinl _casinl #define catan _catan #define catanf _catanf +#define catanl _catanl + +#define gammaf _gammaf +#define tgamma _tgamma +#define tgammaf _tgammaf +#define tgammal _tgammal +#endif /* !lint */ + +#ifndef SFX +#define SFX(a) a +#define TYPE double +#endif + +#define ASINH SFX(asinh) +#define ATAN2 SFX(atan2) +#define CABS SFX(cabs) +#define CARG SFX(carg) +#define CACOS SFX(cacos) +#define CACOSH SFX(cacosh) +#define CASIN SFX(casin) +#define CASINH SFX(casinh) +#define CATAN SFX(catan) +#define CATANH SFX(catanh) +#define CCOS SFX(ccos) +#define CCOSH SFX(ccosh) +#define CEXP SFX(cexp) +#define CIMAG SFX(cimag) +#define CLOG SFX(clog) +#define CONJ SFX(conj) +#define COPYSIGN SFX(copysign) +#define COS SFX(cos) +#define COSH SFX(cosh) +#define CPOW SFX(cpow) +#define CREAL SFX(creal) +#define CSIN SFX(csin) +#define CSINH SFX(csinh) +#define CSQRT SFX(csqrt) +#define CTAN SFX(ctan) +#define CTANH SFX(ctanh) +#define EXP SFX(exp) +#define FABS SFX(fabs) +#define FINITE SFX(finite) +#define HYPOT SFX(hypot) +#define LOG SFX(log) +#define LOG1P SFX(log1p) +#define LOGB SFX(logb) +#define POW SFX(pow) +#define SCALB SFX(scalb) +#define SIN SFX(sin) +#define SINH SFX(sinh) +#define SQRT SFX(sqrt) + +#define _CCHSH SFX(_cchsh) +#define _REDUPI SFX(_redupi) +#define _CTANS SFX(_ctans) +#define __LOG__L SFX(__log__L) + +#define ONE SFX(1.0) +#define TWO SFX(2.0) +#define NUM(x) SFX(x)