[CRT] Replace amd64 math functions/stubs with libm

This commit is contained in:
Timo Kreuzer 2022-08-23 17:37:14 +03:00
parent 20e6e17070
commit 28c41b7d22
15 changed files with 115 additions and 276 deletions

View file

@ -1,17 +0,0 @@
#include <asm.inc>
.code64
PUBLIC _logb
FUNC _logb
.endprolog
fld dword ptr [rsp + 8]
fxtract
fstp st
ret
ENDFUNC
END

View file

@ -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

View file

@ -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@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <asm.inc>
/* CODE **********************************************************************/
.code64
PUBLIC acos
acos:
UNIMPLEMENTED acos
ret
END

View file

@ -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@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <asm.inc>
/* CODE **********************************************************************/
.code64
PUBLIC acosf
acosf:
UNIMPLEMENTED acos
ret
END

View file

@ -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@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <asm.inc>
#include <ksamd64.inc>
/* CODE **********************************************************************/
.code64
PUBLIC atan
atan:
UNIMPLEMENTED atan
ret
END

View file

@ -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@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <asm.inc>
#include <ksamd64.inc>
/* CODE **********************************************************************/
.code64
PUBLIC atan2
atan2:
UNIMPLEMENTED atan2
ret
END

View file

@ -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@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <asm.inc>
#include <ksamd64.inc>
/* CODE **********************************************************************/
.code64
PUBLIC exp
exp:
UNIMPLEMENTED exp
ret
END

View file

@ -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@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <asm.inc>
/* CODE **********************************************************************/
.code64
PUBLIC ldexp
ldexp:
UNIMPLEMENTED ldexp
ret
END

View file

@ -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@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <asm.inc>
/* CODE **********************************************************************/
.code64
PUBLIC log
log:
UNIMPLEMENTED log
ret
END

View file

@ -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@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <asm.inc>
/* CODE **********************************************************************/
.code64
PUBLIC log10
log10:
UNIMPLEMENTED log10
ret
END

View file

@ -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@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <asm.inc>
#include <ksamd64.inc>
/* CODE **********************************************************************/
.code64
PUBLIC pow
pow:
UNIMPLEMENTED pow
ret
END

View file

@ -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@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <asm.inc>
#include <ksamd64.inc>
/* CODE **********************************************************************/
.code64
PUBLIC tan
tan:
UNIMPLEMENTED tan
ret
END

View file

@ -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

View file

@ -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

View file

@ -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)