https://git.reactos.org/?p=reactos.git;a=commitdiff;h=15c9f63b659fbd3d688e4f22e925fe89d656304f

commit 15c9f63b659fbd3d688e4f22e925fe89d656304f
Author:     Jérôme Gardou <[email protected]>
AuthorDate: Fri Nov 6 21:39:00 2020 +0100
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Mon Nov 16 16:58:10 2020 +0100

    [MSVCRTEX] Add some floating point functions for CLang build
    
    Clang makes optimisations requiring functions not present in msvcrt
---
 sdk/lib/crt/math/i386/exp2_asm.s | 38 ++++++++++++++++++++++++++++++++++++++
 sdk/lib/crt/msvcrtex.cmake       |  9 +++++++++
 2 files changed, 47 insertions(+)

diff --git a/sdk/lib/crt/math/i386/exp2_asm.s b/sdk/lib/crt/math/i386/exp2_asm.s
new file mode 100644
index 00000000000..d2ab14d63b1
--- /dev/null
+++ b/sdk/lib/crt/math/i386/exp2_asm.s
@@ -0,0 +1,38 @@
+#include <asm.inc>
+
+PUBLIC _exp2
+
+/* FUNCTIONS ***************************************************************/
+.code
+
+_exp2:
+    push ebp
+    mov ebp, esp
+
+    fld qword ptr [ebp + 8]
+    fxam
+    fstsw ax
+    fwait
+    sahf
+    jnp .not_inf
+    jnc .not_inf
+    test ah, 2
+    jz .done
+    fstp st
+    fldz
+    jmp .done
+.not_inf:
+    fst st(1)
+    frndint
+    fxch st(1)
+    fsub st, st(1)
+    f2xm1
+    fld1
+    faddp st(1), st
+    fscale
+    fstp st(1)
+.done:
+    pop ebp
+    ret
+
+END
diff --git a/sdk/lib/crt/msvcrtex.cmake b/sdk/lib/crt/msvcrtex.cmake
index 593622e277d..0b6bff8520d 100644
--- a/sdk/lib/crt/msvcrtex.cmake
+++ b/sdk/lib/crt/msvcrtex.cmake
@@ -58,6 +58,15 @@ if(ARCH STREQUAL "i386")
         math/i386/cipow.c
         math/i386/cisin.c
         math/i386/cisqrt.c)
+    if (GCC AND CLANG)
+        # CLang performs some optimisations requiring those funtions
+        list(APPEND MSVCRTEX_ASM_SOURCE
+            math/i386/ceilf.S
+            math/i386/exp2_asm.s
+            math/i386/floorf.S)
+        list(APPEND MSVCRTEX_SOURCE
+            math/i386/sqrtf.c)
+    endif()
 elseif(ARCH STREQUAL "amd64")
     list(APPEND MSVCRTEX_ASM_SOURCE
         except/amd64/chkstk_ms.s)

Reply via email to