summaryrefslogtreecommitdiff
path: root/src/VBox/Runtime
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2022-08-05 12:22:06 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2022-08-05 12:22:06 +0000
commitc21dad8fa4cc9c6792eb45d66fe7774cb73229c5 (patch)
tree394d13ffb5a0e12247a008581b55fbc8fcd3e377 /src/VBox/Runtime
parent5d8b20698b85e17a481254928d714e15f9bfac18 (diff)
downloadVirtualBox-svn-c21dad8fa4cc9c6792eb45d66fe7774cb73229c5.tar.gz
IPRT/nocrt: Make use of existing floating point assembly code, morphing it into double and float variants where those were missing. bugref:10261
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@96060 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/Runtime')
-rw-r--r--src/VBox/Runtime/Makefile.kmk62
-rw-r--r--src/VBox/Runtime/common/math/ceil.asm69
-rw-r--r--src/VBox/Runtime/common/math/ceilf.asm69
-rw-r--r--src/VBox/Runtime/common/math/cos.asm71
-rw-r--r--src/VBox/Runtime/common/math/cosf.asm71
-rw-r--r--src/VBox/Runtime/common/math/ldexp.asm69
-rw-r--r--src/VBox/Runtime/common/math/ldexpf.asm69
-rw-r--r--src/VBox/Runtime/common/math/log.asm76
-rw-r--r--src/VBox/Runtime/common/math/logf.asm76
-rw-r--r--src/VBox/Runtime/common/math/sin.asm71
-rw-r--r--src/VBox/Runtime/common/math/sinf.asm71
-rw-r--r--src/VBox/Runtime/common/math/tan.asm72
-rw-r--r--src/VBox/Runtime/common/math/tanf.asm72
13 files changed, 917 insertions, 1 deletions
diff --git a/src/VBox/Runtime/Makefile.kmk b/src/VBox/Runtime/Makefile.kmk
index 3f35524470c..70fc25c84a8 100644
--- a/src/VBox/Runtime/Makefile.kmk
+++ b/src/VBox/Runtime/Makefile.kmk
@@ -1810,7 +1810,32 @@ ifdef VBOX_WITH_NOCRT_STATIC
r3/nocrt-per-thread-1.cpp \
r3/nocrt-per-thread-2.cpp \
r3/nocrt-errno.cpp
+
RuntimeR3_SOURCES.x86 = $(RuntimeBaseR3_SOURCES.x86) \
+ common/math/cos.asm \
+ common/math/cosf.asm \
+ common/math/ceil.asm \
+ common/math/ceilf.asm \
+ common/math/fabs.asm \
+ common/math/fabsf.asm \
+ common/math/floor.asm \
+ common/math/floorf.asm \
+ common/math/ldexp.asm \
+ common/math/ldexpf.asm \
+ common/math/log.asm \
+ common/math/logf.asm \
+ common/math/llrint.asm \
+ common/math/llrintf.asm \
+ common/math/lrint.asm \
+ common/math/lrintf.asm \
+ common/math/remainder.asm \
+ common/math/remainderf.asm \
+ common/math/sin.asm \
+ common/math/sinf.asm \
+ common/math/tan.asm \
+ common/math/tanf.asm \
+ common/math/trunc.asm \
+ common/math/truncf.asm \
common/misc/setjmp.asm \
common/string/memcpy.asm \
common/string/memchr.asm \
@@ -1831,6 +1856,30 @@ ifdef VBOX_WITH_NOCRT_STATIC
common/string/strcspn.cpp \
common/string/strpbrk.cpp
RuntimeR3_SOURCES.amd64 = $(RuntimeBaseR3_SOURCES.amd64) \
+ common/math/cos.asm \
+ common/math/cosf.asm \
+ common/math/ceil.asm \
+ common/math/ceilf.asm \
+ common/math/fabs.asm \
+ common/math/fabsf.asm \
+ common/math/floor.asm \
+ common/math/floorf.asm \
+ common/math/ldexp.asm \
+ common/math/ldexpf.asm \
+ common/math/log.asm \
+ common/math/logf.asm \
+ common/math/llrint.asm \
+ common/math/llrintf.asm \
+ common/math/lrint.asm \
+ common/math/lrintf.asm \
+ common/math/remainder.asm \
+ common/math/remainderf.asm \
+ common/math/sin.asm \
+ common/math/sinf.asm \
+ common/math/tan.asm \
+ common/math/tanf.asm \
+ common/math/trunc.asm \
+ common/math/truncf.asm \
common/misc/setjmp.asm \
common/string/memcpy.asm \
common/string/memchr.asm \
@@ -1880,7 +1929,18 @@ ifdef VBOX_WITH_NOCRT_STATIC
r3/win/nocrt-WinMainCRTStartup-win.asm \
common/compiler/vcc/guard-vcc.asm \
common/compiler/vcc/stack-vcc.asm
- RuntimeR3_VBOX_NOCRT_ALIASES.win = strtok_s=nocrt_strtok_r _strtok_s=nocrt_strtok_r nocrt_strtok_s=nocrt_strtok_r
+ RuntimeR3_VBOX_NOCRT_ALIASES.win = strtok_s=nocrt_strtok_r _strtok_s=nocrt_strtok_r nocrt_strtok_s=nocrt_strtok_r \
+ cosl=nocrt_cos _cosl=nocrt_cos \
+ ceill=nocrt_ceil _ceill=nocrt_ceil \
+ fabsl=nocrt_fabs _fabsl=nocrt_fabs \
+ floorl=nocrt_floor _floorl=nocrt_floor \
+ ldexpl=nocrt_ldexp _ldexpl=nocrt_ldexp \
+ logl=nocrt_log _logl=nocrt_log \
+ lrintl=nocrt_lrint _lrintl=nocrt_lrint \
+ llrintl=nocrt_llrint _llrintl=nocrt_llrint \
+ remainderl=nocrt_remainder _remainderl=nocrt_remainder \
+ sinl=nocrt_sin _sinl=nocrt_sin \
+ tanl=nocrt_tan _tanl=nocrt_tan
endif
endif
diff --git a/src/VBox/Runtime/common/math/ceil.asm b/src/VBox/Runtime/common/math/ceil.asm
new file mode 100644
index 00000000000..3e507c60ac1
--- /dev/null
+++ b/src/VBox/Runtime/common/math/ceil.asm
@@ -0,0 +1,69 @@
+; $Id$
+;; @file
+; IPRT - No-CRT ceil - AMD64 & X86.
+;
+
+;
+; Copyright (C) 2006-2022 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Compute the smallest integral value not less than lrd.
+; @returns st(0) / xmm0
+; @param rd [rbp + 8] / xmm0
+RT_NOCRT_BEGINPROC ceil
+ push xBP
+ mov xBP, xSP
+ sub xSP, 10h
+
+%ifdef RT_ARCH_AMD64 ;; @todo there is probably some sse instruction for this.
+ movsd [xSP], xmm0
+ fld qword [xSP]
+%else
+ fld qword [xBP + xCB*2]
+%endif
+
+ ; Make it round up by modifying the fpu control word.
+ fstcw [xBP - 10h]
+ mov eax, [xBP - 10h]
+ or eax, 00800h
+ and eax, 0fbffh
+ mov [xBP - 08h], eax
+ fldcw [xBP - 08h]
+
+ ; Round ST(0) to integer.
+ frndint
+
+ ; Restore the fpu control word.
+ fldcw [xBP - 10h]
+
+%ifdef RT_ARCH_AMD64
+ fstp qword [xSP]
+ movsd xmm0, [xSP]
+%endif
+ leave
+ ret
+ENDPROC RT_NOCRT(ceil)
+
diff --git a/src/VBox/Runtime/common/math/ceilf.asm b/src/VBox/Runtime/common/math/ceilf.asm
new file mode 100644
index 00000000000..199452f18b1
--- /dev/null
+++ b/src/VBox/Runtime/common/math/ceilf.asm
@@ -0,0 +1,69 @@
+; $Id$
+;; @file
+; IPRT - No-CRT ceilf - AMD64 & X86.
+;
+
+;
+; Copyright (C) 2006-2022 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Compute the smallest integral value not less than r32.
+; @returns st(0) / xmm0
+; @param r32 [rbp + 8] / xmm0
+RT_NOCRT_BEGINPROC ceilf
+ push xBP
+ mov xBP, xSP
+ sub xSP, 10h
+
+%ifdef RT_ARCH_AMD64 ;; @todo there is probably some sse instruction for this.
+ movss [xSP], xmm0
+ fld dword [xSP]
+%else
+ fld dword [xBP + xCB*2]
+%endif
+
+ ; Make it round up by modifying the fpu control word.
+ fstcw [xBP - 10h]
+ mov eax, [xBP - 10h]
+ or eax, 00800h
+ and eax, 0fbffh
+ mov [xBP - 08h], eax
+ fldcw [xBP - 08h]
+
+ ; Round ST(0) to integer.
+ frndint
+
+ ; Restore the fpu control word.
+ fldcw [xBP - 10h]
+
+%ifdef RT_ARCH_AMD64
+ fstp dword [xSP]
+ movss xmm0, [xSP]
+%endif
+ leave
+ ret
+ENDPROC RT_NOCRT(ceilf)
+
diff --git a/src/VBox/Runtime/common/math/cos.asm b/src/VBox/Runtime/common/math/cos.asm
new file mode 100644
index 00000000000..0ee79d101db
--- /dev/null
+++ b/src/VBox/Runtime/common/math/cos.asm
@@ -0,0 +1,71 @@
+; $Id$
+;; @file
+; IPRT - No-CRT cos - AMD64 & X86.
+;
+
+;
+; Copyright (C) 2006-2022 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; compute the cosine of dr, measured in radians.
+; @returns st(0) / xmm0
+; @param rd [rbp + xCB*2] / xmm0
+RT_NOCRT_BEGINPROC cos
+ push xBP
+ mov xBP, xSP
+%ifdef RT_ARCH_AMD64
+ sub xSP, 10h
+
+ movsd [xSP], xmm0
+ fld qword [xSP]
+%else
+ fld qword [xBP + xCB*2]
+%endif
+ fcos
+ fnstsw ax
+ test ah, 4
+ jz .done
+
+ fldpi
+ fadd st0, st0
+ fxch st1
+.again:
+ fprem1
+ fnstsw ax
+ test ah, 4
+ jnz .again
+
+ fstp st0
+ fcos
+
+.done:
+%ifdef RT_ARCH_AMD64
+ fstp qword [xSP]
+ movsd xmm0, [xSP]
+%endif
+ leave
+ ret
+ENDPROC RT_NOCRT(cos)
+
diff --git a/src/VBox/Runtime/common/math/cosf.asm b/src/VBox/Runtime/common/math/cosf.asm
new file mode 100644
index 00000000000..51f070f6187
--- /dev/null
+++ b/src/VBox/Runtime/common/math/cosf.asm
@@ -0,0 +1,71 @@
+; $Id$
+;; @file
+; IPRT - No-CRT cosf - AMD64 & X86.
+;
+
+;
+; Copyright (C) 2006-2022 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; compute the cosine of r32, measured in radians.
+; @returns st(0) / xmm0
+; @param r32 [rbp + xCB*2] / xmm0
+RT_NOCRT_BEGINPROC cosf
+ push xBP
+ mov xBP, xSP
+%ifdef RT_ARCH_AMD64
+ sub xSP, 10h
+
+ movss [xSP], xmm0
+ fld dword [xSP]
+%else
+ fld dword [xBP + xCB*2]
+%endif
+ fcos
+ fnstsw ax
+ test ah, 4
+ jz .done
+
+ fldpi
+ fadd st0, st0
+ fxch st1
+.again:
+ fprem1
+ fnstsw ax
+ test ah, 4
+ jnz .again
+
+ fstp st0
+ fcos
+
+.done:
+%ifdef RT_ARCH_AMD64
+ fstp dword [xSP]
+ movss xmm0, [xSP]
+%endif
+ leave
+ ret
+ENDPROC RT_NOCRT(cosf)
+
diff --git a/src/VBox/Runtime/common/math/ldexp.asm b/src/VBox/Runtime/common/math/ldexp.asm
new file mode 100644
index 00000000000..5cade5fa2e0
--- /dev/null
+++ b/src/VBox/Runtime/common/math/ldexp.asm
@@ -0,0 +1,69 @@
+; $Id$
+;; @file
+; IPRT - No-CRT ldexp - AMD64 & X86.
+;
+
+;
+; Copyright (C) 2006-2022 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Computes rd * 2^exp
+; @returns st(0) / xmm0
+; @param rd [rbp + xCB*2] / xmm0
+; @param exp [ebp + 10h] gcc:edi msc:ecx
+RT_NOCRT_BEGINPROC ldexp
+ push xBP
+ mov xBP, xSP
+%ifdef RT_ARCH_AMD64
+ sub xSP, 20h
+%else
+ sub xSP, 10h
+%endif
+
+ ; load exp
+%ifdef RT_ARCH_AMD64
+ %ifdef ASM_CALL64_GCC
+ mov [rsp], edi
+ %else
+ mov [rsp], ecx
+ %endif
+ fild dword [rsp]
+ movsd [rsp + 8], xmm0
+ fld qword [rsp + 8]
+%else
+ fild dword [ebp + xCB*2 + 8]
+ fld qword [xBP + xCB*2]
+%endif
+ fscale
+ fstp st1
+
+%ifdef RT_ARCH_AMD64
+ fstp qword [xSP]
+ movsd xmm0, [xSP]
+%endif
+ leave
+ ret
+ENDPROC RT_NOCRT(ldexp)
+
diff --git a/src/VBox/Runtime/common/math/ldexpf.asm b/src/VBox/Runtime/common/math/ldexpf.asm
new file mode 100644
index 00000000000..f79c7384b26
--- /dev/null
+++ b/src/VBox/Runtime/common/math/ldexpf.asm
@@ -0,0 +1,69 @@
+; $Id$
+;; @file
+; IPRT - No-CRT ldexpf - AMD64 & X86.
+;
+
+;
+; Copyright (C) 2006-2022 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Computes r32 * 2^exp
+; @returns st(0) / xmm0
+; @param r32 [rbp + xCB*2] / xmm0
+; @param exp [ebp + 10h] gcc:edi msc:ecx
+RT_NOCRT_BEGINPROC ldexpf
+ push xBP
+ mov xBP, xSP
+%ifdef RT_ARCH_AMD64
+ sub xSP, 20h
+%else
+ sub xSP, 10h
+%endif
+
+ ; load exp
+%ifdef RT_ARCH_AMD64
+ %ifdef ASM_CALL64_GCC
+ mov [rsp], edi
+ %else
+ mov [rsp], ecx
+ %endif
+ fild dword [rsp]
+ movss [rsp + 8], xmm0
+ fld dword [rsp + 8]
+%else
+ fild dword [ebp + xCB*2 + 8]
+ fld dword [xBP + xCB*2]
+%endif
+ fscale
+ fstp st1
+
+%ifdef RT_ARCH_AMD64
+ fstp dword [xSP]
+ movss xmm0, [xSP]
+%endif
+ leave
+ ret
+ENDPROC RT_NOCRT(ldexpf)
+
diff --git a/src/VBox/Runtime/common/math/log.asm b/src/VBox/Runtime/common/math/log.asm
new file mode 100644
index 00000000000..8d84da3a5dc
--- /dev/null
+++ b/src/VBox/Runtime/common/math/log.asm
@@ -0,0 +1,76 @@
+; $Id$
+;; @file
+; IPRT - No-CRT log - AMD64 & X86.
+;
+
+;
+; Copyright (C) 2006-2022 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; compute the natural logarithm of rd
+; @returns st(0) / xmm0
+; @param rd [rbp + xCB*2] / xmm0
+RT_NOCRT_BEGINPROC log
+ push xBP
+ mov xBP, xSP
+%ifdef RT_ARCH_AMD64
+ sub xSP, 10h
+%endif
+
+ fldln2 ; st0=log(2)
+%ifdef RT_ARCH_AMD64
+ movsd [xSP], xmm0
+ fld qword [xSP]
+%else
+ fld qword [xBP + xCB*2] ; st1=log(2) st0=lrd
+%endif
+ fld st0 ; st1=log(2) st0=lrd st0=lrd
+ fsub qword [.one xWrtRIP] ; st2=log(2) st1=lrd st0=lrd-1.0
+ fld st0 ; st3=log(2) st2=lrd st1=lrd-1.0 st0=lrd-1.0
+ fabs ; st3=log(2) st2=lrd st1=lrd-1.0 st0=abs(lrd-1.0)
+ fcomp qword [.limit xWrtRIP] ; st2=log(2) st1=lrd st0=lrd-1.0
+ fnstsw ax
+ and eax, 04500h
+ jnz .use_st1
+
+ fstp st0 ; st1=log(2) st0=lrd
+ fyl2x ; log(lrd)
+ jmp .done
+
+.use_st1:
+ fstp st1 ; st1=log(2) st0=lrd-1.0
+ fyl2xp1 ; log(lrd)
+
+.done:
+%ifdef RT_ARCH_AMD64
+ fstp qword [xSP]
+ movsd xmm0, [xSP]
+%endif
+ leave
+ ret
+.one: dq 1.0
+.limit: dq 0.29
+ENDPROC RT_NOCRT(log)
+
diff --git a/src/VBox/Runtime/common/math/logf.asm b/src/VBox/Runtime/common/math/logf.asm
new file mode 100644
index 00000000000..2bebe9e7631
--- /dev/null
+++ b/src/VBox/Runtime/common/math/logf.asm
@@ -0,0 +1,76 @@
+; $Id$
+;; @file
+; IPRT - No-CRT logf - AMD64 & X86.
+;
+
+;
+; Copyright (C) 2006-2022 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; compute the natural logarithm of r32
+; @returns st(0) / xmm0
+; @param r32 [rbp + xCB*2] / xmm0
+RT_NOCRT_BEGINPROC logf
+ push xBP
+ mov xBP, xSP
+%ifdef RT_ARCH_AMD64
+ sub xSP, 10h
+%endif
+
+ fldln2 ; st0=log(2)
+%ifdef RT_ARCH_AMD64
+ movss [xSP], xmm0
+ fld dword [xSP]
+%else
+ fld dword [xBP + xCB*2] ; st1=log(2) st0=lrd
+%endif
+ fld st0 ; st1=log(2) st0=lrd st0=lrd
+ fsub qword [.one xWrtRIP] ; st2=log(2) st1=lrd st0=lrd-1.0
+ fld st0 ; st3=log(2) st2=lrd st1=lrd-1.0 st0=lrd-1.0
+ fabs ; st3=log(2) st2=lrd st1=lrd-1.0 st0=abs(lrd-1.0)
+ fcomp qword [.limit xWrtRIP] ; st2=log(2) st1=lrd st0=lrd-1.0
+ fnstsw ax
+ and eax, 04500h
+ jnz .use_st1
+
+ fstp st0 ; st1=log(2) st0=lrd
+ fyl2x ; log(lrd)
+ jmp .done
+
+.use_st1:
+ fstp st1 ; st1=log(2) st0=lrd-1.0
+ fyl2xp1 ; log(lrd)
+
+.done:
+%ifdef RT_ARCH_AMD64
+ fstp dword [xSP]
+ movss xmm0, [xSP]
+%endif
+ leave
+ ret
+.one: dq 1.0
+.limit: dq 0.29
+ENDPROC RT_NOCRT(logf)
+
diff --git a/src/VBox/Runtime/common/math/sin.asm b/src/VBox/Runtime/common/math/sin.asm
new file mode 100644
index 00000000000..7178a7696f7
--- /dev/null
+++ b/src/VBox/Runtime/common/math/sin.asm
@@ -0,0 +1,71 @@
+; $Id$
+;; @file
+; IPRT - No-CRT sin - AMD64 & X86.
+;
+
+;
+; Copyright (C) 2006-2022 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Compute the sine of rd
+; @returns st(0)/xmm0
+; @param rd [xSP + xCB*2] / xmm0
+RT_NOCRT_BEGINPROC sin
+ push xBP
+ mov xBP, xSP
+
+%ifdef RT_ARCH_AMD64
+ sub xSP, 10h
+
+ movsd [xSP], xmm0
+ fld qword [xSP]
+%else
+ fld qword [xBP + xCB*2]
+%endif
+ fsin
+ fnstsw ax
+ test ah, 04h
+ jz .done
+
+ fldpi
+ fadd st0
+ fxch st1
+.again:
+ fprem1
+ fnstsw ax
+ test ah, 04h
+ jnz .again
+ fstp st1
+ fsin
+
+.done:
+%ifdef RT_ARCH_AMD64
+ fstp qword [xSP]
+ movsd xmm0, [xSP]
+%endif
+ leave
+ ret
+ENDPROC RT_NOCRT(sin)
+
diff --git a/src/VBox/Runtime/common/math/sinf.asm b/src/VBox/Runtime/common/math/sinf.asm
new file mode 100644
index 00000000000..f906f33b757
--- /dev/null
+++ b/src/VBox/Runtime/common/math/sinf.asm
@@ -0,0 +1,71 @@
+; $Id$
+;; @file
+; IPRT - No-CRT sinf - AMD64 & X86.
+;
+
+;
+; Copyright (C) 2006-2022 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Compute the sine of r32
+; @returns st(0)/xmm0
+; @param r32 [xSP + xCB*2] / xmm0
+RT_NOCRT_BEGINPROC sinf
+ push xBP
+ mov xBP, xSP
+
+%ifdef RT_ARCH_AMD64
+ sub xSP, 10h
+
+ movss [xSP], xmm0
+ fld dword [xSP]
+%else
+ fld dword [xBP + xCB*2]
+%endif
+ fsin
+ fnstsw ax
+ test ah, 04h
+ jz .done
+
+ fldpi
+ fadd st0
+ fxch st1
+.again:
+ fprem1
+ fnstsw ax
+ test ah, 04h
+ jnz .again
+ fstp st1
+ fsin
+
+.done:
+%ifdef RT_ARCH_AMD64
+ fstp dword [xSP]
+ movss xmm0, [xSP]
+%endif
+ leave
+ ret
+ENDPROC RT_NOCRT(sinf)
+
diff --git a/src/VBox/Runtime/common/math/tan.asm b/src/VBox/Runtime/common/math/tan.asm
new file mode 100644
index 00000000000..2d8710a7205
--- /dev/null
+++ b/src/VBox/Runtime/common/math/tan.asm
@@ -0,0 +1,72 @@
+; $Id$
+;; @file
+; IPRT - No-CRT tan - AMD64 & X86.
+;
+
+;
+; Copyright (C) 2006-2022 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Compute the sine of rd
+; @returns st(0) / xmm0
+; @param rd [xSP + xCB*2] / xmm0
+RT_NOCRT_BEGINPROC tan
+ push xBP
+ mov xBP, xSP
+
+%ifdef RT_ARCH_AMD64
+ sub xSP, 10h
+
+ movsd [xSP], xmm0
+ fld qword [xSP]
+%else
+ fld qword [xBP + xCB*2]
+%endif
+ fptan
+ fnstsw ax
+ test ah, 04h ; check for C2
+ jz .done
+
+ fldpi
+ fadd st0
+ fxch st1
+.again:
+ fprem1
+ fnstsw ax
+ test ah, 04h
+ jnz .again
+ fstp st1
+ fptan
+
+.done:
+ fstp st0
+%ifdef RT_ARCH_AMD64
+ fstp qword [xSP]
+ movsd xmm0, [xSP]
+%endif
+ leave
+ ret
+ENDPROC RT_NOCRT(tan)
+
diff --git a/src/VBox/Runtime/common/math/tanf.asm b/src/VBox/Runtime/common/math/tanf.asm
new file mode 100644
index 00000000000..da3c7e4d082
--- /dev/null
+++ b/src/VBox/Runtime/common/math/tanf.asm
@@ -0,0 +1,72 @@
+; $Id$
+;; @file
+; IPRT - No-CRT tanf - AMD64 & X86.
+;
+
+;
+; Copyright (C) 2006-2022 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+; The contents of this file may alternatively be used under the terms
+; of the Common Development and Distribution License Version 1.0
+; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+; VirtualBox OSE distribution, in which case the provisions of the
+; CDDL are applicable instead of those of the GPL.
+;
+; You may elect to license modified versions of this file under the
+; terms and conditions of either the GPL or the CDDL or both.
+;
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Compute the sine of r32
+; @returns st(0) / xmm0
+; @param r32 [xSP + xCB*2] / xmm0
+RT_NOCRT_BEGINPROC tanf
+ push xBP
+ mov xBP, xSP
+
+%ifdef RT_ARCH_AMD64
+ sub xSP, 10h
+
+ movss [xSP], xmm0
+ fld dword [xSP]
+%else
+ fld dword [xBP + xCB*2]
+%endif
+ fptan
+ fnstsw ax
+ test ah, 04h ; check for C2
+ jz .done
+
+ fldpi
+ fadd st0
+ fxch st1
+.again:
+ fprem1
+ fnstsw ax
+ test ah, 04h
+ jnz .again
+ fstp st1
+ fptan
+
+.done:
+ fstp st0
+%ifdef RT_ARCH_AMD64
+ fstp dword [xSP]
+ movss xmm0, [xSP]
+%endif
+ leave
+ ret
+ENDPROC RT_NOCRT(tanf)
+