diff --git a/reactos/subsys/win32k/float/chgsign.c b/reactos/subsys/win32k/float/chgsign.c new file mode 100644 index 00000000000..589cc40bfbe --- /dev/null +++ b/reactos/subsys/win32k/float/chgsign.c @@ -0,0 +1,13 @@ +#include +#include + +double _chgsign( double __x ) +{ + double_t *x = (double_t *)&x; + if ( x->sign == 1 ) + x->sign = 0; + else + x->sign = 1; + + return __x; +} diff --git a/reactos/subsys/win32k/float/clearfp.c b/reactos/subsys/win32k/float/clearfp.c new file mode 100644 index 00000000000..e824752e4c6 --- /dev/null +++ b/reactos/subsys/win32k/float/clearfp.c @@ -0,0 +1,13 @@ +#include + +unsigned int _clearfp (void) +{ + +unsigned short __res = _statusfp(); + +__asm__ __volatile__ ( + "fclex \n\t" + ); + return __res; +} + diff --git a/reactos/subsys/win32k/float/cntrlfp.c b/reactos/subsys/win32k/float/cntrlfp.c new file mode 100644 index 00000000000..2ebdb0ad212 --- /dev/null +++ b/reactos/subsys/win32k/float/cntrlfp.c @@ -0,0 +1,38 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +#include + +unsigned int _controlfp (unsigned int unNew, unsigned int unMask) +{ + return _control87(unNew,unMask); +} + +unsigned int _control87 (unsigned int unNew, unsigned int unMask) +{ + +register unsigned int __res; +__asm__ __volatile__ ( + "pushl %%eax \n\t" /* make room on stack */ + "fstcw (%%esp) \n\t" + "fwait \n\t" + "popl %%eax \n\t" + "andl $0xffff, %%eax \n\t" /* OK; we have the old value ready */ + + "movl %1, %%ecx \n\t" + "notl %%ecx \n\t" + "andl %%eax, %%ecx \n\t" /* the bits we want to keep */ + + "movl %2, %%edx \n\t" + "andl %1, %%edx \n\t" /* the bits we want to change */ + + "orl %%ecx, %%edx\n\t" /* the new value */ + "pushl %%edx \n\t" + "fldcw (%%esp) \n\t" + "popl %%edx \n\t" + + + :"=r" (__res):"r" (unNew),"r" (unMask): "ax", "dx", "cx"); +/* :"=a" (__res):"c" (unNew),"d" (unMask):"ax", "dx", "cx"); */ + + return __res; +} diff --git a/reactos/subsys/win32k/float/copysign.c b/reactos/subsys/win32k/float/copysign.c new file mode 100644 index 00000000000..4d02b38601f --- /dev/null +++ b/reactos/subsys/win32k/float/copysign.c @@ -0,0 +1,13 @@ +#include +#include + +double _copysign (double __d, double __s) +{ + double_t *d = (double_t *)&__d; + double_t *s = (double_t *)&__s; + + d->sign = s->sign; + + return __d; +} + \ No newline at end of file diff --git a/reactos/subsys/win32k/float/fpclass.c b/reactos/subsys/win32k/float/fpclass.c new file mode 100644 index 00000000000..06c404f5ead --- /dev/null +++ b/reactos/subsys/win32k/float/fpclass.c @@ -0,0 +1,65 @@ +#include +#include +#include + +#define _FPCLASS_SNAN 0x0001 /* signaling NaN */ +#define _FPCLASS_QNAN 0x0002 /* quiet NaN */ +#define _FPCLASS_NINF 0x0004 /* negative infinity */ +#define _FPCLASS_NN 0x0008 /* negative normal */ +#define _FPCLASS_ND 0x0010 /* negative denormal */ +#define _FPCLASS_NZ 0x0020 /* -0 */ +#define _FPCLASS_PZ 0x0040 /* +0 */ +#define _FPCLASS_PD 0x0080 /* positive denormal */ +#define _FPCLASS_PN 0x0100 /* positive normal */ +#define _FPCLASS_PINF 0x0200 /* positive infinity */ + +#define FP_SNAN 0x0001 // signaling NaN +#define FP_QNAN 0x0002 // quiet NaN +#define FP_NINF 0x0004 // negative infinity +#define FP_PINF 0x0200 // positive infinity +#define FP_NDENORM 0x0008 // negative denormalized non-zero +#define FP_PDENORM 0x0010 // positive denormalized non-zero +#define FP_NZERO 0x0020 // negative zero +#define FP_PZERO 0x0040 // positive zero +#define FP_NNORM 0x0080 // negative normalized non-zero +#define FP_PNORM 0x0100 // positive normalized non-zero + +typedef int fpclass_t; + +fpclass_t _fpclass(double __d) +{ + double_t *d = (double_t *)&__d; + + if ( d->exponent == 0 ) { + if ( d->mantissah == 0 && d->mantissal == 0 ) { + if ( d->sign ==0 ) + return FP_NZERO; + else + return FP_PZERO; + } else { + if ( d->sign ==0 ) + return FP_NDENORM; + else + return FP_PDENORM; + } + } + if (d->exponent == 0x7ff ) { + if ( d->mantissah == 0 && d->mantissal == 0 ) { + if ( d->sign ==0 ) + return FP_NINF; + else + return FP_PINF; + } + else if ( d->mantissah == 0 && d->mantissal != 0 ) { + return FP_QNAN; + } + else if ( d->mantissah == 0 && d->mantissal != 0 ) { + return FP_SNAN; + } + + } + + return 0; +} + + diff --git a/reactos/subsys/win32k/float/fpreset.c b/reactos/subsys/win32k/float/fpreset.c new file mode 100644 index 00000000000..6e8dd3d24ca --- /dev/null +++ b/reactos/subsys/win32k/float/fpreset.c @@ -0,0 +1,8 @@ +#include + +void _fpreset (void) +{ + /* FIXME: This causes an exception */ +// __asm__ __volatile__("fninit\n\t"); + return; +} diff --git a/reactos/subsys/win32k/float/isnan.c b/reactos/subsys/win32k/float/isnan.c new file mode 100644 index 00000000000..d6f4ac04e1a --- /dev/null +++ b/reactos/subsys/win32k/float/isnan.c @@ -0,0 +1,77 @@ +/* Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +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., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include + +int _isnan(double __x) +{ + double_t * x = (double_t *)&__x; + return ( x->exponent == 0x7ff && ( x->mantissah != 0 || x->mantissal != 0 )); +} + +int _isnanl(long double __x) +{ + + /* Intel's extended format has the normally implicit 1 explicit + present. Sigh! */ + + long_double_t * x = (long_double_t *)&__x; + + + /* IEEE 854 NaN's have the maximum possible + exponent and a nonzero mantissa. */ + + return (( x->exponent == 0x7fff) + && ( (x->mantissah & 0x80000000) != 0) + && ( (x->mantissah & (unsigned int)0x7fffffff) != 0 || x->mantissal != 0 )); +} + + +int _isinf(double __x) +{ + double_t * x = (double_t *)&__x; + return ( x->exponent == 0x7ff && ( x->mantissah == 0 && x->mantissal == 0 )); +} + + + +int _finite( double x ) +{ + return !_isinf(x); +} + +int _isinfl(long double __x) +{ + /* Intel's extended format has the normally implicit 1 explicit + present. Sigh! */ + + long_double_t * x = (long_double_t *)&__x; + + + /* An IEEE 854 infinity has an exponent with the + maximum possible value and a zero mantissa. */ + + + if ( x->exponent == 0x7fff && ( (x->mantissah == 0x80000000 ) && x->mantissal == 0 )) + return x->sign ? -1 : 1; + return 0; +} + + diff --git a/reactos/subsys/win32k/float/logb.c b/reactos/subsys/win32k/float/logb.c new file mode 100644 index 00000000000..db8eff6381a --- /dev/null +++ b/reactos/subsys/win32k/float/logb.c @@ -0,0 +1,31 @@ +/* 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 _logb (double __x); + +double _logb (double __x) +{ + register double __value, __junk; + __asm __volatile__ + ("fxtract\n\t" + : "=t" (__junk), "=u" (__value) : "0" (__x)); + + return __value; +} \ No newline at end of file diff --git a/reactos/subsys/win32k/float/nafter.c b/reactos/subsys/win32k/float/nafter.c new file mode 100644 index 00000000000..5e2a2ad317f --- /dev/null +++ b/reactos/subsys/win32k/float/nafter.c @@ -0,0 +1,12 @@ +#include + +double _nextafter( double x, double y ) +{ + if ( x == y) + return x; + + if ( isnan(x) || isnan(y) ) + return x; + + return x; +} diff --git a/reactos/subsys/win32k/float/nextaf.c b/reactos/subsys/win32k/float/nextaf.c new file mode 100644 index 00000000000..d97d2dd2a71 --- /dev/null +++ b/reactos/subsys/win32k/float/nextaf.c @@ -0,0 +1,48 @@ +#define MAX_DOUBLE 1.7976931348623158e+308 +#define MIN_DOUBLE 2.2250738585072014e-308 + +double _xnextafter( double __x, double __y ) +{ + double_t *x = ( double_t *)&__x; + + double __e; + double_t *e = (double_t *)&__e; + + + if ( _isnan(__x) || _isinf(__x) ) + return __x; + + if ( _isnan(__y) ) + return __y; + + + // don't go to infinity just by adding + + if ( _isinf(__y) && fabs(__x) >= MAX_DOUBLE ) + return __x; + + if ( !_isinf(__y) && fabs(__x - __y) <= MIN_DOUBLE ) + return __y; + + + + + e->mantissal = 1; + e->mantissah = 0; + if ( x->exponent >= 53 ) + e->exponent = x->exponent - 52; + else + e->exponent = 1; + + if ( fabs(__x) < fabs(__y) ) + e->sign = 0; + else + e->sign = 1; + + + + return __x+__e; + + + +} diff --git a/reactos/subsys/win32k/float/scalb.c b/reactos/subsys/win32k/float/scalb.c new file mode 100644 index 00000000000..e035584cb93 --- /dev/null +++ b/reactos/subsys/win32k/float/scalb.c @@ -0,0 +1,12 @@ +#include +#include + +double _scalb( double __x, long e ) +{ + double_t *x = (double_t *)&__x; + + x->exponent += e; + + return __x; + +} diff --git a/reactos/subsys/win32k/float/statfp.c b/reactos/subsys/win32k/float/statfp.c new file mode 100644 index 00000000000..5cfeabfe51c --- /dev/null +++ b/reactos/subsys/win32k/float/statfp.c @@ -0,0 +1,14 @@ +#include + +unsigned int _statusfp (void) +{ + +register unsigned short __res; + +__asm__ __volatile__ ( + "fstsw %0 \n\t" +// "movzwl %ax, %eax" + :"=a" (__res) + ); + return __res; +} diff --git a/reactos/subsys/win32k/math/acos.c b/reactos/subsys/win32k/math/acos.c new file mode 100644 index 00000000000..34707822aaf --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/acosh.c b/reactos/subsys/win32k/math/acosh.c new file mode 100644 index 00000000000..15f556cbc96 --- /dev/null +++ b/reactos/subsys/win32k/math/acosh.c @@ -0,0 +1,8 @@ +/* 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/subsys/win32k/math/asin.c b/reactos/subsys/win32k/math/asin.c new file mode 100644 index 00000000000..6aeba7d9e26 --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/asinh.c b/reactos/subsys/win32k/math/asinh.c new file mode 100644 index 00000000000..7089ebcf64a --- /dev/null +++ b/reactos/subsys/win32k/math/asinh.c @@ -0,0 +1,9 @@ +/* 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/subsys/win32k/math/atan.c b/reactos/subsys/win32k/math/atan.c new file mode 100644 index 00000000000..20ef6724d7c --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/atan2.c b/reactos/subsys/win32k/math/atan2.c new file mode 100644 index 00000000000..30b800167a6 --- /dev/null +++ b/reactos/subsys/win32k/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" + "fld %%st(0)" + : "=t" (__value) : "0" (__x), "u" (__y)); + + return __value; +} \ No newline at end of file diff --git a/reactos/subsys/win32k/math/atanh.c b/reactos/subsys/win32k/math/atanh.c new file mode 100644 index 00000000000..fdfb3194cf9 --- /dev/null +++ b/reactos/subsys/win32k/math/atanh.c @@ -0,0 +1,8 @@ +/* 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/subsys/win32k/math/cabs.c b/reactos/subsys/win32k/math/cabs.c new file mode 100644 index 00000000000..2c3ada9608c --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/ceil.c b/reactos/subsys/win32k/math/ceil.c new file mode 100644 index 00000000000..56cf8569c17 --- /dev/null +++ b/reactos/subsys/win32k/math/ceil.c @@ -0,0 +1,23 @@ +#include + +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; +} + + +long double ceill (long double __x) +{ + return floor(__x)+1; +} \ No newline at end of file diff --git a/reactos/subsys/win32k/math/cos.c b/reactos/subsys/win32k/math/cos.c new file mode 100644 index 00000000000..07edd8b0a3e --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/cosh.c b/reactos/subsys/win32k/math/cosh.c new file mode 100644 index 00000000000..85e95f088ac --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/exp.c b/reactos/subsys/win32k/math/exp.c new file mode 100644 index 00000000000..71df0e0e309 --- /dev/null +++ b/reactos/subsys/win32k/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" + "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/subsys/win32k/math/fabs.c b/reactos/subsys/win32k/math/fabs.c new file mode 100644 index 00000000000..f56c2682528 --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/floor.c b/reactos/subsys/win32k/math/floor.c new file mode 100644 index 00000000000..7403a52aa16 --- /dev/null +++ b/reactos/subsys/win32k/math/floor.c @@ -0,0 +1,50 @@ +/* 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; +} + +typedef struct IEEExp { + unsigned manl:32; + unsigned manh:32; + unsigned exp:15; + unsigned sign:1; + } long_double_t; + +long double floorl(long double x ) +{ + + return (long double)(long long int)x; +} + diff --git a/reactos/subsys/win32k/math/fmod.c b/reactos/subsys/win32k/math/fmod.c new file mode 100644 index 00000000000..8e178d9ef77 --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/frexp.c b/reactos/subsys/win32k/math/frexp.c new file mode 100644 index 00000000000..8b3390de34c --- /dev/null +++ b/reactos/subsys/win32k/math/frexp.c @@ -0,0 +1,20 @@ +#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/subsys/win32k/math/ftol.c b/reactos/subsys/win32k/math/ftol.c new file mode 100644 index 00000000000..b20aef46aca --- /dev/null +++ b/reactos/subsys/win32k/math/ftol.c @@ -0,0 +1,5 @@ +#include + +long _ftol(double fl) { + return (long)fl; +} diff --git a/reactos/subsys/win32k/math/huge_val.c b/reactos/subsys/win32k/math/huge_val.c new file mode 100644 index 00000000000..91eefa00fed --- /dev/null +++ b/reactos/subsys/win32k/math/huge_val.c @@ -0,0 +1,7 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ + +#include + +#undef _HUGE +double_t _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 }; +double *_HUGE_dll = (double *)&_HUGE; diff --git a/reactos/subsys/win32k/math/hypot.c b/reactos/subsys/win32k/math/hypot.c new file mode 100644 index 00000000000..08e34923f04 --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/j0_y0.c b/reactos/subsys/win32k/math/j0_y0.c new file mode 100644 index 00000000000..fe3c422f3bc --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/j1_y1.c b/reactos/subsys/win32k/math/j1_y1.c new file mode 100644 index 00000000000..76432b9f67b --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/jn_yn.c b/reactos/subsys/win32k/math/jn_yn.c new file mode 100644 index 00000000000..b3a718163d4 --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/ldexp.c b/reactos/subsys/win32k/math/ldexp.c new file mode 100644 index 00000000000..f96c3c35aa4 --- /dev/null +++ b/reactos/subsys/win32k/math/ldexp.c @@ -0,0 +1,31 @@ +/* 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 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/subsys/win32k/math/log.c b/reactos/subsys/win32k/math/log.c new file mode 100644 index 00000000000..b8cf142f50c --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/log10.c b/reactos/subsys/win32k/math/log10.c new file mode 100644 index 00000000000..64a6b1708e4 --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/modf.c b/reactos/subsys/win32k/math/modf.c new file mode 100644 index 00000000000..6864e52e044 --- /dev/null +++ b/reactos/subsys/win32k/math/modf.c @@ -0,0 +1,141 @@ +/* @(#)s_modf.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include +#include +#include + + + +//static const double one = 1.0; + +double modf(double __x, double *__i) +{ + + double_t * x = (double_t *)&__x; + double_t * iptr = ( double_t *)__i; + + int j0; + unsigned int i; + j0 = x->exponent - 0x3ff; /* exponent of x */ + if(j0<20) { /* integer part in high x */ + if(j0<0) { /* |x|<1 */ + *__i = 0.0; + iptr->sign = x->sign; + return __x; + } else { + + if ( x->mantissah == 0 && x->mantissal == 0 ) { + *__i = __x; + return 0.0; + } + + i = (0x000fffff)>>j0; + iptr->sign = x->sign; + iptr->exponent = x->exponent; + iptr->mantissah = x->mantissah&(~i); + iptr->mantissal = 0; + if ( __x == *__i ) { + __x = 0.0; + x->sign = iptr->sign; + return __x; + } + return __x - *__i; + } + } else if (j0>51) { /* no fraction part */ + *__i = __x; + if ( _isnan(__x) || _isinf(__x) ) + return __x; + + + __x = 0.0; + x->sign = iptr->sign; + return __x; + } else { /* fraction part in low x */ + + + i = ((unsigned)(0xffffffff))>>(j0-20); + iptr->sign = x->sign; + iptr->exponent = x->exponent; + iptr->mantissah = x->mantissah; + iptr->mantissal = x->mantissal&(~i); + if ( __x == *__i ) { + __x = 0.0; + x->sign = iptr->sign; + return __x; + } + return __x - *__i; + } +} + + +long double modfl(long double __x, long double *__i) +{ + + + long_double_t * x = (long_double_t *)&__x; + long_double_t * iptr = (long_double_t *)__i; + + int j0; + unsigned int i; + j0 = x->exponent - 0x3fff; /* exponent of x */ + + + if(j0<32) { /* integer part in high x */ + if(j0<0) { /* |x|<1 */ + *__i = 0.0L; + iptr->sign = x->sign; + return __x; + } else { + + i = ((unsigned int)(0xffffffff))>>(j0+1); + if ( x->mantissal == 0 && (x->mantissal & i) == 0 ) { + *__i = __x; + __x = 0.0L; + x->sign = iptr->sign; + return __x; + } + iptr->sign = x->sign; + iptr->exponent = x->exponent; + iptr->mantissah = x->mantissah&((~i)); + iptr->mantissal = 0; + + + return __x - *__i; + } + } else if (j0>63) { /* no fraction part */ + *__i = __x; + if ( _isnanl(__x) || _isinfl(__x) ) + return __x; + + __x = 0.0L; + x->sign = iptr->sign; + return __x; + } else { /* fraction part in low x */ + + i = ((unsigned int)(0xffffffff))>>(j0-32); + if ( x->mantissal == 0 ) { + *__i = __x; + __x = 0.0L; + x->sign = iptr->sign; + return __x; + } + iptr->sign = x->sign; + iptr->exponent = x->exponent; + iptr->mantissah = x->mantissah; + iptr->mantissal = x->mantissal&(~i); + + return __x - *__i; + + + } +} diff --git a/reactos/subsys/win32k/math/pow.c b/reactos/subsys/win32k/math/pow.c new file mode 100644 index 00000000000..37810ac5362 --- /dev/null +++ b/reactos/subsys/win32k/math/pow.c @@ -0,0 +1,85 @@ +/* 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" + "fst %%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; +} + +long double powl (long double __x,long double __y) +{ + return pow(__x,__y/2)*pow(__x,__y/2); +} + diff --git a/reactos/subsys/win32k/math/sin.c b/reactos/subsys/win32k/math/sin.c new file mode 100644 index 00000000000..be9e0b34fa4 --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/sinh.c b/reactos/subsys/win32k/math/sinh.c new file mode 100644 index 00000000000..7acb21f05d4 --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/sqrt.c b/reactos/subsys/win32k/math/sqrt.c new file mode 100644 index 00000000000..f157eab5723 --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/stubs.c b/reactos/subsys/win32k/math/stubs.c new file mode 100644 index 00000000000..5c7686d2693 --- /dev/null +++ b/reactos/subsys/win32k/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/subsys/win32k/math/tan.c b/reactos/subsys/win32k/math/tan.c new file mode 100644 index 00000000000..2a460a9032a --- /dev/null +++ b/reactos/subsys/win32k/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; +} diff --git a/reactos/subsys/win32k/math/tanh.c b/reactos/subsys/win32k/math/tanh.c new file mode 100644 index 00000000000..12b00128104 --- /dev/null +++ b/reactos/subsys/win32k/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); + } +} +