[CRT]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 21 Jul 2010 16:03:44 +0000 (16:03 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 21 Jul 2010 16:03:44 +0000 (16:03 +0000)
- Add a number of amd64 specific math functions
- add generic c versions of cos and sin
- Remove leading underscores from amd64 symbols

svn path=/trunk/; revision=48161

30 files changed:
reactos/lib/sdk/crt/crt.rbuild
reactos/lib/sdk/crt/except/amd64/chkstk_asm.s
reactos/lib/sdk/crt/except/amd64/seh.s
reactos/lib/sdk/crt/libcntpr.rbuild
reactos/lib/sdk/crt/math/amd64/alldiv.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/atan.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/atan2.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/ceil.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/ceilf.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/exp.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/fabs.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/floor.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/floorf.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/fmod.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/fmodf.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/ldexp.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/log.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/log10.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/pow.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/sqrt.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/sqrtf.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/amd64/tan.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/cos.c [new file with mode: 0644]
reactos/lib/sdk/crt/math/cosf.c [new file with mode: 0644]
reactos/lib/sdk/crt/math/i386/ceilf.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/i386/floorf.S [new file with mode: 0644]
reactos/lib/sdk/crt/math/i386/fmodf.c [new file with mode: 0644]
reactos/lib/sdk/crt/math/i386/sqrtf.c [new file with mode: 0644]
reactos/lib/sdk/crt/math/sin.c [new file with mode: 0644]
reactos/lib/sdk/crt/math/sinf.c [new file with mode: 0644]

index 5100612..a8cbc90 100644 (file)
                <file>adjust.c</file>
                <file>asin.c</file>
                <file>cabs.c</file>
+               <file>cosf.c</file>
                <file>cosh.c</file>
                <file>div.c</file>
                <file>fdivbug.c</file>
                <file>modf.c</file>
                <file>rand.c</file>
                <file>s_modf.c</file>
+               <file>sinf.c</file>
                <file>sinh.c</file>
                <file>tanh.c</file>
                <file>pow_asm.c</file>
                                <file>aullrem_asm.s</file>
                                <file>aullshr_asm.s</file>
                                <file>ceil_asm.s</file>
+                               <file>ceilf.S</file>
                                <file>cos_asm.s</file>
                                <file>fabs_asm.s</file>
                                <file>floor_asm.s</file>
+                               <file>floorf.S</file>
                                <file>ftol_asm.s</file>
                                <file>log_asm.s</file>
                                <file>log10_asm.s</file>
                                <file>ci.c</file>
                                <file>exp.c</file>
                                <file>fmod.c</file>
+                               <file>fmodf.c</file>
                                <file>ldexp.c</file>
+                               <file>sqrtf.c</file>
                        </directory>
                        <!-- FIXME: we don't actually implement these... they recursively call themselves through an alias -->
                        <!--<file>j0_y0.c</file>
                        <file>jn_yn.c</file>-->
                </if>
                <if property="ARCH" value="amd64">
-                       <directory name="i386">
-                               <file>atan2.c</file>
-                               <file>exp.c</file>
-                               <file>fmod.c</file>
-                               <file>ldexp.c</file>
+                       <file>cos.c</file>
+                       <file>sin.c</file>
+                       <directory name="amd64">
+                               <file>alldiv.S</file>
+                               <file>atan.S</file>
+                               <file>atan2.S</file>
+                               <file>ceil.S</file>
+                               <file>ceilf.S</file>
+                               <file>exp.S</file>
+                               <file>fabs.S</file>
+                               <file>floor.S</file>
+                               <file>floorf.S</file>
+                               <file>fmod.S</file>
+                               <file>fmodf.S</file>
+                               <file>ldexp.S</file>
+                               <file>log.S</file>
+                               <file>log10.S</file>
+                               <file>pow.S</file>
+                               <file>sqrt.S</file>
+                               <file>sqrtf.S</file>
+                               <file>tan.S</file>
                        </directory>
                        <!-- FIXME: we don't actually implement these... they recursively call themselves through an alias -->
                        <!--<file>j0_y0.c</file>
index 9501c35..4008d4f 100644 (file)
@@ -8,24 +8,23 @@
 
 /* INCLUDES ******************************************************************/
 
-#include <ndk/amd64/asm.h>
-#include <ndk/amd64/asmmacro.S>
+#include <reactos/asm.h>
 
 .intel_syntax noprefix
 
-.global _MsgUnimplemented
-_MsgUnimplemented:
+.global MsgUnimplemented
+MsgUnimplemented:
 .asciz "WARNING:  %s at %s:%d is UNIMPLEMENTED!\n"
 
 
 .proc _chkstk
     UNIMPLEMENTED chkstk
     ret
-.endproc
+.endp
 
 .proc _alloca_probe
     UNIMPLEMENTED alloca_probe
     ret
-.endproc
+.endp
 
 /* EOF */
index 82ed5ac..e784457 100644 (file)
@@ -25,7 +25,7 @@
 
 /* FUNCTIONS *****************************************************************/
 
-.func unwind_handler
+.func _unwind_handler
 _unwind_handler:
     ret
 .endfunc
index 198bdf5..e27ac1d 100644 (file)
@@ -8,6 +8,7 @@
        <define name="_NTDLLBUILD_" />
        <define name="_LIBCNT_" />
        <define name="_CRTBLD" />
+       <define name="__CRT__NO_INLINE" />
        <if property="ARCH" value="i386">
                <define name="__MINGW_IMPORT">"extern __attribute__ ((dllexport))"</define>
        </if>
                                <file>tan_asm.s</file>
                        </directory>
                </if>
+               <if property="ARCH" value="amd64">
+                       <file>cos.c</file>
+                       <file>sin.c</file>
+                       <directory name="amd64">
+                               <file>alldiv.S</file>
+                               <file>atan.S</file>
+                               <file>atan2.S</file>
+                               <file>ceil.S</file>
+                               <file>exp.S</file>
+                               <file>fabs.S</file>
+                               <file>floor.S</file>
+                               <file>fmod.S</file>
+                               <file>ldexp.S</file>
+                               <file>log.S</file>
+                               <file>log10.S</file>
+                               <file>pow.S</file>
+                               <file>sqrt.S</file>
+                               <file>tan.S</file>
+                       </directory>
+               </if>
                <file>abs.c</file>
                <file>div.c</file>
                <file>labs.c</file>
diff --git a/reactos/lib/sdk/crt/math/amd64/alldiv.S b/reactos/lib/sdk/crt/math/amd64/alldiv.S
new file mode 100644 (file)
index 0000000..831ef50
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of alldiv
+ * FILE:              lib/sdk/crt/math/amd64/alldiv.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* DATA *********************************************************************/
+
+PUBLIC _fltused
+_fltused:
+        .long 0x9875
+
+/* FUNCTIONS ****************************************************************/
+
+.code64
+
+.proc alldiv
+    UNIMPLEMENTED alldiv
+    ret
+
+.endp alldiv
diff --git a/reactos/lib/sdk/crt/math/amd64/atan.S b/reactos/lib/sdk/crt/math/amd64/atan.S
new file mode 100644 (file)
index 0000000..3ba1949
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of atan
+ * FILE:              lib/sdk/crt/math/amd64/atan.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* FUNCTIONS ****************************************************************/
+
+.code64
+
+PUBLIC atan
+atan:
+    UNIMPLEMENTED atan
+    ret
diff --git a/reactos/lib/sdk/crt/math/amd64/atan2.S b/reactos/lib/sdk/crt/math/amd64/atan2.S
new file mode 100644 (file)
index 0000000..7cd29b9
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of atan2
+ * FILE:              lib/sdk/crt/math/amd64/atan2.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* FUNCTIONS ****************************************************************/
+
+.code64
+
+PUBLIC atan2
+atan2:
+    UNIMPLEMENTED atan2
+    ret
diff --git a/reactos/lib/sdk/crt/math/amd64/ceil.S b/reactos/lib/sdk/crt/math/amd64/ceil.S
new file mode 100644 (file)
index 0000000..dbee413
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of ceil
+ * FILE:              lib/sdk/crt/math/amd64/ceil.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* FUNCTIONS ****************************************************************/
+
+.code64
+
+PUBLIC ceil
+ceil:
+    UNIMPLEMENTED ceil
+    ret
+
diff --git a/reactos/lib/sdk/crt/math/amd64/ceilf.S b/reactos/lib/sdk/crt/math/amd64/ceilf.S
new file mode 100644 (file)
index 0000000..e3a948f
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of tan
+ * FILE:              lib/sdk/crt/math/amd64/ceilf.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* FUNCTIONS ****************************************************************/
+
+.code64
+
+PUBLIC ceilf
+ceilf:
+    /* Put parameter on the stack */
+    movss [rsp - 0x10], xmm0
+    fld   dword ptr [rsp]
+
+    /* Change fpu control word to round up */
+    fstcw [rsp - 0x10]
+    mov   eax, [rsp - 0x10]
+    or    eax, 0x00800
+    and   eax, 0x0fbff
+    mov   [rsp - 0x08], eax
+    fldcw [rsp - 0x08]
+
+    /* Round to integer */
+    frndint
+
+    /* Restore fpu control word */
+    fldcw [rsp - 0x10]
+
+    fstp  dword ptr [rsp - 0x10]
+    movss xmm0, [rsp - 0x10]
+    ret
diff --git a/reactos/lib/sdk/crt/math/amd64/exp.S b/reactos/lib/sdk/crt/math/amd64/exp.S
new file mode 100644 (file)
index 0000000..ca3dc99
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of exp
+ * FILE:              lib/sdk/crt/math/amd64/exp.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* FUNCTIONS ****************************************************************/
+
+.code64
+
+PUBLIC exp
+exp:
+    UNIMPLEMENTED exp
+    ret
+
diff --git a/reactos/lib/sdk/crt/math/amd64/fabs.S b/reactos/lib/sdk/crt/math/amd64/fabs.S
new file mode 100644 (file)
index 0000000..e58b960
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of fabs
+ * FILE:              lib/sdk/crt/math/amd64/fabs.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* FUNCTIONS ****************************************************************/
+
+.code64
+
+PUBLIC fabs
+fabs:
+    UNIMPLEMENTED fabs
+    ret
+
diff --git a/reactos/lib/sdk/crt/math/amd64/floor.S b/reactos/lib/sdk/crt/math/amd64/floor.S
new file mode 100644 (file)
index 0000000..f1c3b93
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of floor
+ * FILE:              lib/sdk/crt/math/amd64/floor.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* FUNCTIONS ****************************************************************/
+
+.code64
+
+PUBLIC floor
+floor:
+    UNIMPLEMENTED floor
+    ret
diff --git a/reactos/lib/sdk/crt/math/amd64/floorf.S b/reactos/lib/sdk/crt/math/amd64/floorf.S
new file mode 100644 (file)
index 0000000..e2d0220
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of tan
+ * FILE:              lib/sdk/crt/math/amd64/floorf.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* FUNCTIONS ****************************************************************/
+
+.code64
+
+PUBLIC floorf
+floorf:
+    /* Put parameter on the stack */
+    movss [rsp - 0x10], xmm0
+    fld   dword ptr [rsp]
+
+    /* Change fpu control word to round down */
+    fstcw [rsp - 0x10]
+    mov   eax, [rsp - 0x10]
+    or    eax, 0x00400
+    and   eax, 0x0f7ff
+    mov   [rsp - 0x08], eax
+    fldcw [rsp - 0x08]
+
+    /* Round to integer */
+    frndint
+
+    /* Restore fpu control word */
+    fldcw [rsp - 0x10]
+
+    fstp  dword ptr [rsp - 0x10]
+    movss xmm0, [rsp - 0x10]
+    ret
diff --git a/reactos/lib/sdk/crt/math/amd64/fmod.S b/reactos/lib/sdk/crt/math/amd64/fmod.S
new file mode 100644 (file)
index 0000000..4ca67f5
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of fmod
+ * FILE:              lib/sdk/crt/math/amd64/fmod.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* DATA *********************************************************************/
+
+PUBLIC fmod
+fmod:
+    UNIMPLEMENTED fmod
+    ret
diff --git a/reactos/lib/sdk/crt/math/amd64/fmodf.S b/reactos/lib/sdk/crt/math/amd64/fmodf.S
new file mode 100644 (file)
index 0000000..e109c38
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of fmodf
+ * FILE:              lib/sdk/crt/math/amd64/fmodf.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* DATA *********************************************************************/
+
+PUBLIC fmodf
+fmodf:
+    UNIMPLEMENTED fmodf
+    ret
diff --git a/reactos/lib/sdk/crt/math/amd64/ldexp.S b/reactos/lib/sdk/crt/math/amd64/ldexp.S
new file mode 100644 (file)
index 0000000..d026562
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of ldexp
+ * FILE:              lib/sdk/crt/math/amd64/ldexp.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* DATA *********************************************************************/
+
+PUBLIC ldexp
+ldexp:
+    UNIMPLEMENTED ldexp
+    ret
diff --git a/reactos/lib/sdk/crt/math/amd64/log.S b/reactos/lib/sdk/crt/math/amd64/log.S
new file mode 100644 (file)
index 0000000..9fa0276
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of log
+ * FILE:              lib/sdk/crt/math/amd64/log.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* DATA *********************************************************************/
+
+PUBLIC log
+log:
+    UNIMPLEMENTED log
+    ret
diff --git a/reactos/lib/sdk/crt/math/amd64/log10.S b/reactos/lib/sdk/crt/math/amd64/log10.S
new file mode 100644 (file)
index 0000000..007f0d8
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of log10
+ * FILE:              lib/sdk/crt/math/amd64/log10.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* DATA *********************************************************************/
+
+PUBLIC log10
+log10:
+    UNIMPLEMENTED log10
+    ret
+
diff --git a/reactos/lib/sdk/crt/math/amd64/pow.S b/reactos/lib/sdk/crt/math/amd64/pow.S
new file mode 100644 (file)
index 0000000..3798880
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of pow
+ * FILE:              lib/sdk/crt/math/amd64/pow.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* DATA *********************************************************************/
+
+PUBLIC pow
+pow:
+    UNIMPLEMENTED pow
+    ret
+
diff --git a/reactos/lib/sdk/crt/math/amd64/sqrt.S b/reactos/lib/sdk/crt/math/amd64/sqrt.S
new file mode 100644 (file)
index 0000000..758d876
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of sqrt
+ * FILE:              lib/sdk/crt/math/amd64/sqrt.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* DATA *********************************************************************/
+
+PUBLIC sqrt
+sqrt:
+    UNIMPLEMENTED sqrt
+    ret
diff --git a/reactos/lib/sdk/crt/math/amd64/sqrtf.S b/reactos/lib/sdk/crt/math/amd64/sqrtf.S
new file mode 100644 (file)
index 0000000..a4ee3fa
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of tan
+ * FILE:              lib/sdk/crt/math/amd64/sqrtf.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* DATA *********************************************************************/
+
+PUBLIC sqrtf
+sqrtf:
+    sqrtss     xmm0, xmm0
+    ret
diff --git a/reactos/lib/sdk/crt/math/amd64/tan.S b/reactos/lib/sdk/crt/math/amd64/tan.S
new file mode 100644 (file)
index 0000000..a7c66d0
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS system libraries
+ * PURPOSE:           Implementation of tan
+ * FILE:              lib/sdk/crt/math/amd64/tan.S
+ * PROGRAMMER:        Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <reactos/asm.h>
+#include <ndk/amd64/asm.h>
+
+/* DATA *********************************************************************/
+
+PUBLIC tan
+tan:
+    UNIMPLEMENTED tan
+    ret
diff --git a/reactos/lib/sdk/crt/math/cos.c b/reactos/lib/sdk/crt/math/cos.c
new file mode 100644 (file)
index 0000000..1e7d8c4
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS CRT
+ * FILE:             lib/crt/math/cos.c
+ * PURPOSE:          Generic C Implementation of cos
+ * PROGRAMMER:       Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+#define PRECISION 9
+#define M_PI 3.141592653589793238462643
+
+static double cos_off_tbl[] = {0.0, -M_PI/2., 0, -M_PI/2.};
+static double cos_sign_tbl[] = {1,-1,-1,1};
+
+double
+cos(double x)
+{
+    int quadrant;
+    double x2, result;
+
+    /* Calculate the quadrant */
+    quadrant = x * (2./M_PI);
+
+    /* Get offset inside quadrant */
+    x = x - quadrant * (M_PI/2.);
+
+    /* Normalize quadrant to [0..3] */
+    quadrant = quadrant & 0x3;
+
+    /* Fixup value for the generic function */
+    x += cos_off_tbl[quadrant];
+
+    /* Calculate the negative of the square of x */
+    x2 = - (x * x);
+
+    /* This is an unrolled taylor series using <PRECISION> iterations 
+     * Example with 4 iterations:
+     * result = 1 - x^2/2! + x^4/4! - x^6/6! + x^8/8!
+     * To save multiplications and to keep the precision high, it's performed
+     * like this:
+     * result = 1 - x^2 * (1/2! - x^2 * (1/4! - x^2 * (1/6! - x^2 * (1/8!))))
+     */
+
+    /* Start with 0, compiler will optimize this away */
+    result = 0;
+
+#if (PRECISION >= 10)
+    result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*19*20);
+    result *= x2;
+#endif
+#if (PRECISION >= 9)
+    result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18);
+    result *= x2;
+#endif
+#if (PRECISION >= 8)
+    result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16);
+    result *= x2;
+#endif
+#if (PRECISION >= 7)
+    result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14);
+    result *= x2;
+#endif
+#if (PRECISION >= 6)
+    result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12);
+    result *= x2;
+#endif
+#if (PRECISION >= 5)
+    result += 1./(1.*2*3*4*5*6*7*8*9*10);
+    result *= x2;
+#endif
+    result += 1./(1.*2*3*4*5*6*7*8);
+    result *= x2;
+
+    result += 1./(1.*2*3*4*5*6);
+    result *= x2;
+
+    result += 1./(1.*2*3*4);
+    result *= x2;
+
+    result += 1./(1.*2);
+    result *= x2;
+
+    result += 1;
+
+    /* Apply correct sign */
+    result *= cos_sign_tbl[quadrant];
+
+    return result;
+}
diff --git a/reactos/lib/sdk/crt/math/cosf.c b/reactos/lib/sdk/crt/math/cosf.c
new file mode 100644 (file)
index 0000000..d2329c7
--- /dev/null
@@ -0,0 +1,11 @@
+/**
+ * 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 cosf(float _X)
+{
+  return ((float)cos((double)_X));
+}
diff --git a/reactos/lib/sdk/crt/math/i386/ceilf.S b/reactos/lib/sdk/crt/math/i386/ceilf.S
new file mode 100644 (file)
index 0000000..9eee272
--- /dev/null
@@ -0,0 +1,55 @@
+/**
+ * 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 <_mingw_mac.h>
+
+       .file   "ceilf.S"
+       .text
+       .align 4
+.globl __MINGW_USYMBOL(ceilf)
+       .def    __MINGW_USYMBOL(ceilf); .scl    2;      .type   32;     .endef
+__MINGW_USYMBOL(ceilf):
+#ifdef _WIN64
+       subq    $24,%rsp
+       movss   %xmm0,8(%rsp)
+       flds    8(%rsp)
+
+       fstcw   4(%rsp)                 /* store fpu control word */
+
+       movl    $0x0800,%edx            /* round towards +oo */
+       orl     4(%rsp),%edx
+       andl    $0xfbff,%edx
+       movl    %edx,(%rsp)
+       fldcw   (%rsp)                  /* load modified control word */
+
+       frndint                         /* round */
+
+       fldcw   4(%rsp)                 /* restore original control word */
+       fstps   8(%rsp)
+       movss   8(%rsp),%xmm0
+       addq    $24,%rsp
+       ret
+#else
+       flds    4(%esp)
+       subl    $8,%esp
+
+       fstcw   4(%esp)                 /* store fpu control word */
+
+       /* We use here %edx although only the low 1 bits are defined.
+          But none of the operations should care and they are faster
+          than the 16 bit operations.  */
+       movl    $0x0800,%edx            /* round towards +oo */
+       orl     4(%esp),%edx
+       andl    $0xfbff,%edx
+       movl    %edx,(%esp)
+       fldcw   (%esp)                  /* load modified control word */
+
+       frndint                         /* round */
+
+       fldcw   4(%esp)                 /* restore original control word */
+
+       addl    $8,%esp
+       ret
+#endif
diff --git a/reactos/lib/sdk/crt/math/i386/floorf.S b/reactos/lib/sdk/crt/math/i386/floorf.S
new file mode 100644 (file)
index 0000000..eec073b
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ *
+ * Changes for long double by Ulrich Drepper <drepper@cygnus.com>
+ * 
+ * Removed header file dependency for use in libmingwex.a by
+ *   Danny Smith <dannysmith@users.sourceforge.net>
+ */
+#include <_mingw_mac.h>
+
+       .file   "floorf.S"
+       .text
+#ifdef _WIN64
+       .align 8
+#else
+       .align 4
+#endif
+.globl __MINGW_USYMBOL(floorf)
+       .def    __MINGW_USYMBOL(floorf);        .scl    2;      .type   32;     .endef
+__MINGW_USYMBOL(floorf):
+#ifdef _WIN64
+       subq    $24,%rsp
+       movss   %xmm0,8(%rsp)
+       flds    8(%rsp)
+
+       fstcw   4(%rsp)                 /* store fpu control word */
+       movl    $0x400,%edx             /* round towards -oo */
+       orl     4(%rsp),%edx
+       andl    $0xf7ff,%edx
+       movl    %edx,(%rsp)
+       fldcw   (%rsp)                  /* load modified control word */
+
+       frndint                         /* round */
+
+       fldcw   4(%rsp)                 /* restore original control word */
+
+       fstps   8(%rsp)
+       movss   8(%rsp),%xmm0
+       addq    $24,%rsp
+       ret
+#else
+       flds    4(%esp)
+       subl    $8,%esp
+
+       fstcw   4(%esp)                 /* store fpu control word */
+
+       /* We use here %edx although only the low 1 bits are defined.
+          But none of the operations should care and they are faster
+          than the 16 bit operations.  */
+       movl    $0x400,%edx             /* round towards -oo */
+       orl     4(%esp),%edx
+       andl    $0xf7ff,%edx
+       movl    %edx,(%esp)
+       fldcw   (%esp)                  /* load modified control word */
+
+       frndint                         /* round */
+
+       fldcw   4(%esp)                 /* restore original control word */
+
+       addl    $8,%esp
+       ret
+#endif
diff --git a/reactos/lib/sdk/crt/math/i386/fmodf.c b/reactos/lib/sdk/crt/math/i386/fmodf.c
new file mode 100644 (file)
index 0000000..761f56c
--- /dev/null
@@ -0,0 +1,28 @@
+/**
+ * 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/reactos/lib/sdk/crt/math/i386/sqrtf.c b/reactos/lib/sdk/crt/math/i386/sqrtf.c
new file mode 100644 (file)
index 0000000..ff36a34
--- /dev/null
@@ -0,0 +1,12 @@
+/**
+ * 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));
+}
diff --git a/reactos/lib/sdk/crt/math/sin.c b/reactos/lib/sdk/crt/math/sin.c
new file mode 100644 (file)
index 0000000..da69573
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS CRT
+ * FILE:             lib/crt/math/sin.c
+ * PURPOSE:          Generic C Implementation of sin
+ * PROGRAMMER:       Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+#define PRECISION 9
+#define M_PI 3.141592653589793238462643
+
+static double sin_off_tbl[] = {0.0, -M_PI/2., 0, -M_PI/2.};
+static double sin_sign_tbl[] = {1,-1,-1,1};
+
+double
+sin(double x)
+{
+    int quadrant;
+    double x2, result;
+
+    /* Calculate the quadrant */
+    quadrant = x * (2./M_PI);
+
+    /* Get offset inside quadrant */
+    x = x - quadrant * (M_PI/2.);
+
+    /* Normalize quadrant to [0..3] */
+    quadrant = (quadrant - 1) & 0x3;
+
+    /* Fixup value for the generic function */
+    x += sin_off_tbl[quadrant];
+
+    /* Calculate the negative of the square of x */
+    x2 = - (x * x);
+
+    /* This is an unrolled taylor series using <PRECISION> iterations 
+     * Example with 4 iterations:
+     * result = 1 - x^2/2! + x^4/4! - x^6/6! + x^8/8!
+     * To save multiplications and to keep the precision high, it's performed
+     * like this:
+     * result = 1 - x^2 * (1/2! - x^2 * (1/4! - x^2 * (1/6! - x^2 * (1/8!))))
+     */
+
+    /* Start with 0, compiler will optimize this away */
+    result = 0;
+
+#if (PRECISION >= 10)
+    result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*19*20);
+    result *= x2;
+#endif
+#if (PRECISION >= 9)
+    result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18);
+    result *= x2;
+#endif
+#if (PRECISION >= 8)
+    result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16);
+    result *= x2;
+#endif
+#if (PRECISION >= 7)
+    result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14);
+    result *= x2;
+#endif
+#if (PRECISION >= 6)
+    result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12);
+    result *= x2;
+#endif
+#if (PRECISION >= 5)
+    result += 1./(1.*2*3*4*5*6*7*8*9*10);
+    result *= x2;
+#endif
+    result += 1./(1.*2*3*4*5*6*7*8);
+    result *= x2;
+
+    result += 1./(1.*2*3*4*5*6);
+    result *= x2;
+
+    result += 1./(1.*2*3*4);
+    result *= x2;
+
+    result += 1./(1.*2);
+    result *= x2;
+
+    result += 1;
+
+    /* Apply correct sign */
+    result *= sin_sign_tbl[quadrant];
+
+    return result;
+}
diff --git a/reactos/lib/sdk/crt/math/sinf.c b/reactos/lib/sdk/crt/math/sinf.c
new file mode 100644 (file)
index 0000000..1069dcf
--- /dev/null
@@ -0,0 +1,11 @@
+/**
+ * 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 sinf(float _X)
+{
+  return ((float) sin ((double) _X));
+}