https://git.reactos.org/?p=reactos.git;a=commitdiff;h=28c41b7d22130aeac1202…
commit 28c41b7d22130aeac1202026e68365a85674587d
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Tue Aug 23 17:37:14 2022 +0300
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Thu Dec 1 15:21:59 2022 +0200
[CRT] Replace amd64 math functions/stubs with libm
---
sdk/lib/crt/float/amd64/logb.S | 17 ----
sdk/lib/crt/float/float.cmake | 1 -
sdk/lib/crt/math/amd64/acos.S | 21 -----
sdk/lib/crt/math/amd64/acosf.S | 21 -----
sdk/lib/crt/math/amd64/atan.S | 22 -----
sdk/lib/crt/math/amd64/atan2.S | 22 -----
sdk/lib/crt/math/amd64/exp.S | 22 -----
sdk/lib/crt/math/amd64/ldexp.S | 21 -----
sdk/lib/crt/math/amd64/log.S | 21 -----
sdk/lib/crt/math/amd64/log10.S | 21 -----
sdk/lib/crt/math/amd64/pow.S | 22 -----
sdk/lib/crt/math/amd64/tan.S | 22 -----
sdk/lib/crt/math/libm_sse2/fmod.asm | 1 +
sdk/lib/crt/math/libm_sse2/fmodf.asm | 1 +
sdk/lib/crt/math/math.cmake | 156 +++++++++++++++++++++++++----------
15 files changed, 115 insertions(+), 276 deletions(-)
diff --git a/sdk/lib/crt/float/amd64/logb.S b/sdk/lib/crt/float/amd64/logb.S
deleted file mode 100644
index 2cb4bb886ec..00000000000
--- a/sdk/lib/crt/float/amd64/logb.S
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-#include <asm.inc>
-
-.code64
-
-PUBLIC _logb
-FUNC _logb
- .endprolog
-
- fld dword ptr [rsp + 8]
- fxtract
- fstp st
- ret
-ENDFUNC
-
-END
diff --git a/sdk/lib/crt/float/float.cmake b/sdk/lib/crt/float/float.cmake
index e4189362f64..24fe327fbd5 100644
--- a/sdk/lib/crt/float/float.cmake
+++ b/sdk/lib/crt/float/float.cmake
@@ -32,7 +32,6 @@ elseif(ARCH STREQUAL "amd64")
)
list(APPEND CRT_FLOAT_ASM_SOURCE
float/amd64/getsetfpcw.S
- float/amd64/logb.S
)
elseif(ARCH STREQUAL "arm")
list(APPEND CRT_FLOAT_SOURCE
diff --git a/sdk/lib/crt/math/amd64/acos.S b/sdk/lib/crt/math/amd64/acos.S
deleted file mode 100644
index 23a90493d6d..00000000000
--- a/sdk/lib/crt/math/amd64/acos.S
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS system libraries
- * PURPOSE: Implementation of acos
- * FILE: lib/sdk/crt/math/amd64/acos.S
- * PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)reactos.org)
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <asm.inc>
-
-/* CODE **********************************************************************/
-.code64
-
-PUBLIC acos
-acos:
- UNIMPLEMENTED acos
- ret
-
-END
diff --git a/sdk/lib/crt/math/amd64/acosf.S b/sdk/lib/crt/math/amd64/acosf.S
deleted file mode 100644
index fab952692bf..00000000000
--- a/sdk/lib/crt/math/amd64/acosf.S
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS system libraries
- * PURPOSE: Implementation of acosf
- * FILE: lib/sdk/crt/math/amd64/acosf.S
- * PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)reactos.org)
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <asm.inc>
-
-/* CODE **********************************************************************/
-.code64
-
-PUBLIC acosf
-acosf:
- UNIMPLEMENTED acos
- ret
-
-END
diff --git a/sdk/lib/crt/math/amd64/atan.S b/sdk/lib/crt/math/amd64/atan.S
deleted file mode 100644
index b649ec0398a..00000000000
--- a/sdk/lib/crt/math/amd64/atan.S
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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(a)reactos.org)
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <asm.inc>
-#include <ksamd64.inc>
-
-/* CODE **********************************************************************/
-.code64
-
-PUBLIC atan
-atan:
- UNIMPLEMENTED atan
- ret
-
-END
diff --git a/sdk/lib/crt/math/amd64/atan2.S b/sdk/lib/crt/math/amd64/atan2.S
deleted file mode 100644
index bccaeaf9a3d..00000000000
--- a/sdk/lib/crt/math/amd64/atan2.S
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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(a)reactos.org)
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <asm.inc>
-#include <ksamd64.inc>
-
-/* CODE **********************************************************************/
-.code64
-
-PUBLIC atan2
-atan2:
- UNIMPLEMENTED atan2
- ret
-
-END
diff --git a/sdk/lib/crt/math/amd64/exp.S b/sdk/lib/crt/math/amd64/exp.S
deleted file mode 100644
index 8fda82ba07b..00000000000
--- a/sdk/lib/crt/math/amd64/exp.S
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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(a)reactos.org)
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <asm.inc>
-#include <ksamd64.inc>
-
-/* CODE **********************************************************************/
-.code64
-
-PUBLIC exp
-exp:
- UNIMPLEMENTED exp
- ret
-
-END
diff --git a/sdk/lib/crt/math/amd64/ldexp.S b/sdk/lib/crt/math/amd64/ldexp.S
deleted file mode 100644
index 4635d754e27..00000000000
--- a/sdk/lib/crt/math/amd64/ldexp.S
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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(a)reactos.org)
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <asm.inc>
-
-/* CODE **********************************************************************/
-.code64
-
-PUBLIC ldexp
-ldexp:
- UNIMPLEMENTED ldexp
- ret
-
-END
diff --git a/sdk/lib/crt/math/amd64/log.S b/sdk/lib/crt/math/amd64/log.S
deleted file mode 100644
index f7ffc57f612..00000000000
--- a/sdk/lib/crt/math/amd64/log.S
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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(a)reactos.org)
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <asm.inc>
-
-/* CODE **********************************************************************/
-.code64
-
-PUBLIC log
-log:
- UNIMPLEMENTED log
- ret
-
-END
diff --git a/sdk/lib/crt/math/amd64/log10.S b/sdk/lib/crt/math/amd64/log10.S
deleted file mode 100644
index 5038d178530..00000000000
--- a/sdk/lib/crt/math/amd64/log10.S
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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(a)reactos.org)
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <asm.inc>
-
-/* CODE **********************************************************************/
-.code64
-
-PUBLIC log10
-log10:
- UNIMPLEMENTED log10
- ret
-
-END
diff --git a/sdk/lib/crt/math/amd64/pow.S b/sdk/lib/crt/math/amd64/pow.S
deleted file mode 100644
index fd8d104ee4e..00000000000
--- a/sdk/lib/crt/math/amd64/pow.S
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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(a)reactos.org)
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <asm.inc>
-#include <ksamd64.inc>
-
-/* CODE **********************************************************************/
-.code64
-
-PUBLIC pow
-pow:
- UNIMPLEMENTED pow
- ret
-
-END
diff --git a/sdk/lib/crt/math/amd64/tan.S b/sdk/lib/crt/math/amd64/tan.S
deleted file mode 100644
index 53d82877e86..00000000000
--- a/sdk/lib/crt/math/amd64/tan.S
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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(a)reactos.org)
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <asm.inc>
-#include <ksamd64.inc>
-
-/* CODE **********************************************************************/
-.code64
-
-PUBLIC tan
-tan:
- UNIMPLEMENTED tan
- ret
-
-END
diff --git a/sdk/lib/crt/math/libm_sse2/fmod.asm b/sdk/lib/crt/math/libm_sse2/fmod.asm
index 7ba554671f8..cc1fb710997 100644
--- a/sdk/lib/crt/math/libm_sse2/fmod.asm
+++ b/sdk/lib/crt/math/libm_sse2/fmod.asm
@@ -68,6 +68,7 @@ X87XAM_BAD EQU MASK X87SW_E AND NOT 2
; double fmod [double, double] ----------------------------------
+PUBLIC fmod
fmod PROC FRAME
sub rsp, 40 + 32
diff --git a/sdk/lib/crt/math/libm_sse2/fmodf.asm b/sdk/lib/crt/math/libm_sse2/fmodf.asm
index b5685d7ba0d..5e7aa2578fd 100644
--- a/sdk/lib/crt/math/libm_sse2/fmodf.asm
+++ b/sdk/lib/crt/math/libm_sse2/fmodf.asm
@@ -68,6 +68,7 @@ X87XAM_BAD EQU MASK X87SW_E AND NOT 2
; float fmodf [float, float] ------------------------------------
+PUBLIC fmodf
fmodf PROC FRAME
sub rsp, 40 + 32
diff --git a/sdk/lib/crt/math/math.cmake b/sdk/lib/crt/math/math.cmake
index 42fbc012bbe..b54c21b0a42 100644
--- a/sdk/lib/crt/math/math.cmake
+++ b/sdk/lib/crt/math/math.cmake
@@ -1,4 +1,6 @@
+include_directories(libm_sse2)
+
list(APPEND LIBCNTPR_MATH_SOURCE
math/_invoke_matherr.c
math/abs.c
@@ -54,32 +56,97 @@ if(ARCH STREQUAL "i386")
elseif(ARCH STREQUAL "amd64")
list(APPEND LIBCNTPR_MATH_SOURCE
math/amd64/_set_statfp.c
- math/ceil.c
- math/cos.c
- math/sin.c
- math/floor.c
+ # math/libm_sse2/_chgsign.c
+ # math/libm_sse2/_chgsignf.c
+ # math/libm_sse2/_copysign.c
+ # math/libm_sse2/_copysignf.c
+ # math/libm_sse2/_finite.c
+ # math/libm_sse2/_finitef.c
+ math/libm_sse2/_handle_error.c
+ math/libm_sse2/acos.c
+ math/libm_sse2/acosf.c
+ math/libm_sse2/asin.c
+ math/libm_sse2/asinf.c
+ math/libm_sse2/atan.c
+ math/libm_sse2/atan2.c
+ math/libm_sse2/atan2f.c
+ math/libm_sse2/atanf.c
+ # math/libm_sse2/cabs.c
+ # math/libm_sse2/cabsf.c
+ math/libm_sse2/ceil.c
+ math/libm_sse2/ceilf.c
+ math/libm_sse2/cosh.c
+ math/libm_sse2/coshf.c
+ math/libm_sse2/exp_special.c
+ math/libm_sse2/exp2.c
+ math/libm_sse2/floor.c
+ math/libm_sse2/floorf.c
+ math/libm_sse2/fma3_available.c
+ math/libm_sse2/hypot.c
+ math/libm_sse2/hypotf.c
+ math/libm_sse2/L2_by_pi_bits.c
+ math/libm_sse2/ldexp.c
+ # math/libm_sse2/ldexpf.c
+ math/libm_sse2/log_128_lead_tail_table.c
+ math/libm_sse2/log_256_lead_tail_table.c
+ math/libm_sse2/log_F_inv_dword_table.c
+ math/libm_sse2/log_F_inv_qword_table.c
+ math/libm_sse2/log_special.c
+ math/libm_sse2/log10_128_lead_tail_table.c
+ math/libm_sse2/log10_256_lead_tail_table.c
+ math/libm_sse2/logb.c
+ math/libm_sse2/logbf.c
+ math/libm_sse2/Lsincos_array.c
+ math/libm_sse2/Lsincosf_array.c
+ math/libm_sse2/modf.c
+ math/libm_sse2/modff.c
+ math/libm_sse2/pow_special.c
+ # math/libm_sse2/remainder.c
+ math/libm_sse2/remainder_piby2.c
+ # math/libm_sse2/remainder_piby2f.c
+ # math/libm_sse2/remainderf.c
+ math/libm_sse2/sincos_special.c
+ math/libm_sse2/sinh.c
+ math/libm_sse2/sinhf.c
+ math/libm_sse2/sqrt.c
+ math/libm_sse2/sqrtf.c
+ math/libm_sse2/tan.c
+ math/libm_sse2/tanf.c
+ math/libm_sse2/tanh.c
+ math/libm_sse2/tanhf.c
+ math/libm_sse2/two_to_jby64_head_tail_table.c
+ math/libm_sse2/two_to_jby64_table.c
)
list(APPEND LIBCNTPR_MATH_ASM_SOURCE
- math/amd64/atan.S
- math/amd64/atan2.S
- math/amd64/exp.S
+ math/libm_sse2/fm.inc
+ math/libm_sse2/cos.asm
+ math/libm_sse2/cosf.asm
+ math/libm_sse2/exp.asm
+ math/libm_sse2/expf.asm
math/amd64/fabs.S
math/amd64/fabsf.S
- math/amd64/fmod.S
- math/amd64/ldexp.S
- math/amd64/log.S
- math/amd64/log10.S
- math/amd64/pow.S
- math/amd64/sqrt.S
- math/amd64/tan.S
+ math/libm_sse2/fmod.asm
+ math/libm_sse2/fmodf.asm
+ math/libm_sse2/log.asm
+ math/libm_sse2/log10.asm
+ math/libm_sse2/pow.asm
+ math/libm_sse2/remainder_piby2_forAsm.asm
+ math/libm_sse2/remainder_piby2_forFMA3.asm
+ math/libm_sse2/remainder_piby2f_forAsm.asm
+ math/libm_sse2/remainder_piby2f_forC.asm
+ math/libm_sse2/sin.asm
+ math/libm_sse2/sinf.asm
)
elseif(ARCH STREQUAL "arm")
list(APPEND LIBCNTPR_MATH_SOURCE
math/cos.c
+ math/ceilf.c
math/fabs.c
math/fabsf.c
+ math/floorf.c
math/sin.c
math/sqrt.c
+ math/sqrtf.c
math/arm/__rt_sdiv.c
math/arm/__rt_sdiv64_worker.c
math/arm/__rt_udiv.c
@@ -96,6 +163,22 @@ elseif(ARCH STREQUAL "arm")
math/arm/__u64tos.c
math/arm/__64tof.h
)
+ list(APPEND CRT_MATH_SOURCE
+ math/_hypotf.c
+ math/acosf.c
+ math/asinf.c
+ math/atan2f.c
+ math/atanf.c
+ math/coshf.c
+ math/expf.c
+ math/fabsf.c
+ math/fmodf.c
+ math/modff.c
+ math/sinf.c
+ math/sinhf.c
+ math/tanf.c
+ math/tanhf.c
+ )
list(APPEND LIBCNTPR_MATH_ASM_SOURCE
math/arm/atan.s
math/arm/atan2.s
@@ -121,40 +204,32 @@ if(NOT ARCH STREQUAL "i386")
list(APPEND CRT_MATH_SOURCE
math/_chgsignf.c
math/_copysignf.c
- math/_hypotf.c
- math/acosf.c
- math/asinf.c
- math/atan2f.c
- math/atanf.c
- math/ceilf.c
- math/cos.c
- math/coshf.c
- math/expf.c
- math/floorf.c
- math/fmodf.c
math/log10f.c
- math/modff.c
- math/sin.c
- math/sinhf.c
- math/sqrtf.c
- math/tanf.c
- math/tanhf.c
math/stubs.c
)
endif()
+if(NOT ARCH STREQUAL "amd64")
+ list(APPEND CRT_MATH_SOURCE
+ math/acos.c
+ math/asin.c
+ math/cosh.c
+ math/cosf.c
+ math/hypot.c
+ math/modf.c
+ math/s_modf.c
+ math/sinh.c
+ math/tanh.c
+ )
+endif()
+
list(APPEND CRT_MATH_SOURCE
${LIBCNTPR_MATH_SOURCE}
- math/acos.c
math/adjust.c
- math/asin.c
math/cabs.c
- math/cosf.c
- math/cosh.c
math/fdivbug.c
math/frexp.c
math/huge_val.c
- math/hypot.c
math/ieee754/j0_y0.c
math/ieee754/j1_y1.c
math/ieee754/jn_yn.c
@@ -163,13 +238,8 @@ list(APPEND CRT_MATH_SOURCE
math/jn_yn.c
math/ldiv.c
math/logf.c
- math/modf.c
math/powf.c
math/rand.c
- math/s_modf.c
- math/sinf.c
- math/sinh.c
- math/tanh.c
)
list(APPEND CRT_MATH_ASM_SOURCE
@@ -183,7 +253,7 @@ list(APPEND LIBCNTPR_MATH_SOURCE
if(ARCH STREQUAL "i386")
list(APPEND ATAN2_ASM_SOURCE math/i386/atan2_asm.s)
elseif(ARCH STREQUAL "amd64")
- list(APPEND ATAN2_ASM_SOURCE math/amd64/atan2.S)
+ list(APPEND ATAN2_SOURCE math/_invoke_matherr.c math/amd64/_set_statfp.c
math/libm_sse2/_handle_error.c math/libm_sse2/atan2.c)
elseif(ARCH STREQUAL "arm")
list(APPEND ATAN2_ASM_SOURCE math/arm/atan2.s)
elseif(ARCH STREQUAL "arm64")
@@ -191,6 +261,6 @@ elseif(ARCH STREQUAL "arm64")
endif()
add_asm_files(atan2_asm ${ATAN2_ASM_SOURCE})
-add_library(atan2 ${atan2_asm})
+add_library(atan2 ${ATAN2_SOURCE} ${atan2_asm})
set_target_properties(atan2 PROPERTIES LINKER_LANGUAGE "C")
add_dependencies(atan2 asm)