Author: tkreuzer Date: Mon Nov 8 18:36:45 2010 New Revision: 49534
URL: http://svn.reactos.org/svn/reactos?rev=49534&view=rev Log: [CRT] - Add #pragma function to a number of intrisics that we implement to avoid a compiler error of MSVC - Add a workaround to prevent some functions from being inlined - Move sqrtf out of i386 directory - Convert a number of inline assembly functions to raw assembly
Added: branches/cmake-bringup/lib/sdk/crt/math/i386/atan2_asm.s (with props) branches/cmake-bringup/lib/sdk/crt/math/i386/exp_asm.s (with props) branches/cmake-bringup/lib/sdk/crt/math/i386/fmod_asm.s (with props) branches/cmake-bringup/lib/sdk/crt/math/i386/fmodf_asm.s (with props) branches/cmake-bringup/lib/sdk/crt/math/sqrtf.c - copied, changed from r49530, branches/cmake-bringup/lib/sdk/crt/math/i386/sqrtf.c Removed: branches/cmake-bringup/lib/sdk/crt/math/i386/atan2.c branches/cmake-bringup/lib/sdk/crt/math/i386/exp.c branches/cmake-bringup/lib/sdk/crt/math/i386/fmod.c branches/cmake-bringup/lib/sdk/crt/math/i386/fmodf.c branches/cmake-bringup/lib/sdk/crt/math/i386/sqrtf.c Modified: branches/cmake-bringup/lib/sdk/crt/CMakeLists.txt branches/cmake-bringup/lib/sdk/crt/math/acos.c branches/cmake-bringup/lib/sdk/crt/math/asin.c branches/cmake-bringup/lib/sdk/crt/math/cosf.c branches/cmake-bringup/lib/sdk/crt/math/cosh.c branches/cmake-bringup/lib/sdk/crt/math/logf.c branches/cmake-bringup/lib/sdk/crt/math/modf.c branches/cmake-bringup/lib/sdk/crt/math/sinf.c branches/cmake-bringup/lib/sdk/crt/math/sinh.c branches/cmake-bringup/lib/sdk/crt/math/tanh.c
Modified: branches/cmake-bringup/lib/sdk/crt/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/CMakeL... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/CMakeLists.txt [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/CMakeLists.txt [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -56,6 +56,7 @@ math/logf.c math/modf.c math/rand.c + math/sqrtf.c math/s_modf.c math/sinf.c math/sinh.c @@ -327,13 +328,12 @@ math/i386/sin_asm.s math/i386/sqrt_asm.s math/i386/tan_asm.s - math/i386/atan2.c + math/i386/atan2_asm.s math/i386/ci.c - math/i386/exp.c - math/i386/fmod.c - math/i386/fmodf.c + math/i386/exp_asm.s + math/i386/fmod_asm.s + math/i386/fmodf_asm.s math/i386/ldexp.c - math/i386/sqrtf.c mem/i386/memchr_asm.s mem/i386/memmove_asm.s mem/i386/memset_asm.s
Modified: branches/cmake-bringup/lib/sdk/crt/math/acos.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/a... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/acos.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/acos.c [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -21,6 +21,9 @@
#include <math.h>
+#ifdef _MSC_VER +#pragma function(acos) +#endif
double acos(double __x) {
Modified: branches/cmake-bringup/lib/sdk/crt/math/asin.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/a... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/asin.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/asin.c [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -21,6 +21,9 @@
#include <math.h>
+#ifdef _MSC_VER +#pragma function(asin) +#endif
double asin(double __x) {
Modified: branches/cmake-bringup/lib/sdk/crt/math/cosf.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/c... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/cosf.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/cosf.c [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -3,7 +3,9 @@ * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ +#define cosf _dummy_cosf #include <math.h> +#undef cosf
float cosf(float _X) {
Modified: branches/cmake-bringup/lib/sdk/crt/math/cosh.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/c... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/cosh.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/cosh.c [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -1,6 +1,9 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include <math.h>
+#ifdef _MSC_VER +#pragma function(cosh) +#endif
/* * @implemented
Removed: branches/cmake-bringup/lib/sdk/crt/math/i386/atan2.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/i... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/i386/atan2.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/i386/atan2.c (removed) @@ -1,27 +1,0 @@ - -#include <math.h> - -double atan2 (double __y, double __x); - -/* - * @implemented - */ -double atan2 (double __y, double __x) -{ - register double __val; -#ifdef __GNUC__ - __asm __volatile__ - ("fpatan\n\t" - "fld %%st(0)" - : "=t" (__val) : "0" (__x), "u" (__y)); -#else - __asm - { - fld __y - fld __x - fpatan - fstp __val - } -#endif /*__GNUC__*/ - return __val; -}
Added: branches/cmake-bringup/lib/sdk/crt/math/i386/atan2_asm.s URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/i... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/i386/atan2_asm.s (added) +++ branches/cmake-bringup/lib/sdk/crt/math/i386/atan2_asm.s [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -1,0 +1,18 @@ + +#include <reactos/asm.h> + +PUBLIC _atan2 + +.code +_atan2: + push ebp + mov ebp, esp + + fld qword ptr [ebp + 8] + fld qword ptr [ebp + 16] + fpatan + + pop ebp + retn + +END
Propchange: branches/cmake-bringup/lib/sdk/crt/math/i386/atan2_asm.s ------------------------------------------------------------------------------ svn:eol-style = native
Removed: branches/cmake-bringup/lib/sdk/crt/math/i386/exp.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/i... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/i386/exp.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/i386/exp.c (removed) @@ -1,64 +1,0 @@ -/* 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 bowman@ipp-garching.mpg.de, 1995. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <math.h> - -double exp (double __x); - -double exp (double __x) -{ -#ifdef __GNUC__ - 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; -#else - register double __val; - __asm - { - fld1 // store 1.0 for later use - fld __x - fldl2e // e^x = 2^(x * log2(e)) - fmul st,st(1) // x * log2(e) - fld st(0) - frndint // int(x * log2(e)) - fsub st,st(1) // fract(x * log2(e)) - fxch - f2xm1 // 2^(fract(x * log2(e))) - 1 - fadd st,st(3) // + 1.0 - fscale - fstp __val - } - return __val; -#endif /*__GNUC__*/ -}
Added: branches/cmake-bringup/lib/sdk/crt/math/i386/exp_asm.s URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/i... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/i386/exp_asm.s (added) +++ branches/cmake-bringup/lib/sdk/crt/math/i386/exp_asm.s [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -1,0 +1,29 @@ + +#include <reactos/asm.h> + +PUBLIC _exp + +/* FUNCTIONS ***************************************************************/ +.code + +_exp: + push ebp + mov ebp, esp + + fld qword ptr [ebp + 8] + fldl2e + fmul st, st(1) + fst st(1) + frndint + fxch st(1) + fsub st, st(1) + f2xm1 + fld1 + faddp st(1), st + fscale + fstp st(1) + + pop ebp + retn + +END
Propchange: branches/cmake-bringup/lib/sdk/crt/math/i386/exp_asm.s ------------------------------------------------------------------------------ svn:eol-style = native
Removed: branches/cmake-bringup/lib/sdk/crt/math/i386/fmod.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/i... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/i386/fmod.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/i386/fmod.c (removed) @@ -1,49 +1,0 @@ -/* 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 bowman@ipp-garching.mpg.de, 1995. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <math.h> - -double fmod (double __x, double __y); - -double fmod (double __x, double __y) -{ - register double __val; -#ifdef __GNUC__ - __asm __volatile__ - ("1: fprem\n\t" - "fstsw %%ax\n\t" - "sahf\n\t" - "jp 1b" - : "=t" (__val) : "0" (__x), "u" (__y) : "ax", "cc"); -#else - __asm - { - fld __y - fld __x -L1: fprem1 - fstsw ax - sahf - jp L1 - fstp __val - } -#endif /*__GNUC__*/ - return __val; -}
Added: branches/cmake-bringup/lib/sdk/crt/math/i386/fmod_asm.s URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/i... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/i386/fmod_asm.s (added) +++ branches/cmake-bringup/lib/sdk/crt/math/i386/fmod_asm.s [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -1,0 +1,26 @@ + +#include <reactos/asm.h> + +PUBLIC _fmod + +/* FUNCTIONS ***************************************************************/ +.code + +_fmod: + push ebp + mov ebp, esp + + fld qword ptr [ebp + 8] + fld qword ptr [ebp + 16] + fxch st(1) +l1: + fprem + fstsw ax + sahf + jp l1 + fstp st(1) + + pop ebp + ret + +END
Propchange: branches/cmake-bringup/lib/sdk/crt/math/i386/fmod_asm.s ------------------------------------------------------------------------------ svn:eol-style = native
Removed: branches/cmake-bringup/lib/sdk/crt/math/i386/fmodf.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/i... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/i386/fmodf.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/i386/fmodf.c (removed) @@ -1,28 +1,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -/* - * Written by J.T. Conklin jtc@netbsd.org. - * Public domain. - * - * Adapted for float type by Danny Smith - * dannysmith@users.sourceforge.net. - */ - -#include <math.h> - -float -fmodf (float x, float y) -{ - float res = 0.0F; - - asm ("1:\tfprem\n\t" - "fstsw %%ax\n\t" - "sahf\n\t" - "jp 1b\n\t" - "fstp %%st(1)" - : "=t" (res) : "0" (x), "u" (y) : "ax", "st(1)"); - return res; -}
Added: branches/cmake-bringup/lib/sdk/crt/math/i386/fmodf_asm.s URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/i... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/i386/fmodf_asm.s (added) +++ branches/cmake-bringup/lib/sdk/crt/math/i386/fmodf_asm.s [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -1,0 +1,26 @@ + +#include <reactos/asm.h> + +PUBLIC _fmodf + +/* FUNCTIONS ***************************************************************/ +.code + +_fmodf: + push ebp + mov ebp, esp + + fld dword ptr [esp + 4] + fld dword ptr [esp + 8] + fxch st(1) +l1: + fprem + fstsw ax + sahf + jp l1 + fstp st(1) + + pop ebp + ret + +END
Propchange: branches/cmake-bringup/lib/sdk/crt/math/i386/fmodf_asm.s ------------------------------------------------------------------------------ svn:eol-style = native
Removed: branches/cmake-bringup/lib/sdk/crt/math/i386/sqrtf.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/i... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/i386/sqrtf.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/i386/sqrtf.c (removed) @@ -1,12 +1,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#include <math.h> - -float -sqrtf(float x) -{ - return ((float)sqrt((double)x)); -}
Modified: branches/cmake-bringup/lib/sdk/crt/math/logf.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/l... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/logf.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/logf.c [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -3,7 +3,9 @@ * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ +#define logf _dummy_logf #include <math.h> +#undef logf
float logf(float _X) {
Modified: branches/cmake-bringup/lib/sdk/crt/math/modf.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/m... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/modf.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/modf.c [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -9,8 +9,9 @@ * is preserved. * ==================================================== */ - +#define modfl _dummy_modfl #include <precomp.h> +#undef modfl
//static const double one = 1.0;
Modified: branches/cmake-bringup/lib/sdk/crt/math/sinf.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/s... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/sinf.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/sinf.c [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -3,7 +3,9 @@ * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ +#define sinf _dummy_sinf #include <math.h> +#undef sinf
float sinf(float _X) {
Modified: branches/cmake-bringup/lib/sdk/crt/math/sinh.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/s... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/sinh.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/sinh.c [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -1,5 +1,9 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include <math.h> + +#ifdef _MSC_VER +#pragma function(sinh) +#endif
/* * @implemented
Copied: branches/cmake-bringup/lib/sdk/crt/math/sqrtf.c (from r49530, branches/cmake-bringup/lib/sdk/crt/math/i386/sqrtf.c) URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/s... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/i386/sqrtf.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/sqrtf.c [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -6,7 +6,7 @@ #include <math.h>
float -sqrtf(float x) +_sqrtf(float x) { return ((float)sqrt((double)x)); }
Modified: branches/cmake-bringup/lib/sdk/crt/math/tanh.c URL: http://svn.reactos.org/svn/reactos/branches/cmake-bringup/lib/sdk/crt/math/t... ============================================================================== --- branches/cmake-bringup/lib/sdk/crt/math/tanh.c [iso-8859-1] (original) +++ branches/cmake-bringup/lib/sdk/crt/math/tanh.c [iso-8859-1] Mon Nov 8 18:36:45 2010 @@ -1,6 +1,10 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <math.h> + +#ifdef _MSC_VER +#pragma function(tanh) +#endif
/* * @implemented