[CRT]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Mon, 8 Nov 2010 18:36:45 +0000 (18:36 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Mon, 8 Nov 2010 18:36:45 +0000 (18:36 +0000)
- 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

svn path=/branches/cmake-bringup/; revision=49534

19 files changed:
lib/sdk/crt/CMakeLists.txt
lib/sdk/crt/math/acos.c
lib/sdk/crt/math/asin.c
lib/sdk/crt/math/cosf.c
lib/sdk/crt/math/cosh.c
lib/sdk/crt/math/i386/atan2.c [deleted file]
lib/sdk/crt/math/i386/atan2_asm.s [new file with mode: 0644]
lib/sdk/crt/math/i386/exp.c [deleted file]
lib/sdk/crt/math/i386/exp_asm.s [new file with mode: 0644]
lib/sdk/crt/math/i386/fmod.c [deleted file]
lib/sdk/crt/math/i386/fmod_asm.s [new file with mode: 0644]
lib/sdk/crt/math/i386/fmodf.c [deleted file]
lib/sdk/crt/math/i386/fmodf_asm.s [new file with mode: 0644]
lib/sdk/crt/math/logf.c
lib/sdk/crt/math/modf.c
lib/sdk/crt/math/sinf.c
lib/sdk/crt/math/sinh.c
lib/sdk/crt/math/sqrtf.c [moved from lib/sdk/crt/math/i386/sqrtf.c with 94% similarity]
lib/sdk/crt/math/tanh.c

index a710e26..9b6c5d9 100644 (file)
@@ -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
index ac348f8..4f7a650 100644 (file)
@@ -21,6 +21,9 @@
 
 #include <math.h>
 
+#ifdef _MSC_VER
+#pragma function(acos)
+#endif
 
 double acos(double __x)
 {
index 5be040d..9a7ecec 100644 (file)
@@ -21,6 +21,9 @@
 
 #include <math.h>
 
+#ifdef _MSC_VER
+#pragma function(asin)
+#endif
 
 double asin(double __x)
 {
index d2329c7..0605582 100644 (file)
@@ -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)
 {
index e81fde5..e97651f 100644 (file)
@@ -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
diff --git a/lib/sdk/crt/math/i386/atan2.c b/lib/sdk/crt/math/i386/atan2.c
deleted file mode 100644 (file)
index 7b7ebac..0000000
+++ /dev/null
@@ -1,27 +0,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;
-}
diff --git a/lib/sdk/crt/math/i386/atan2_asm.s b/lib/sdk/crt/math/i386/atan2_asm.s
new file mode 100644 (file)
index 0000000..33d4329
--- /dev/null
@@ -0,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
diff --git a/lib/sdk/crt/math/i386/exp.c b/lib/sdk/crt/math/i386/exp.c
deleted file mode 100644 (file)
index 727a1cb..0000000
+++ /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 <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__*/
-}
diff --git a/lib/sdk/crt/math/i386/exp_asm.s b/lib/sdk/crt/math/i386/exp_asm.s
new file mode 100644 (file)
index 0000000..be2f33f
--- /dev/null
@@ -0,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
diff --git a/lib/sdk/crt/math/i386/fmod.c b/lib/sdk/crt/math/i386/fmod.c
deleted file mode 100644 (file)
index fe74aa5..0000000
+++ /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 <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;
-}
diff --git a/lib/sdk/crt/math/i386/fmod_asm.s b/lib/sdk/crt/math/i386/fmod_asm.s
new file mode 100644 (file)
index 0000000..53136b6
--- /dev/null
@@ -0,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
diff --git a/lib/sdk/crt/math/i386/fmodf.c b/lib/sdk/crt/math/i386/fmodf.c
deleted file mode 100644 (file)
index 761f56c..0000000
+++ /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 <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;
-}
diff --git a/lib/sdk/crt/math/i386/fmodf_asm.s b/lib/sdk/crt/math/i386/fmodf_asm.s
new file mode 100644 (file)
index 0000000..c75df1e
--- /dev/null
@@ -0,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
index 0da1dae..417250f 100644 (file)
@@ -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)
 {
index 8212070..c6d9592 100644 (file)
@@ -9,8 +9,9 @@
  * is preserved.
  * ====================================================
  */
-
+#define modfl _dummy_modfl
 #include <precomp.h>
+#undef modfl
 
 //static const double one = 1.0;
 
index 1069dcf..92ffc99 100644 (file)
@@ -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)
 {
index fa9e5f7..7de7744 100644 (file)
@@ -1,6 +1,10 @@
 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
 #include <math.h>
 
+#ifdef _MSC_VER
+#pragma function(sinh)
+#endif
+
 /*
  * @implemented
  */
similarity index 94%
rename from lib/sdk/crt/math/i386/sqrtf.c
rename to lib/sdk/crt/math/sqrtf.c
index ff36a34..054f1ec 100644 (file)
@@ -6,7 +6,7 @@
 #include <math.h>
 
 float
-sqrtf(float x)
+_sqrtf(float x)
 {
    return ((float)sqrt((double)x));
 }
index 8c231c1..43262f3 100644 (file)
@@ -2,6 +2,10 @@
 
 #include <math.h>
 
+#ifdef _MSC_VER
+#pragma function(tanh)
+#endif
+
 /*
  * @implemented
  */