diff --git a/lib/sdk/crt/CMakeLists.txt b/lib/sdk/crt/CMakeLists.txt index a710e267dfa..9b6c5d9d6c4 100644 --- a/lib/sdk/crt/CMakeLists.txt +++ b/lib/sdk/crt/CMakeLists.txt @@ -56,6 +56,7 @@ list(APPEND CRT_SOURCE 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 @@ list(APPEND CRT_SOURCE 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 diff --git a/lib/sdk/crt/math/acos.c b/lib/sdk/crt/math/acos.c index ac348f87228..4f7a65069eb 100644 --- a/lib/sdk/crt/math/acos.c +++ b/lib/sdk/crt/math/acos.c @@ -21,6 +21,9 @@ #include +#ifdef _MSC_VER +#pragma function(acos) +#endif double acos(double __x) { diff --git a/lib/sdk/crt/math/asin.c b/lib/sdk/crt/math/asin.c index 5be040d1154..9a7ececcc6a 100644 --- a/lib/sdk/crt/math/asin.c +++ b/lib/sdk/crt/math/asin.c @@ -21,6 +21,9 @@ #include +#ifdef _MSC_VER +#pragma function(asin) +#endif double asin(double __x) { diff --git a/lib/sdk/crt/math/cosf.c b/lib/sdk/crt/math/cosf.c index d2329c7f254..0605582efd4 100644 --- a/lib/sdk/crt/math/cosf.c +++ b/lib/sdk/crt/math/cosf.c @@ -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 +#undef cosf float cosf(float _X) { diff --git a/lib/sdk/crt/math/cosh.c b/lib/sdk/crt/math/cosh.c index e81fde563f8..e97651f549c 100644 --- a/lib/sdk/crt/math/cosh.c +++ b/lib/sdk/crt/math/cosh.c @@ -1,6 +1,9 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include +#ifdef _MSC_VER +#pragma function(cosh) +#endif /* * @implemented diff --git a/lib/sdk/crt/math/i386/atan2.c b/lib/sdk/crt/math/i386/atan2.c deleted file mode 100644 index 7b7ebac8a22..00000000000 --- a/lib/sdk/crt/math/i386/atan2.c +++ /dev/null @@ -1,27 +0,0 @@ - -#include - -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; -} diff --git a/lib/sdk/crt/math/i386/atan2_asm.s b/lib/sdk/crt/math/i386/atan2_asm.s new file mode 100644 index 00000000000..33d4329bbda --- /dev/null +++ b/lib/sdk/crt/math/i386/atan2_asm.s @@ -0,0 +1,18 @@ + +#include + +PUBLIC _atan2 + +.code +_atan2: + push ebp + mov ebp, esp + + fld qword ptr [ebp + 8] + fld qword ptr [ebp + 16] + fpatan + + pop ebp + retn + +END diff --git a/lib/sdk/crt/math/i386/exp.c b/lib/sdk/crt/math/i386/exp.c deleted file mode 100644 index 727a1cb5419..00000000000 --- a/lib/sdk/crt/math/i386/exp.c +++ /dev/null @@ -1,64 +0,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 , 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 - -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__*/ -} diff --git a/lib/sdk/crt/math/i386/exp_asm.s b/lib/sdk/crt/math/i386/exp_asm.s new file mode 100644 index 00000000000..be2f33fc9e5 --- /dev/null +++ b/lib/sdk/crt/math/i386/exp_asm.s @@ -0,0 +1,29 @@ + +#include + +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 diff --git a/lib/sdk/crt/math/i386/fmod.c b/lib/sdk/crt/math/i386/fmod.c deleted file mode 100644 index fe74aa5e4d1..00000000000 --- a/lib/sdk/crt/math/i386/fmod.c +++ /dev/null @@ -1,49 +0,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 , 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 - -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; -} diff --git a/lib/sdk/crt/math/i386/fmod_asm.s b/lib/sdk/crt/math/i386/fmod_asm.s new file mode 100644 index 00000000000..53136b6b3c4 --- /dev/null +++ b/lib/sdk/crt/math/i386/fmod_asm.s @@ -0,0 +1,26 @@ + +#include + +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 diff --git a/lib/sdk/crt/math/i386/fmodf.c b/lib/sdk/crt/math/i386/fmodf.c deleted file mode 100644 index 761f56c043e..00000000000 --- a/lib/sdk/crt/math/i386/fmodf.c +++ /dev/null @@ -1,28 +0,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 . - * Public domain. - * - * Adapted for float type by Danny Smith - * . - */ - -#include - -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; -} diff --git a/lib/sdk/crt/math/i386/fmodf_asm.s b/lib/sdk/crt/math/i386/fmodf_asm.s new file mode 100644 index 00000000000..c75df1ef3eb --- /dev/null +++ b/lib/sdk/crt/math/i386/fmodf_asm.s @@ -0,0 +1,26 @@ + +#include + +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 diff --git a/lib/sdk/crt/math/logf.c b/lib/sdk/crt/math/logf.c index 0da1dae909f..417250f46a8 100644 --- a/lib/sdk/crt/math/logf.c +++ b/lib/sdk/crt/math/logf.c @@ -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 +#undef logf float logf(float _X) { diff --git a/lib/sdk/crt/math/modf.c b/lib/sdk/crt/math/modf.c index 8212070e2c8..c6d959293ff 100644 --- a/lib/sdk/crt/math/modf.c +++ b/lib/sdk/crt/math/modf.c @@ -9,8 +9,9 @@ * is preserved. * ==================================================== */ - +#define modfl _dummy_modfl #include +#undef modfl //static const double one = 1.0; diff --git a/lib/sdk/crt/math/sinf.c b/lib/sdk/crt/math/sinf.c index 1069dcf18b7..92ffc9900d4 100644 --- a/lib/sdk/crt/math/sinf.c +++ b/lib/sdk/crt/math/sinf.c @@ -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 +#undef sinf float sinf(float _X) { diff --git a/lib/sdk/crt/math/sinh.c b/lib/sdk/crt/math/sinh.c index fa9e5f7586d..7de7744348c 100644 --- a/lib/sdk/crt/math/sinh.c +++ b/lib/sdk/crt/math/sinh.c @@ -1,6 +1,10 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include +#ifdef _MSC_VER +#pragma function(sinh) +#endif + /* * @implemented */ diff --git a/lib/sdk/crt/math/i386/sqrtf.c b/lib/sdk/crt/math/sqrtf.c similarity index 94% rename from lib/sdk/crt/math/i386/sqrtf.c rename to lib/sdk/crt/math/sqrtf.c index ff36a345b6d..054f1ec9f19 100644 --- a/lib/sdk/crt/math/i386/sqrtf.c +++ b/lib/sdk/crt/math/sqrtf.c @@ -6,7 +6,7 @@ #include float -sqrtf(float x) +_sqrtf(float x) { return ((float)sqrt((double)x)); } diff --git a/lib/sdk/crt/math/tanh.c b/lib/sdk/crt/math/tanh.c index 8c231c12c3a..43262f3b4ee 100644 --- a/lib/sdk/crt/math/tanh.c +++ b/lib/sdk/crt/math/tanh.c @@ -2,6 +2,10 @@ #include +#ifdef _MSC_VER +#pragma function(tanh) +#endif + /* * @implemented */