From 98071efc7e37535b96c57a8c06df001cb686cda4 Mon Sep 17 00:00:00 2001 From: Boudewijn Dekker Date: Fri, 12 Mar 1999 20:26:05 +0000 Subject: [PATCH] Changed .s files to .c files with gcc asm. svn path=/trunk/; revision=300 --- reactos/lib/crtdll/math/acos.S | 22 --------- reactos/lib/crtdll/math/acos.c | 26 ++++++++++ reactos/lib/crtdll/math/acosh.c | 8 --- reactos/lib/crtdll/math/asin.S | 14 ------ reactos/lib/crtdll/math/asin.c | 26 ++++++++++ reactos/lib/crtdll/math/asinh.c | 9 ---- reactos/lib/crtdll/math/atan.S | 8 --- reactos/lib/crtdll/math/atan.c | 32 ++++++++++++ reactos/lib/crtdll/math/atan2.S | 35 -------------- reactos/lib/crtdll/math/atan2.c | 12 +++++ reactos/lib/crtdll/math/atanh.c | 8 --- reactos/lib/crtdll/math/cabs.c | 10 ++++ reactos/lib/crtdll/math/ceil.S | 24 --------- reactos/lib/crtdll/math/ceil.c | 15 ++++++ reactos/lib/crtdll/math/cos.S | 16 ------ reactos/lib/crtdll/math/cos.c | 11 +++++ reactos/lib/crtdll/math/cosh.c | 8 --- reactos/lib/crtdll/math/exp.S | 32 ------------ reactos/lib/crtdll/math/exp.c | 42 ++++++++++++++++ reactos/lib/crtdll/math/fabs.S | 6 --- reactos/lib/crtdll/math/fabs.c | 32 ++++++++++++ reactos/lib/crtdll/math/floor.S | 24 --------- reactos/lib/crtdll/math/floor.c | 36 ++++++++++++++ reactos/lib/crtdll/math/fmod.S | 29 ----------- reactos/lib/crtdll/math/fmod.c | 35 ++++++++++++++ reactos/lib/crtdll/math/ftol.c | 2 +- reactos/lib/crtdll/math/ldexp.c | 57 +++++++++++----------- reactos/lib/crtdll/math/log.S | 7 --- reactos/lib/crtdll/math/log.c | 33 +++++++++++++ reactos/lib/crtdll/math/log10.S | 7 --- reactos/lib/crtdll/math/log10.c | 34 +++++++++++++ reactos/lib/crtdll/math/modf.S | 33 ------------- reactos/lib/crtdll/math/modf.c | 14 ++++++ reactos/lib/crtdll/math/modfl.S | 22 --------- reactos/lib/crtdll/math/pow.S | 86 --------------------------------- reactos/lib/crtdll/math/pow.c | 80 ++++++++++++++++++++++++++++++ reactos/lib/crtdll/math/pow10.S | 32 ------------ reactos/lib/crtdll/math/pow2.S | 30 ------------ reactos/lib/crtdll/math/sin.S | 16 ------ reactos/lib/crtdll/math/sin.c | 32 ++++++++++++ reactos/lib/crtdll/math/sqrt.S | 6 --- reactos/lib/crtdll/math/sqrt.c | 32 ++++++++++++ reactos/lib/crtdll/math/tan.S | 17 ------- reactos/lib/crtdll/math/tan.c | 33 +++++++++++++ 44 files changed, 564 insertions(+), 529 deletions(-) delete mode 100644 reactos/lib/crtdll/math/acos.S create mode 100644 reactos/lib/crtdll/math/acos.c delete mode 100644 reactos/lib/crtdll/math/acosh.c delete mode 100644 reactos/lib/crtdll/math/asin.S create mode 100644 reactos/lib/crtdll/math/asin.c delete mode 100644 reactos/lib/crtdll/math/asinh.c delete mode 100644 reactos/lib/crtdll/math/atan.S create mode 100644 reactos/lib/crtdll/math/atan.c delete mode 100644 reactos/lib/crtdll/math/atan2.S create mode 100644 reactos/lib/crtdll/math/atan2.c delete mode 100644 reactos/lib/crtdll/math/atanh.c create mode 100644 reactos/lib/crtdll/math/cabs.c delete mode 100644 reactos/lib/crtdll/math/ceil.S create mode 100644 reactos/lib/crtdll/math/ceil.c delete mode 100644 reactos/lib/crtdll/math/cos.S create mode 100644 reactos/lib/crtdll/math/cos.c delete mode 100644 reactos/lib/crtdll/math/cosh.c delete mode 100644 reactos/lib/crtdll/math/exp.S create mode 100644 reactos/lib/crtdll/math/exp.c delete mode 100644 reactos/lib/crtdll/math/fabs.S create mode 100644 reactos/lib/crtdll/math/fabs.c delete mode 100644 reactos/lib/crtdll/math/floor.S create mode 100644 reactos/lib/crtdll/math/floor.c delete mode 100644 reactos/lib/crtdll/math/fmod.S create mode 100644 reactos/lib/crtdll/math/fmod.c delete mode 100644 reactos/lib/crtdll/math/log.S create mode 100644 reactos/lib/crtdll/math/log.c delete mode 100644 reactos/lib/crtdll/math/log10.S create mode 100644 reactos/lib/crtdll/math/log10.c delete mode 100644 reactos/lib/crtdll/math/modf.S create mode 100644 reactos/lib/crtdll/math/modf.c delete mode 100644 reactos/lib/crtdll/math/modfl.S delete mode 100644 reactos/lib/crtdll/math/pow.S create mode 100644 reactos/lib/crtdll/math/pow.c delete mode 100644 reactos/lib/crtdll/math/pow10.S delete mode 100644 reactos/lib/crtdll/math/pow2.S delete mode 100644 reactos/lib/crtdll/math/sin.S create mode 100644 reactos/lib/crtdll/math/sin.c delete mode 100644 reactos/lib/crtdll/math/sqrt.S create mode 100644 reactos/lib/crtdll/math/sqrt.c delete mode 100644 reactos/lib/crtdll/math/tan.S create mode 100644 reactos/lib/crtdll/math/tan.c diff --git a/reactos/lib/crtdll/math/acos.S b/reactos/lib/crtdll/math/acos.S deleted file mode 100644 index 67624bc76ea..00000000000 --- a/reactos/lib/crtdll/math/acos.S +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - .text -LC0: - .double 0d1.00000000000000000000e+00 - - .globl _acos -_acos: - fldl 4(%esp) - fld1 - fsubp %st(0),%st(1) - fsqrt - - fldl 4(%esp) - fld1 - faddp %st(0),%st(1) - fsqrt - - fpatan - - fld %st(0) - faddp - ret diff --git a/reactos/lib/crtdll/math/acos.c b/reactos/lib/crtdll/math/acos.c new file mode 100644 index 00000000000..5c3a0d18707 --- /dev/null +++ b/reactos/lib/crtdll/math/acos.c @@ -0,0 +1,26 @@ +/* Math functions for i387. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +double acos (double __x) +{ + return atan2 (sqrt (1.0 - __x * __x), __x); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/math/acosh.c b/reactos/lib/crtdll/math/acosh.c deleted file mode 100644 index 6e13bbe6ec6..00000000000 --- a/reactos/lib/crtdll/math/acosh.c +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -double -acosh(double x) -{ - return log(x + sqrt(x*x - 1)); -} diff --git a/reactos/lib/crtdll/math/asin.S b/reactos/lib/crtdll/math/asin.S deleted file mode 100644 index ee04df6de05..00000000000 --- a/reactos/lib/crtdll/math/asin.S +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - .globl _asin -_asin: - fldl 4(%esp) - fld %st(0) - fmulp - fld1 - fsubp - fsqrt - fldl 4(%esp) - fxch %st(1) - fpatan - ret - diff --git a/reactos/lib/crtdll/math/asin.c b/reactos/lib/crtdll/math/asin.c new file mode 100644 index 00000000000..aef4b42ee99 --- /dev/null +++ b/reactos/lib/crtdll/math/asin.c @@ -0,0 +1,26 @@ +/* Math functions for i387. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +double asin (double __x) +{ + return atan2 (__x, sqrt (1.0 - __x * __x)); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/math/asinh.c b/reactos/lib/crtdll/math/asinh.c deleted file mode 100644 index e27e20da7ed..00000000000 --- a/reactos/lib/crtdll/math/asinh.c +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -double -asinh(double x) -{ - return x>0 ? log(x + sqrt(x*x + 1)) : -log(sqrt(x*x+1)-x); -} - diff --git a/reactos/lib/crtdll/math/atan.S b/reactos/lib/crtdll/math/atan.S deleted file mode 100644 index 7858c76f695..00000000000 --- a/reactos/lib/crtdll/math/atan.S +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - .globl _atan -_atan: - fldl 4(%esp) - fld1 - fpatan - ret - diff --git a/reactos/lib/crtdll/math/atan.c b/reactos/lib/crtdll/math/atan.c new file mode 100644 index 00000000000..20ef6724d7c --- /dev/null +++ b/reactos/lib/crtdll/math/atan.c @@ -0,0 +1,32 @@ +/* Math functions for i387. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +double atan (double __x); + +double atan (double __x) +{ + register double __value; + __asm __volatile__ + ("fld1\n\t" + "fpatan" + : "=t" (__value) : "0" (__x)); + + return __value; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/math/atan2.S b/reactos/lib/crtdll/math/atan2.S deleted file mode 100644 index 40e6332b30d..00000000000 --- a/reactos/lib/crtdll/math/atan2.S +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -.data - .align 2 -nan: - .long 0xffffffff - .byte 0xff - .byte 0xff - .byte 0xff - .byte 0x7f - -.text - .globl _atan2 -_atan2: - fldl 4(%esp) - fldl 12(%esp) - ftst - fnstsw %ax - sahf - jne doit - fxch %st(1) - ftst - fnstsw %ax - sahf - je isanan - fxch %st(1) -doit: - fpatan - ret -isanan: - movl $1,_errno - fstp %st(0) - fstp %st(0) - fldl nan - ret - diff --git a/reactos/lib/crtdll/math/atan2.c b/reactos/lib/crtdll/math/atan2.c new file mode 100644 index 00000000000..a07ccd24307 --- /dev/null +++ b/reactos/lib/crtdll/math/atan2.c @@ -0,0 +1,12 @@ +double atan2 (double __y, double __x); + +double atan2 (double __y, double __x) +{ + register double __value; + __asm __volatile__ + ("fpatan\n\t" + "fldl %%st(0)" + : "=t" (__value) : "0" (__x), "u" (__y)); + + return __value; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/math/atanh.c b/reactos/lib/crtdll/math/atanh.c deleted file mode 100644 index 8335dc78b3a..00000000000 --- a/reactos/lib/crtdll/math/atanh.c +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -double -atanh(double x) -{ - return log((1+x)/(1-x)) / 2.0; -} diff --git a/reactos/lib/crtdll/math/cabs.c b/reactos/lib/crtdll/math/cabs.c new file mode 100644 index 00000000000..efee29385a5 --- /dev/null +++ b/reactos/lib/crtdll/math/cabs.c @@ -0,0 +1,10 @@ +#include + +double _cabs( struct _complex z ) +{ + return hypot(z.x,z.y); +} + + + + diff --git a/reactos/lib/crtdll/math/ceil.S b/reactos/lib/crtdll/math/ceil.S deleted file mode 100644 index baa0923bd25..00000000000 --- a/reactos/lib/crtdll/math/ceil.S +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - .globl _ceil -_ceil: - pushl %ebp - movl %esp,%ebp - subl $8,%esp /* -4 = old CW, -2 = new CW */ - - fstcw -4(%ebp) - fwait - movw -4(%ebp),%ax - andw $0xf3ff,%ax - orw $0x0800,%ax - movw %ax,-2(%ebp) - fldcww -2(%ebp) - - fldl 8(%ebp) - frndint - - fldcww -4(%ebp) - - movl %ebp,%esp - popl %ebp - ret - diff --git a/reactos/lib/crtdll/math/ceil.c b/reactos/lib/crtdll/math/ceil.c new file mode 100644 index 00000000000..eb750a860f5 --- /dev/null +++ b/reactos/lib/crtdll/math/ceil.c @@ -0,0 +1,15 @@ +double ceil (double __x); + +double ceil (double __x) +{ + register double __value; + __volatile unsigned short int __cw, __cwtmp; + + __asm __volatile ("fnstcw %0" : "=m" (__cw)); + __cwtmp = (__cw & 0xf3ff) | 0x0800; /* rounding up */ + __asm __volatile ("fldcw %0" : : "m" (__cwtmp)); + __asm __volatile ("frndint" : "=t" (__value) : "0" (__x)); + __asm __volatile ("fldcw %0" : : "m" (__cw)); + + return __value; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/math/cos.S b/reactos/lib/crtdll/math/cos.S deleted file mode 100644 index 97b7418eace..00000000000 --- a/reactos/lib/crtdll/math/cos.S +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -L0: - .quad 0xffffffffffffffff - - .globl _cos -_cos: - fldl 4(%esp) - fcos - fstsw - sahf - jnp L1 - fstp %st(0) - fldl L0 -L1: - ret - diff --git a/reactos/lib/crtdll/math/cos.c b/reactos/lib/crtdll/math/cos.c new file mode 100644 index 00000000000..07edd8b0a3e --- /dev/null +++ b/reactos/lib/crtdll/math/cos.c @@ -0,0 +1,11 @@ +double cos (double __x); + +double cos (double __x) +{ + register double __value; + __asm __volatile__ + ("fcos" + : "=t" (__value): "0" (__x)); + + return __value; +} diff --git a/reactos/lib/crtdll/math/cosh.c b/reactos/lib/crtdll/math/cosh.c deleted file mode 100644 index c2cca978ace..00000000000 --- a/reactos/lib/crtdll/math/cosh.c +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -#include - -double cosh(double x) -{ - const double ebig = exp(fabs(x)); - return (ebig + 1.0/ebig) / 2.0; -} diff --git a/reactos/lib/crtdll/math/exp.S b/reactos/lib/crtdll/math/exp.S deleted file mode 100644 index d02cde075d8..00000000000 --- a/reactos/lib/crtdll/math/exp.S +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - .data -LCW1: - .word 0 -LCW2: - .word 0 -LC0: - .double 0d1.0e+00 - - .text - - .globl _exp -_exp: - fldl 4(%esp) - fldl2e - fmulp - fstcww LCW1 - fstcww LCW2 - fwait - andw $0xf3ff,LCW2 - orw $0x0400,LCW2 - fldcww LCW2 - fldl %st(0) - frndint - fldcww LCW1 - fxch %st(1) - fsub %st(1),%st - f2xm1 - faddl LC0 - fscale - fstp %st(1) - ret diff --git a/reactos/lib/crtdll/math/exp.c b/reactos/lib/crtdll/math/exp.c new file mode 100644 index 00000000000..43a142f9362 --- /dev/null +++ b/reactos/lib/crtdll/math/exp.c @@ -0,0 +1,42 @@ +/* Math functions for i387. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + + +double exp (double __x); + +double exp (double __x) +{ + register double __value, __exponent; + __asm __volatile__ + ("fldl2e # e^x = 2^(x * log2(e))\n\t" + "fmul %%st(1) # x * log2(e)\n\t" + "fstl %%st(1)\n\t" + "frndint # int(x * log2(e))\n\t" + "fxch\n\t" + "fsub %%st(1) # fract(x * log2(e))\n\t" + "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" + : "=t" (__value), "=u" (__exponent) : "0" (__x)); + __value += 1.0; + __asm __volatile__ + ("fscale" + : "=t" (__value) : "0" (__value), "u" (__exponent)); + + return __value; +} diff --git a/reactos/lib/crtdll/math/fabs.S b/reactos/lib/crtdll/math/fabs.S deleted file mode 100644 index 0189dbaf61c..00000000000 --- a/reactos/lib/crtdll/math/fabs.S +++ /dev/null @@ -1,6 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - .globl _fabs -_fabs: - fldl 4(%esp) - fabs - ret diff --git a/reactos/lib/crtdll/math/fabs.c b/reactos/lib/crtdll/math/fabs.c new file mode 100644 index 00000000000..f56c2682528 --- /dev/null +++ b/reactos/lib/crtdll/math/fabs.c @@ -0,0 +1,32 @@ +/* Math functions for i387. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + + +double fabs (double __x); + +double fabs (double __x) +{ + register double __value; + __asm __volatile__ + ("fabs" + : "=t" (__value) : "0" (__x)); + + return __value; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/math/floor.S b/reactos/lib/crtdll/math/floor.S deleted file mode 100644 index beaf00d7d63..00000000000 --- a/reactos/lib/crtdll/math/floor.S +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - .globl _floor -_floor: - pushl %ebp - movl %esp,%ebp - subl $8,%esp /* -4 = old CW, -2 = new CW */ - - fstcw -4(%ebp) - fwait - movw -4(%ebp),%ax - andw $0xf3ff,%ax - orw $0x0400,%ax - movw %ax,-2(%ebp) - fldcww -2(%ebp) - - fldl 8(%ebp) - frndint - - fldcww -4(%ebp) - - movl %ebp,%esp - popl %ebp - ret - diff --git a/reactos/lib/crtdll/math/floor.c b/reactos/lib/crtdll/math/floor.c new file mode 100644 index 00000000000..3c316805a80 --- /dev/null +++ b/reactos/lib/crtdll/math/floor.c @@ -0,0 +1,36 @@ +/* Math functions for i387. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + + +double floor (double __x); + +double floor (double __x) +{ + register double __value; + __volatile unsigned short int __cw, __cwtmp; + + __asm __volatile ("fnstcw %0" : "=m" (__cw)); + __cwtmp = (__cw & 0xf3ff) | 0x0400; /* rounding down */ + __asm __volatile ("fldcw %0" : : "m" (__cwtmp)); + __asm __volatile ("frndint" : "=t" (__value) : "0" (__x)); + __asm __volatile ("fldcw %0" : : "m" (__cw)); + + return __value; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/math/fmod.S b/reactos/lib/crtdll/math/fmod.S deleted file mode 100644 index 82eb419ecfb..00000000000 --- a/reactos/lib/crtdll/math/fmod.S +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - .data -LCW1: - .word 0 - .align 4 - - .text - - .globl _fmod -_fmod: - fldl 4(%esp) - fldl 12(%esp) - ftst - fnstsw %ax - fxch %st(1) - sahf - jnz next - fstpl %st(0) - jmp out -next: - fpreml - fnstsw %ax - sahf - jpe next - fstpl %st(1) -out: - ret - - diff --git a/reactos/lib/crtdll/math/fmod.c b/reactos/lib/crtdll/math/fmod.c new file mode 100644 index 00000000000..8e178d9ef77 --- /dev/null +++ b/reactos/lib/crtdll/math/fmod.c @@ -0,0 +1,35 @@ +/* Math functions for i387. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + + +double fmod (double __x, double __y); + +double fmod (double __x, double __y) +{ + register double __value; + __asm __volatile__ + ("1: fprem\n\t" + "fstsw %%ax\n\t" + "sahf\n\t" + "jp 1b" + : "=t" (__value) : "0" (__x), "u" (__y) : "ax", "cc"); + + return __value; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/math/ftol.c b/reactos/lib/crtdll/math/ftol.c index d0f8a50015f..1c58bb630e2 100644 --- a/reactos/lib/crtdll/math/ftol.c +++ b/reactos/lib/crtdll/math/ftol.c @@ -1,3 +1,3 @@ long __cdecl ftol(double fl) { return (long)fl; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/math/ldexp.c b/reactos/lib/crtdll/math/ldexp.c index 818cab7578a..f96c3c35aa4 100644 --- a/reactos/lib/crtdll/math/ldexp.c +++ b/reactos/lib/crtdll/math/ldexp.c @@ -1,32 +1,31 @@ -/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include +/* Math functions for i387. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. -double -ldexp(double v, int e) + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +double ldexp (double __x, int __y); + +double ldexp (double __x, int __y) { - double two = 2.0; - - if (e < 0) - { - e = -e; /* This just might overflow on two-complement machines. */ - if (e < 0) return 0.0; - while (e > 0) - { - if (e & 1) v /= two; - two *= two; - e >>= 1; - } - } - else if (e > 0) - { - while (e > 0) - { - if (e & 1) v *= two; - two *= two; - e >>= 1; - } - } - return v; -} + register double __value; + __asm __volatile__ + ("fscale" + : "=t" (__value) : "0" (__x), "u" ((double) __y)); + return __value; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/math/log.S b/reactos/lib/crtdll/math/log.S deleted file mode 100644 index b45a9778635..00000000000 --- a/reactos/lib/crtdll/math/log.S +++ /dev/null @@ -1,7 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - .globl _log -_log: - fldln2 - fldl 4(%esp) - fyl2x - ret diff --git a/reactos/lib/crtdll/math/log.c b/reactos/lib/crtdll/math/log.c new file mode 100644 index 00000000000..b8cf142f50c --- /dev/null +++ b/reactos/lib/crtdll/math/log.c @@ -0,0 +1,33 @@ +/* Math functions for i387. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +double log (double __x); + +double log (double __x) +{ + register double __value; + __asm __volatile__ + ("fldln2\n\t" + "fxch\n\t" + "fyl2x" + : "=t" (__value) : "0" (__x)); + + return __value; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/math/log10.S b/reactos/lib/crtdll/math/log10.S deleted file mode 100644 index 91b50ee5f50..00000000000 --- a/reactos/lib/crtdll/math/log10.S +++ /dev/null @@ -1,7 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - .globl _log10 -_log10: - fldlg2 - fldl 4(%esp) - fyl2x - ret diff --git a/reactos/lib/crtdll/math/log10.c b/reactos/lib/crtdll/math/log10.c new file mode 100644 index 00000000000..64a6b1708e4 --- /dev/null +++ b/reactos/lib/crtdll/math/log10.c @@ -0,0 +1,34 @@ +/* Math functions for i387. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + + +double log10 (double __x); + +double log10 (double __x) +{ + register double __value; + __asm __volatile__ + ("fldlg2\n\t" + "fxch\n\t" + "fyl2x" + : "=t" (__value) : "0" (__x)); + + return __value; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/math/modf.S b/reactos/lib/crtdll/math/modf.S deleted file mode 100644 index db78db48edb..00000000000 --- a/reactos/lib/crtdll/math/modf.S +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - .text - .globl _modf -_modf: - pushl %ebp - movl %esp,%ebp - subl $16,%esp - pushl %ebx - fnstcw -4(%ebp) - fwait - movw -4(%ebp),%ax - orw $0x0c3f,%ax - movw %ax,-8(%ebp) - fldcw -8(%ebp) - fwait - fldl 8(%ebp) - frndint - fstpl -16(%ebp) - fwait - movl -16(%ebp),%edx - movl -12(%ebp),%ecx - movl 16(%ebp),%ebx - movl %edx,(%ebx) - movl %ecx,4(%ebx) - fldl 8(%ebp) - fsubl -16(%ebp) - leal -20(%ebp),%esp - fclex - fldcw -4(%ebp) - fwait - popl %ebx - leave - ret diff --git a/reactos/lib/crtdll/math/modf.c b/reactos/lib/crtdll/math/modf.c new file mode 100644 index 00000000000..40da2157f10 --- /dev/null +++ b/reactos/lib/crtdll/math/modf.c @@ -0,0 +1,14 @@ +// from linux libc + +#include + +/* Slooow version. */ + +double modf(double x,double *pint) +{ + if (x >= 0) + *pint = floor(x); + else + *pint = ceil(x); + return x - *pint; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/math/modfl.S b/reactos/lib/crtdll/math/modfl.S deleted file mode 100644 index 2257fee3e68..00000000000 --- a/reactos/lib/crtdll/math/modfl.S +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - .text - .globl ___modfl -___modfl: - pushl %ebp - movl %esp,%ebp - subl $4,%esp - fldt 8(%ebp) - movl 20(%ebp),%eax - fnstcw -2(%ebp) - movw -2(%ebp),%dx - orb $0x0c,%dh - movw %dx,-4(%ebp) - fldcw -4(%ebp) - fld %st(0) - frndint - fldcw -2(%ebp) - fld %st(0) - fstpt (%eax) - fsubrp %st,%st(1) - leave - ret diff --git a/reactos/lib/crtdll/math/pow.S b/reactos/lib/crtdll/math/pow.S deleted file mode 100644 index 7a0da7c1539..00000000000 --- a/reactos/lib/crtdll/math/pow.S +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - .data -yint: - .word 0,0 -LCW1: - .word 0 -LCW2: - .word 0 - - .text -LC0: - .double 0d1.0e+00 - -frac: - fstcww LCW1 - fstcww LCW2 - fwait - andw $0xf3ff,LCW2 - orw $0x0400,LCW2 - fldcww LCW2 - fldl %st(0) - frndint - fldcww LCW1 - fxch %st(1) - fsub %st(1),%st - ret - -Lpow2: - call frac - f2xm1 - faddl LC0 - fscale - fstp %st(1) - ret - - .globl _pow -_pow: - fldl 12(%esp) - fldl 4(%esp) - ftst - fnstsww %ax - sahf - jbe xltez - fyl2x - jmp Lpow2 -xltez: - jb xltz - fstp %st(0) - ftst - fnstsww %ax - sahf - ja ygtz - jb error - fstp %st(0) - fld1l - fchs -error: - fsqrt - ret -ygtz: - fstp %st(0) - fldzl - ret -xltz: - fabs - fxch %st(1) - call frac - ftst - fnstsww %ax - fstp %st(0) - sahf - je yisint - fstp %st(0) - fchs - jmp error -yisint: - fistl yint - fxch %st(1) - fyl2x - call Lpow2 - andl $1,yint - jz yeven - fchs -yeven: - ret - diff --git a/reactos/lib/crtdll/math/pow.c b/reactos/lib/crtdll/math/pow.c new file mode 100644 index 00000000000..adc709c1062 --- /dev/null +++ b/reactos/lib/crtdll/math/pow.c @@ -0,0 +1,80 @@ +/* Math functions for i387. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +double pow (double __x, double __y); + +double __log2 (double __x); + +double __log2 (double __x) +{ + register double __value; + __asm __volatile__ + ("fld1\n\t" + "fxch\n\t" + "fyl2x" + : "=t" (__value) : "0" (__x)); + + return __value; +} + +double pow (double __x, double __y) +{ + register double __value, __exponent; + long __p = (long) __y; + + if (__x == 0.0 && __y > 0.0) + return 0.0; + if (__y == (double) __p) + { + double __r = 1.0; + if (__p == 0) + return 1.0; + if (__p < 0) + { + __p = -__p; + __x = 1.0 / __x; + } + while (1) + { + if (__p & 1) + __r *= __x; + __p >>= 1; + if (__p == 0) + return __r; + __x *= __x; + } + /* NOTREACHED */ + } + __asm __volatile__ + ("fmul %%st(1) # y * log2(x)\n\t" + "fstl %%st(1)\n\t" + "frndint # int(y * log2(x))\n\t" + "fxch\n\t" + "fsub %%st(1) # fract(y * log2(x))\n\t" + "f2xm1 # 2^(fract(y * log2(x))) - 1\n\t" + : "=t" (__value), "=u" (__exponent) : "0" (__log2 (__x)), "1" (__y)); + __value += 1.0; + __asm __volatile__ + ("fscale" + : "=t" (__value) : "0" (__value), "u" (__exponent)); + + return __value; +} + diff --git a/reactos/lib/crtdll/math/pow10.S b/reactos/lib/crtdll/math/pow10.S deleted file mode 100644 index 3a2236d9fb7..00000000000 --- a/reactos/lib/crtdll/math/pow10.S +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - .data -LCW1: - .word 0 -LCW2: - .word 0 -LC0: - .double 0d1.0e+00 - - .text - - .globl ___pow10 -___pow10: - fldl 4(%esp) - fldl2t - fmulp - fstcww LCW1 - fstcww LCW2 - fwait - andw $0xf3ff,LCW2 - orw $0x0400,LCW2 - fldcww LCW2 - fldl %st(0) - frndint - fldcww LCW1 - fxch %st(1) - fsub %st(1),%st - f2xm1 - faddl LC0 - fscale - fstp %st(1) - ret diff --git a/reactos/lib/crtdll/math/pow2.S b/reactos/lib/crtdll/math/pow2.S deleted file mode 100644 index 1a747a86636..00000000000 --- a/reactos/lib/crtdll/math/pow2.S +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ - .data -LCW1: - .word 0 -LCW2: - .word 0 -LC0: - .double 0d1.0e+00 - - .text - - .globl ___pow2 -___pow2: - fldl 4(%esp) - fstcww LCW1 - fstcww LCW2 - fwait - andw $0xf3ff,LCW2 - orw $0x0400,LCW2 - fldcww LCW2 - fldl %st(0) - frndint - fldcww LCW1 - fxch %st(1) - fsub %st(1),%st - f2xm1 - faddl LC0 - fscale - fstp %st(1) - ret diff --git a/reactos/lib/crtdll/math/sin.S b/reactos/lib/crtdll/math/sin.S deleted file mode 100644 index 862f9add557..00000000000 --- a/reactos/lib/crtdll/math/sin.S +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -L0: - .quad 0xffffffffffffffff - - .globl _sin -_sin: - fldl 4(%esp) - fsin - fstsw - sahf - jnp L1 - fstp %st(0) - fldl L0 -L1: - ret - diff --git a/reactos/lib/crtdll/math/sin.c b/reactos/lib/crtdll/math/sin.c new file mode 100644 index 00000000000..be9e0b34fa4 --- /dev/null +++ b/reactos/lib/crtdll/math/sin.c @@ -0,0 +1,32 @@ +/* Math functions for i387. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + + +double sin (double __x); + +double sin (double __x) +{ + register double __value; + __asm __volatile__ + ("fsin" + : "=t" (__value) : "0" (__x)); + + return __value; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/math/sqrt.S b/reactos/lib/crtdll/math/sqrt.S deleted file mode 100644 index ff8066df796..00000000000 --- a/reactos/lib/crtdll/math/sqrt.S +++ /dev/null @@ -1,6 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ - .globl _sqrt -_sqrt: - fldl 4(%esp) - fsqrt - ret diff --git a/reactos/lib/crtdll/math/sqrt.c b/reactos/lib/crtdll/math/sqrt.c new file mode 100644 index 00000000000..f157eab5723 --- /dev/null +++ b/reactos/lib/crtdll/math/sqrt.c @@ -0,0 +1,32 @@ +/* Math functions for i387. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + + +double sqrt (double __x); + +double sqrt (double __x) +{ + register double __value; + __asm __volatile__ + ("fsqrt" + : "=t" (__value) : "0" (__x)); + + return __value; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/math/tan.S b/reactos/lib/crtdll/math/tan.S deleted file mode 100644 index 8b629d09a6e..00000000000 --- a/reactos/lib/crtdll/math/tan.S +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -L0: - .quad 0xffffffffffffffff - - .globl _tan -_tan: - fldl 4(%esp) - fptan - fstsw - fstp %st(0) - sahf - jnp L1 -/* fstp %st(0) - if exception, there is nothing on the stack */ - fldl L0 -L1: - ret - diff --git a/reactos/lib/crtdll/math/tan.c b/reactos/lib/crtdll/math/tan.c new file mode 100644 index 00000000000..2a460a9032a --- /dev/null +++ b/reactos/lib/crtdll/math/tan.c @@ -0,0 +1,33 @@ +/* Math functions for i387. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + + +double tan (double __x); + +double tan (double __x) +{ + register double __value; + register double __value2 __attribute__ ((unused)); + __asm __volatile__ + ("fptan" + : "=t" (__value2), "=u" (__value) : "0" (__x)); + + return __value; +}