diff --git a/lib/msun/amd64/Makefile.inc b/lib/msun/amd64/Makefile.inc index a747b678424d..1914ce8f5803 100644 --- a/lib/msun/amd64/Makefile.inc +++ b/lib/msun/amd64/Makefile.inc @@ -1,4 +1,5 @@ # $FreeBSD$ -ARCH_SRCS = e_sqrt.S s_lrint.S s_llrint.S s_remquo.S s_remquof.S +ARCH_SRCS = e_sqrt.S e_sqrtf.S s_llrint.S s_llrintf.S s_lrint.S s_lrintf.S \ + s_remquo.S s_remquof.S s_scalbn.S s_scalbnf.S s_scalbnl.S LDBL_PREC = 64 diff --git a/lib/msun/amd64/e_sqrtf.S b/lib/msun/amd64/e_sqrtf.S new file mode 100644 index 000000000000..25f4dfc5bf84 --- /dev/null +++ b/lib/msun/amd64/e_sqrtf.S @@ -0,0 +1,32 @@ +/*- + * Copyright (c) 2005 David Schultz + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 +__FBSDID("$FreeBSD$") + +ENTRY(sqrtf) + sqrtss %xmm0, %xmm0 + ret diff --git a/lib/msun/amd64/s_llrintf.S b/lib/msun/amd64/s_llrintf.S new file mode 100644 index 000000000000..e810e40b640d --- /dev/null +++ b/lib/msun/amd64/s_llrintf.S @@ -0,0 +1,6 @@ +#include +__FBSDID("$FreeBSD$") + +/* sizeof(long) == sizeof(long long) */ +#define fn llrintf +#include "s_lrintf.S" diff --git a/lib/msun/amd64/s_lrintf.S b/lib/msun/amd64/s_lrintf.S new file mode 100644 index 000000000000..cc27d208ae4a --- /dev/null +++ b/lib/msun/amd64/s_lrintf.S @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 2005 David Schultz + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 + +#ifndef fn +__FBSDID("$FreeBSD$") +#define fn lrintf +#endif + +ENTRY(fn) + cvtss2si %xmm0, %rax + ret diff --git a/lib/msun/amd64/s_scalbn.S b/lib/msun/amd64/s_scalbn.S new file mode 100644 index 000000000000..c9ac808b9b03 --- /dev/null +++ b/lib/msun/amd64/s_scalbn.S @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2005 David Schultz + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 +__FBSDID("$FreeBSD$") + +ENTRY(scalbn) + movsd %xmm0,-8(%rsp) + movl %edi,-12(%rsp) + fildl -12(%rsp) + fldl -8(%rsp) + fscale + fstp %st(1) + fstpl -8(%rsp) + movsd -8(%rsp),%xmm0 + ret diff --git a/lib/msun/amd64/s_scalbnf.S b/lib/msun/amd64/s_scalbnf.S new file mode 100644 index 000000000000..d1bcb9f183a9 --- /dev/null +++ b/lib/msun/amd64/s_scalbnf.S @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2005 David Schultz + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 +__FBSDID("$FreeBSD$") + +ENTRY(scalbnf) + movss %xmm0,-8(%rsp) + movl %edi,-4(%rsp) + fildl -4(%rsp) + flds -8(%rsp) + fscale + fstp %st(1) + fstps -8(%rsp) + movss -8(%rsp),%xmm0 + ret diff --git a/lib/msun/amd64/s_scalbnl.S b/lib/msun/amd64/s_scalbnl.S new file mode 100644 index 000000000000..8dfa810757af --- /dev/null +++ b/lib/msun/amd64/s_scalbnl.S @@ -0,0 +1,19 @@ +/* + * Based on code written by J.T. Conklin . + * Public domain. + */ + +#include +__FBSDID("$FreeBSD$") +/* RCSID("$NetBSD: s_scalbnf.S,v 1.4 1999/01/02 05:15:40 kristerw Exp $") */ + +ENTRY(scalbnl) + movl %edi,-4(%rsp) + fildl -4(%rsp) + fldt 8(%rsp) + fscale + fstp %st(1) + ret + +.globl CNAME(ldexpl) +.set CNAME(ldexpl),CNAME(scalbnl) diff --git a/lib/msun/i387/Makefile.inc b/lib/msun/i387/Makefile.inc index 38cb0fc2e2d0..bae4c620a154 100644 --- a/lib/msun/i387/Makefile.inc +++ b/lib/msun/i387/Makefile.inc @@ -3,14 +3,16 @@ ARCH_SRCS = e_exp.S e_fmod.S e_log.S e_log10.S \ e_remainder.S e_scalb.S e_sqrt.S s_ceil.S s_copysign.S \ s_cos.S s_finite.S s_floor.S s_llrint.S s_logb.S s_lrint.S \ - s_remquo.S s_rint.S s_scalbn.S s_significand.S s_sin.S s_tan.S + s_remquo.S s_rint.S s_scalbn.S s_significand.S s_sin.S s_tan.S \ + s_trunc.S # float counterparts ARCH_SRCS+= e_log10f.S e_logf.S e_remainderf.S e_scalbf.S \ - e_sqrtf.S s_ceilf.S s_copysignf.S s_floorf.S s_logbf.S \ - s_remquof.S s_rintf.S s_scalbnf.S s_significandf.S + e_sqrtf.S s_ceilf.S s_copysignf.S s_floorf.S \ + s_llrintf.S s_logbf.S s_lrintf.S \ + s_remquof.S s_rintf.S s_scalbnf.S s_significandf.S s_truncf.S # long double counterparts -ARCH_SRCS+= s_scalbnl.S +ARCH_SRCS+= s_ceill.S s_copysignl.S s_floorl.S s_scalbnl.S s_truncl.S LDBL_PREC = 64 # XXX 64-bit format, but truncated to 53 bits diff --git a/lib/msun/i387/s_ceill.S b/lib/msun/i387/s_ceill.S new file mode 100644 index 000000000000..ae64abfecaf8 --- /dev/null +++ b/lib/msun/i387/s_ceill.S @@ -0,0 +1,27 @@ +/* + * Based on code written by J.T. Conklin . + * Public domain. + */ + +#include +__FBSDID("$FreeBSD$") + +ENTRY(ceill) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -4(%ebp) /* store fpu control word */ + movw -4(%ebp),%dx + orw $0x0800,%dx /* round towards +oo */ + andw $0xfbff,%dx + movw %dx,-8(%ebp) + fldcw -8(%ebp) /* load modfied control word */ + + fldt 8(%ebp) /* round */ + frndint + + fldcw -4(%ebp) /* restore original control word */ + + leave + ret diff --git a/lib/msun/i387/s_copysignl.S b/lib/msun/i387/s_copysignl.S new file mode 100644 index 000000000000..7878591d387e --- /dev/null +++ b/lib/msun/i387/s_copysignl.S @@ -0,0 +1,17 @@ +/* + * Based on code written by J.T. Conklin . + * Public domain. + */ + +#include +__FBSDID("$FreeBSD$") + +ENTRY(copysignl) + movl 24(%esp),%edx + andl $0x8000,%edx + movl 12(%esp),%eax + andl $0x7fff,%eax + orl %edx,%eax + movl %eax,12(%esp) + fldt 4(%esp) + ret diff --git a/lib/msun/i387/s_floorl.S b/lib/msun/i387/s_floorl.S new file mode 100644 index 000000000000..a0bb048e4a7d --- /dev/null +++ b/lib/msun/i387/s_floorl.S @@ -0,0 +1,27 @@ +/* + * Based on code written by J.T. Conklin . + * Public domain. + */ + +#include +__FBSDID("$FreeBSD$") + +ENTRY(floorl) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -4(%ebp) /* store fpu control word */ + movw -4(%ebp),%dx + orw $0x0400,%dx /* round towards -oo */ + andw $0xf7ff,%dx + movw %dx,-8(%ebp) + fldcw -8(%ebp) /* load modfied control word */ + + fldt 8(%ebp) /* round */ + frndint + + fldcw -4(%ebp) /* restore original control word */ + + leave + ret diff --git a/lib/msun/i387/s_llrintf.S b/lib/msun/i387/s_llrintf.S new file mode 100644 index 000000000000..4f398b6dd1b8 --- /dev/null +++ b/lib/msun/i387/s_llrintf.S @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 2005 David Schultz + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 +__FBSDID("$FreeBSD$") + +ENTRY(llrintf) + flds 4(%esp) + subl $8,%esp + fistpll (%esp) + popl %eax + popl %edx + ret diff --git a/lib/msun/i387/s_lrintf.S b/lib/msun/i387/s_lrintf.S new file mode 100644 index 000000000000..b9915fa5d071 --- /dev/null +++ b/lib/msun/i387/s_lrintf.S @@ -0,0 +1,35 @@ +/*- + * Copyright (c) 2005 David Schultz + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 +__FBSDID("$FreeBSD$") + +ENTRY(lrintf) + flds 4(%esp) + subl $4,%esp + fistpl (%esp) + popl %eax + ret diff --git a/lib/msun/i387/s_trunc.S b/lib/msun/i387/s_trunc.S new file mode 100644 index 000000000000..91926d7373c4 --- /dev/null +++ b/lib/msun/i387/s_trunc.S @@ -0,0 +1,26 @@ +/* + * Based on code written by J.T. Conklin . + * Public domain. + */ + +#include +__FBSDID("$FreeBSD$") + +ENTRY(trunc) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -4(%ebp) /* store fpu control word */ + movw -4(%ebp),%dx + orw $0x0c00,%dx /* round towards -oo */ + movw %dx,-8(%ebp) + fldcw -8(%ebp) /* load modfied control word */ + + fldl 8(%ebp) /* round */ + frndint + + fldcw -4(%ebp) /* restore original control word */ + + leave + ret diff --git a/lib/msun/i387/s_truncf.S b/lib/msun/i387/s_truncf.S new file mode 100644 index 000000000000..b7329081a8f6 --- /dev/null +++ b/lib/msun/i387/s_truncf.S @@ -0,0 +1,26 @@ +/* + * Based on code written by J.T. Conklin . + * Public domain. + */ + +#include +__FBSDID("$FreeBSD$") + +ENTRY(truncf) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -12(%ebp) /* store fpu control word */ + movw -12(%ebp),%dx + orw $0x0c00,%dx /* round towards -oo */ + movw %dx,-16(%ebp) + fldcw -16(%ebp) /* load modfied control word */ + + flds 8(%ebp) /* round */ + frndint + + fldcw -12(%ebp) /* restore original control word */ + + leave + ret diff --git a/lib/msun/i387/s_truncl.S b/lib/msun/i387/s_truncl.S new file mode 100644 index 000000000000..b20b06ebcfc4 --- /dev/null +++ b/lib/msun/i387/s_truncl.S @@ -0,0 +1,26 @@ +/* + * Based on code written by J.T. Conklin . + * Public domain. + */ + +#include +__FBSDID("$FreeBSD$") + +ENTRY(truncl) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -4(%ebp) /* store fpu control word */ + movw -4(%ebp),%dx + orw $0x0c00,%dx /* round towards -oo */ + movw %dx,-8(%ebp) + fldcw -8(%ebp) /* load modfied control word */ + + fldt 8(%ebp) /* round */ + frndint + + fldcw -4(%ebp) /* restore original control word */ + + leave + ret