diff --git a/reactos/lib/msvcrt/math/acos.c b/reactos/lib/msvcrt/math/acos.c new file mode 100644 index 00000000000..6619c30fece --- /dev/null +++ b/reactos/lib/msvcrt/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/msvcrt/math/asin.c b/reactos/lib/msvcrt/math/asin.c new file mode 100644 index 00000000000..eedd33829f8 --- /dev/null +++ b/reactos/lib/msvcrt/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/msvcrt/math/atan.c b/reactos/lib/msvcrt/math/atan.c new file mode 100644 index 00000000000..c7a472815b5 --- /dev/null +++ b/reactos/lib/msvcrt/math/atan.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. */ + +#include + +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/msvcrt/math/atan2.c b/reactos/lib/msvcrt/math/atan2.c new file mode 100644 index 00000000000..e9ec8557cb6 --- /dev/null +++ b/reactos/lib/msvcrt/math/atan2.c @@ -0,0 +1,15 @@ + +#include + +double atan2 (double __y, double __x); + +double atan2 (double __y, double __x) +{ + register double __value; + __asm __volatile__ + ("fpatan\n\t" + "fld %%st(0)" + : "=t" (__value) : "0" (__x), "u" (__y)); + + return __value; +} \ No newline at end of file diff --git a/reactos/lib/msvcrt/math/cabs.c b/reactos/lib/msvcrt/math/cabs.c new file mode 100644 index 00000000000..73d4643290f --- /dev/null +++ b/reactos/lib/msvcrt/math/cabs.c @@ -0,0 +1,11 @@ +#include + +double _cabs( struct _complex z ) +{ + return sqrt( z.x*z.x + z.y*z.y ); +// return hypot(z.x,z.y); +} + + + + diff --git a/reactos/lib/msvcrt/math/ceil.c b/reactos/lib/msvcrt/math/ceil.c new file mode 100644 index 00000000000..34a10193ff3 --- /dev/null +++ b/reactos/lib/msvcrt/math/ceil.c @@ -0,0 +1,15 @@ +#include + +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; +} diff --git a/reactos/lib/msvcrt/math/cos.c b/reactos/lib/msvcrt/math/cos.c new file mode 100644 index 00000000000..1753f59413d --- /dev/null +++ b/reactos/lib/msvcrt/math/cos.c @@ -0,0 +1,13 @@ +#include + +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/msvcrt/math/cosh.c b/reactos/lib/msvcrt/math/cosh.c new file mode 100644 index 00000000000..1f89a0ead5b --- /dev/null +++ b/reactos/lib/msvcrt/math/cosh.c @@ -0,0 +1,8 @@ +/* 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/msvcrt/math/exp.c b/reactos/lib/msvcrt/math/exp.c new file mode 100644 index 00000000000..fb074fbdb8d --- /dev/null +++ b/reactos/lib/msvcrt/math/exp.c @@ -0,0 +1,43 @@ +/* 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 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" + "fst %%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/msvcrt/math/fabs.c b/reactos/lib/msvcrt/math/fabs.c new file mode 100644 index 00000000000..fa0679ab612 --- /dev/null +++ b/reactos/lib/msvcrt/math/fabs.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. */ + +#include + +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/msvcrt/math/floor.c b/reactos/lib/msvcrt/math/floor.c new file mode 100644 index 00000000000..3e567818287 --- /dev/null +++ b/reactos/lib/msvcrt/math/floor.c @@ -0,0 +1,37 @@ +/* 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 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; +} diff --git a/reactos/lib/msvcrt/math/fmod.c b/reactos/lib/msvcrt/math/fmod.c new file mode 100644 index 00000000000..7c6cecd1886 --- /dev/null +++ b/reactos/lib/msvcrt/math/fmod.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. */ + +#include + +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/msvcrt/math/frexp.c b/reactos/lib/msvcrt/math/frexp.c new file mode 100644 index 00000000000..27de8a366e3 --- /dev/null +++ b/reactos/lib/msvcrt/math/frexp.c @@ -0,0 +1,19 @@ +#include +#include +#include + +double +frexp(double __x, int *exptr) +{ + double_t *x = (double_t *)&__x; + + if (exptr != NULL) + *exptr = x->exponent - 0x3FE; + + x->exponent = 0x3FE; + + return __x; +} + + + diff --git a/reactos/lib/msvcrt/math/ftol.c b/reactos/lib/msvcrt/math/ftol.c new file mode 100644 index 00000000000..dfa334624e6 --- /dev/null +++ b/reactos/lib/msvcrt/math/ftol.c @@ -0,0 +1,6 @@ +#include + +long _ftol(double fl) +{ + return (long)fl; +} diff --git a/reactos/lib/msvcrt/math/huge_val.c b/reactos/lib/msvcrt/math/huge_val.c new file mode 100644 index 00000000000..aaa50d0e81e --- /dev/null +++ b/reactos/lib/msvcrt/math/huge_val.c @@ -0,0 +1,6 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ + +#include + +#undef _HUGE +double_t _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 }; diff --git a/reactos/lib/msvcrt/math/hypot.c b/reactos/lib/msvcrt/math/hypot.c new file mode 100644 index 00000000000..9ca52e3ec1b --- /dev/null +++ b/reactos/lib/msvcrt/math/hypot.c @@ -0,0 +1,98 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * hypot() function for DJGPP. + * + * hypot() computes sqrt(x^2 + y^2). The problem with the obvious + * naive implementation is that it might fail for very large or + * very small arguments. For instance, for large x or y the result + * might overflow even if the value of the function should not, + * because squaring a large number might trigger an overflow. For + * very small numbers, their square might underflow and will be + * silently replaced by zero; this won't cause an exception, but might + * have an adverse effect on the accuracy of the result. + * + * This implementation tries to avoid the above pitfals, without + * inflicting too much of a performance hit. + * + */ + +#include +#include +#include + +/* Approximate square roots of DBL_MAX and DBL_MIN. Numbers + between these two shouldn't neither overflow nor underflow + when squared. */ +#define __SQRT_DBL_MAX 1.3e+154 +#define __SQRT_DBL_MIN 2.3e-162 + +double +_hypot(double x, double y) +{ + double abig = fabs(x), asmall = fabs(y); + double ratio; + + /* Make abig = max(|x|, |y|), asmall = min(|x|, |y|). */ + if (abig < asmall) + { + double temp = abig; + + abig = asmall; + asmall = temp; + } + + /* Trivial case. */ + if (asmall == 0.) + return abig; + + /* Scale the numbers as much as possible by using its ratio. + For example, if both ABIG and ASMALL are VERY small, then + X^2 + Y^2 might be VERY inaccurate due to loss of + significant digits. Dividing ASMALL by ABIG scales them + to a certain degree, so that accuracy is better. */ + + if ((ratio = asmall / abig) > __SQRT_DBL_MIN && abig < __SQRT_DBL_MAX) + return abig * sqrt(1.0 + ratio*ratio); + else + { + /* Slower but safer algorithm due to Moler and Morrison. Never + produces any intermediate result greater than roughly the + larger of X and Y. Should converge to machine-precision + accuracy in 3 iterations. */ + + double r = ratio*ratio, t, s, p = abig, q = asmall; + + do { + t = 4. + r; + if (t == 4.) + break; + s = r / t; + p += 2. * s * p; + q *= s; + r = (q / p) * (q / p); + } while (1); + + return p; + } +} + +#ifdef TEST + +#include + +int +main(void) +{ + printf("hypot(3, 4) =\t\t\t %25.17e\n", _hypot(3., 4.)); + printf("hypot(3*10^150, 4*10^150) =\t %25.17g\n", _hypot(3.e+150, 4.e+150)); + printf("hypot(3*10^306, 4*10^306) =\t %25.17g\n", _hypot(3.e+306, 4.e+306)); + printf("hypot(3*10^-320, 4*10^-320) =\t %25.17g\n",_hypot(3.e-320, 4.e-320)); + printf("hypot(0.7*DBL_MAX, 0.7*DBL_MAX) =%25.17g\n",_hypot(0.7*DBL_MAX, 0.7*DBL_MAX)); + printf("hypot(DBL_MAX, 1.0) =\t\t %25.17g\n", _hypot(DBL_MAX, 1.0)); + printf("hypot(1.0, DBL_MAX) =\t\t %25.17g\n", _hypot(1.0, DBL_MAX)); + printf("hypot(0.0, DBL_MAX) =\t\t %25.17g\n", _hypot(0.0, DBL_MAX)); + + return 0; +} + +#endif diff --git a/reactos/lib/msvcrt/math/j0_y0.c b/reactos/lib/msvcrt/math/j0_y0.c new file mode 100644 index 00000000000..5f63c53c3b5 --- /dev/null +++ b/reactos/lib/msvcrt/math/j0_y0.c @@ -0,0 +1,11 @@ +#include + +double _j0(double x) +{ + return x; +} + +double _y0(double x) +{ + return x; +} \ No newline at end of file diff --git a/reactos/lib/msvcrt/math/j1_y1.c b/reactos/lib/msvcrt/math/j1_y1.c new file mode 100644 index 00000000000..1f8bd093b33 --- /dev/null +++ b/reactos/lib/msvcrt/math/j1_y1.c @@ -0,0 +1,11 @@ +#include + +double _j1(double x) +{ + return x; +} + +double _y1(double x) +{ + return x; +} \ No newline at end of file diff --git a/reactos/lib/msvcrt/math/jn_yn.c b/reactos/lib/msvcrt/math/jn_yn.c new file mode 100644 index 00000000000..b3a718163d4 --- /dev/null +++ b/reactos/lib/msvcrt/math/jn_yn.c @@ -0,0 +1,11 @@ +#include + +double _jn(int n, double x) +{ + return x; +} + +double _yn(int n, double x) +{ + return x; +} \ No newline at end of file diff --git a/reactos/lib/msvcrt/math/ldexp.c b/reactos/lib/msvcrt/math/ldexp.c new file mode 100644 index 00000000000..22cda219ad6 --- /dev/null +++ b/reactos/lib/msvcrt/math/ldexp.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. */ + +#include + +double ldexp (double __x, int __y); + +double ldexp (double __x, int __y) +{ + 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/msvcrt/math/log.c b/reactos/lib/msvcrt/math/log.c new file mode 100644 index 00000000000..1788696bb05 --- /dev/null +++ b/reactos/lib/msvcrt/math/log.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. */ + +#include + +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/msvcrt/math/log10.c b/reactos/lib/msvcrt/math/log10.c new file mode 100644 index 00000000000..19258c29038 --- /dev/null +++ b/reactos/lib/msvcrt/math/log10.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. */ + +#include + +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/msvcrt/math/pow.c b/reactos/lib/msvcrt/math/pow.c index 232f0b6be8f..266fc039840 100644 --- a/reactos/lib/msvcrt/math/pow.c +++ b/reactos/lib/msvcrt/math/pow.c @@ -18,6 +18,8 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + double pow (double __x, double __y); double __log2 (double __x); @@ -78,9 +80,7 @@ double pow (double __x, double __y) return __value; } - long double powl (long double __x,long double __y) { return pow(__x,__y/2)*pow(__x,__y/2); } - diff --git a/reactos/lib/msvcrt/math/sin.c b/reactos/lib/msvcrt/math/sin.c new file mode 100644 index 00000000000..18ff3cf05b6 --- /dev/null +++ b/reactos/lib/msvcrt/math/sin.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. */ + +#include + +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/msvcrt/math/sinh.c b/reactos/lib/msvcrt/math/sinh.c new file mode 100644 index 00000000000..5a0b2be95a8 --- /dev/null +++ b/reactos/lib/msvcrt/math/sinh.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +double sinh(double x) +{ + if(x >= 0.0) + { + const double epos = exp(x); + return (epos - 1.0/epos) / 2.0; + } + else + { + const double eneg = exp(-x); + return (1.0/eneg - eneg) / 2.0; + } +} diff --git a/reactos/lib/msvcrt/math/sqrt.c b/reactos/lib/msvcrt/math/sqrt.c new file mode 100644 index 00000000000..d775407695f --- /dev/null +++ b/reactos/lib/msvcrt/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. */ +#include + +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/msvcrt/math/stubs.c b/reactos/lib/msvcrt/math/stubs.c new file mode 100644 index 00000000000..a367bc448e6 --- /dev/null +++ b/reactos/lib/msvcrt/math/stubs.c @@ -0,0 +1,84 @@ +#include + +double _CIsin (double x); +double _CIcos (double x); +double _CItan (double x); +double _CIsinh (double x); +double _CIcosh (double x); +double _CItanh (double x); +double _CIasin (double x); +double _CIacos (double x); +double _CIatan (double x); +double _CIatan2 (double y, double x); +double _CIexp (double x); +double _CIlog (double x); +double _CIlog10 (double x); +double _CIpow (double x, double y); +double _CIsqrt (double x); +double _CIfmod (double x, double y); + + +double _CIsin (double x) +{ + return sin(x); +} +double _CIcos (double x) +{ + return cos(x); +} +double _CItan (double x) +{ + return tan(x); +} +double _CIsinh (double x) +{ + return sinh(x); +} +double _CIcosh (double x) +{ + return cosh(x); +} +double _CItanh (double x) +{ + return tanh(x); +} +double _CIasin (double x) +{ + return asin(x); +} +double _CIacos (double x) +{ + return acos(x); +} +double _CIatan (double x) +{ + return atan(x); +} +double _CIatan2 (double y, double x) +{ + return atan2(y,x); +} +double _CIexp (double x) +{ + return exp(x); +} +double _CIlog (double x) +{ + return log(x); +} +double _CIlog10 (double x) +{ + return log10(x); +} +double _CIpow (double x, double y) +{ + return pow(x,y); +} +double _CIsqrt (double x) +{ + return sqrt(x); +} +double _CIfmod (double x, double y) +{ + return fmod(x,y); +} \ No newline at end of file diff --git a/reactos/lib/msvcrt/math/tan.c b/reactos/lib/msvcrt/math/tan.c new file mode 100644 index 00000000000..baa92c4f828 --- /dev/null +++ b/reactos/lib/msvcrt/math/tan.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. */ + +#include + +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; +} diff --git a/reactos/lib/msvcrt/math/tanh.c b/reactos/lib/msvcrt/math/tanh.c new file mode 100644 index 00000000000..da1eabb8ace --- /dev/null +++ b/reactos/lib/msvcrt/math/tanh.c @@ -0,0 +1,17 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ + +#include + +double tanh(double x) +{ + if (x > 50) + return 1; + else if (x < -50) + return -1; + else + { + const double ebig = exp(x); + const double esmall = 1.0/ebig; + return (ebig - esmall) / (ebig + esmall); + } +}