Index: trunk/src/VBox/Runtime/Makefile.kmk
===================================================================
--- trunk/src/VBox/Runtime/Makefile.kmk	(revision 5423)
+++ trunk/src/VBox/Runtime/Makefile.kmk	(revision 5424)
@@ -574,28 +574,28 @@
 	common/misc/sanity-c.c \
 	\
-	math/ceill.asm \
-	math/cosl.asm \
-	math/fabs.asm \
-	math/fabsf.asm \
-	math/fabsl.asm \
-	math/floor.asm \
-	math/floorf.asm \
-	math/floorl.asm \
-	math/ldexpl.asm \
-	math/llrint.asm \
-	math/llrintf.asm \
-	math/llrintl.asm \
-	math/logl.asm \
-	math/lrint.asm \
-	math/lrintf.asm \
-	math/lrintl.asm \
-	math/remainder.asm \
-	math/remainderf.asm \
-	math/remainderl.asm \
-	math/sinl.asm \
-	math/tanl.asm \
-	math/trunc.asm \
-	math/truncf.asm \
-	math/truncl.asm \
+	common/math/ceill.asm \
+	common/math/cosl.asm \
+	common/math/fabs.asm \
+	common/math/fabsf.asm \
+	common/math/fabsl.asm \
+	common/math/floor.asm \
+	common/math/floorf.asm \
+	common/math/floorl.asm \
+	common/math/ldexpl.asm \
+	common/math/llrint.asm \
+	common/math/llrintf.asm \
+	common/math/llrintl.asm \
+	common/math/logl.asm \
+	common/math/lrint.asm \
+	common/math/lrintf.asm \
+	common/math/lrintl.asm \
+	common/math/remainder.asm \
+	common/math/remainderf.asm \
+	common/math/remainderl.asm \
+	common/math/sinl.asm \
+	common/math/tanl.asm \
+	common/math/trunc.asm \
+	common/math/truncf.asm \
+	common/math/truncl.asm \
 	\
 	common/misc/setjmp.asm \
@@ -616,24 +616,24 @@
 
 RuntimeR3NoCRTGCC_SOURCES.x86 = \
-	math/x86/fenv-x86.c \
-	math/gcc/adddi3.c \
-	math/gcc/anddi3.c \
-	math/gcc/ashldi3.c \
-	math/gcc/ashrdi3.c \
-	math/gcc/cmpdi2.c \
-	math/gcc/divdi3.c \
-	math/gcc/iordi3.c \
-	math/gcc/lshldi3.c \
-	math/gcc/lshrdi3.c \
-	math/gcc/moddi3.c \
-	math/gcc/muldi3.c \
-	math/gcc/negdi2.c \
-	math/gcc/notdi2.c \
-	math/gcc/qdivrem.c \
-	math/gcc/subdi3.c \
-	math/gcc/ucmpdi2.c \
-	math/gcc/udivdi3.c \
-	math/gcc/umoddi3.c \
-	math/gcc/xordi3.c
+	common/math/x86/fenv-x86.c \
+	common/math/gcc/adddi3.c \
+	common/math/gcc/anddi3.c \
+	common/math/gcc/ashldi3.c \
+	common/math/gcc/ashrdi3.c \
+	common/math/gcc/cmpdi2.c \
+	common/math/gcc/divdi3.c \
+	common/math/gcc/iordi3.c \
+	common/math/gcc/lshldi3.c \
+	common/math/gcc/lshrdi3.c \
+	common/math/gcc/moddi3.c \
+	common/math/gcc/muldi3.c \
+	common/math/gcc/negdi2.c \
+	common/math/gcc/notdi2.c \
+	common/math/gcc/qdivrem.c \
+	common/math/gcc/subdi3.c \
+	common/math/gcc/ucmpdi2.c \
+	common/math/gcc/udivdi3.c \
+	common/math/gcc/umoddi3.c \
+	common/math/gcc/xordi3.c
 
 
@@ -688,23 +688,23 @@
 ifeq ($(filter-out darwin solaris freebsd,$(BUILD_TARGET)),)
 RuntimeR0_SOURCES += \
-	math/gcc/adddi3.c \
-	math/gcc/anddi3.c \
-	math/gcc/ashldi3.c \
-	math/gcc/ashrdi3.c \
-	math/gcc/cmpdi2.c \
-	math/gcc/divdi3.c \
-	math/gcc/iordi3.c \
-	math/gcc/lshldi3.c \
-	math/gcc/lshrdi3.c \
-	math/gcc/moddi3.c \
-	math/gcc/muldi3.c \
-	math/gcc/negdi2.c \
-	math/gcc/notdi2.c \
-	math/gcc/qdivrem.c \
-	math/gcc/subdi3.c \
-	math/gcc/ucmpdi2.c \
-	math/gcc/udivdi3.c \
-	math/gcc/umoddi3.c \
-	math/gcc/xordi3.c
+	common/math/gcc/adddi3.c \
+	common/math/gcc/anddi3.c \
+	common/math/gcc/ashldi3.c \
+	common/math/gcc/ashrdi3.c \
+	common/math/gcc/cmpdi2.c \
+	common/math/gcc/divdi3.c \
+	common/math/gcc/iordi3.c \
+	common/math/gcc/lshldi3.c \
+	common/math/gcc/lshrdi3.c \
+	common/math/gcc/moddi3.c \
+	common/math/gcc/muldi3.c \
+	common/math/gcc/negdi2.c \
+	common/math/gcc/notdi2.c \
+	common/math/gcc/qdivrem.c \
+	common/math/gcc/subdi3.c \
+	common/math/gcc/ucmpdi2.c \
+	common/math/gcc/udivdi3.c \
+	common/math/gcc/umoddi3.c \
+	common/math/gcc/xordi3.c
 endif
 
@@ -1010,23 +1010,23 @@
 ifeq ($(filter-out darwin solaris freebsd,$(BUILD_TARGET)),)
 RuntimeGC_SOURCES += \
-	math/gcc/adddi3.c \
-	math/gcc/anddi3.c \
-	math/gcc/ashldi3.c \
-	math/gcc/ashrdi3.c \
-	math/gcc/cmpdi2.c \
-	math/gcc/divdi3.c \
-	math/gcc/iordi3.c \
-	math/gcc/lshldi3.c \
-	math/gcc/lshrdi3.c \
-	math/gcc/moddi3.c \
-	math/gcc/muldi3.c \
-	math/gcc/negdi2.c \
-	math/gcc/notdi2.c \
-	math/gcc/qdivrem.c \
-	math/gcc/subdi3.c \
-	math/gcc/ucmpdi2.c \
-	math/gcc/udivdi3.c \
-	math/gcc/umoddi3.c \
-	math/gcc/xordi3.c
+	common/math/gcc/adddi3.c \
+	common/math/gcc/anddi3.c \
+	common/math/gcc/ashldi3.c \
+	common/math/gcc/ashrdi3.c \
+	common/math/gcc/cmpdi2.c \
+	common/math/gcc/divdi3.c \
+	common/math/gcc/iordi3.c \
+	common/math/gcc/lshldi3.c \
+	common/math/gcc/lshrdi3.c \
+	common/math/gcc/moddi3.c \
+	common/math/gcc/muldi3.c \
+	common/math/gcc/negdi2.c \
+	common/math/gcc/notdi2.c \
+	common/math/gcc/qdivrem.c \
+	common/math/gcc/subdi3.c \
+	common/math/gcc/ucmpdi2.c \
+	common/math/gcc/udivdi3.c \
+	common/math/gcc/umoddi3.c \
+	common/math/gcc/xordi3.c
 endif
 
Index: trunk/src/VBox/Runtime/common/math/ceill.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/ceill.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/ceill.asm	(revision 5424)
@@ -0,0 +1,60 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT ceill - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Compute the smallest integral value not less than lrd.
+; @returns st(0)
+; @param    lrd     [rbp + 8]
+BEGINPROC RT_NOCRT(ceill)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 10h
+
+    fld     tword [_BP + _S*2]
+
+    ; Make it round up by modifying the fpu control word.
+    fstcw   [_BP - 10h]
+    mov     eax, [_BP - 10h]
+    or      eax, 00800h
+    and     eax, 0fbffh
+    mov     [_BP - 08h], eax
+    fldcw   [_BP - 08h]
+
+    ; Round ST(0) to integer.
+    frndint
+
+    ; Restore the fpu control word.
+    fldcw   [_BP - 10h]
+
+    leave
+    ret
+ENDPROC   RT_NOCRT(ceill)
+
Index: trunk/src/VBox/Runtime/common/math/cosl.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/cosl.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/cosl.asm	(revision 5424)
@@ -0,0 +1,62 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT cosl - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; compute the cosine of ldr, measured in radians.
+; @returns st(0)
+; @param    lrd     [rbp + _S*2]
+BEGINPROC RT_NOCRT(cosl)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 10h
+
+    fld     tword [_BP + _S*2]
+    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:
+    leave
+    ret
+ENDPROC   RT_NOCRT(cosl)
+
Index: trunk/src/VBox/Runtime/common/math/fabs.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/fabs.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/fabs.asm	(revision 5424)
@@ -0,0 +1,58 @@
+; $Id: $
+;; @file
+; innotek Portable Runtime - No-CRT fabs - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Compute the absolute value of rd (|rd|).
+; @returns 32-bit: st(0)   64-bit: xmm0
+; @param    rd      32-bit: [ebp + 8]   64-bit: xmm0
+BEGINPROC RT_NOCRT(fabs)
+    push    _BP
+    mov     _BP, _SP
+
+%ifdef RT_ARCH_AMD64
+    sub     _SP, 10h
+
+    movsd   [_SP], xmm0
+    fld     qword [_SP]
+
+    fabs
+
+    fstp    qword [_SP]
+    movsd   xmm0, [_SP]
+
+%else
+    fld     qword [_BP + _S*2]
+    fabs
+%endif
+
+    leave
+    ret
+ENDPROC   RT_NOCRT(fabs)
+
Index: trunk/src/VBox/Runtime/common/math/fabsf.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/fabsf.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/fabsf.asm	(revision 5424)
@@ -0,0 +1,58 @@
+; $Id: $
+;; @file
+; innotek Portable Runtime - No-CRT fabsf - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Compute the absolute value of rf (|rf|).
+; @returns 32-bit: st(0)   64-bit: xmm0
+; @param    rf      32-bit: [ebp + 8]   64-bit: xmm0
+BEGINPROC RT_NOCRT(fabsf)
+    push    _BP
+    mov     _BP, _SP
+
+%ifdef RT_ARCH_AMD64
+    sub     _SP, 10h
+
+    movsd   [_SP], xmm0
+    fld     dword [_SP]
+
+    fabs
+
+    fstp    dword [_SP]
+    movsd   xmm0, [_SP]
+
+%else
+    fld     dword [_BP + _S*2]
+    fabs
+%endif
+
+    leave
+    ret
+ENDPROC   RT_NOCRT(fabsf)
+
Index: trunk/src/VBox/Runtime/common/math/fabsl.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/fabsl.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/fabsl.asm	(revision 5424)
@@ -0,0 +1,47 @@
+; $Id: $
+;; @file
+; innotek Portable Runtime - No-CRT fabsl - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Compute the absolute value of lrd (|lrd|).
+; @returns st(0)
+; @param    lrd     [_SP + _S*2]
+BEGINPROC RT_NOCRT(fabsl)
+    push    _BP
+    mov     _BP, _SP
+
+    fld     tword [_BP + _S*2]
+    fabs
+
+.done:
+    leave
+    ret
+ENDPROC   RT_NOCRT(fabsl)
+
Index: trunk/src/VBox/Runtime/common/math/floor.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/floor.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/floor.asm	(revision 5424)
@@ -0,0 +1,68 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT floor - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Compute the largest integral value not greater than rd.
+; @returns 32-bit: st(0)   64-bit: xmm0
+; @param    rd      32-bit: [ebp + 8]   64-bit: xmm0
+BEGINPROC RT_NOCRT(floor)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 10h
+
+%ifdef RT_ARCH_AMD64
+    movsd   [_SP], xmm0
+    fld     qword [_SP]
+%else
+    fld     qword [_BP + _S*2]
+%endif
+
+    ; Make it round down by modifying the fpu control word.
+    fstcw   [_BP - 10h]
+    mov     eax, [_BP - 10h]
+    or      eax, 00400h
+    and     eax, 0f7ffh
+    mov     [_BP - 08h], eax
+    fldcw   [_BP - 08h]
+
+    ; Round ST(0) to integer.
+    frndint
+
+    ; Restore the fpu control word.
+    fldcw   [_BP - 10h]
+
+%ifdef RT_ARCH_AMD64
+    fstp    qword [_SP]
+    movsd   xmm0, [_SP]
+%endif
+    leave
+    ret
+ENDPROC   RT_NOCRT(floor)
+
Index: trunk/src/VBox/Runtime/common/math/floorf.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/floorf.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/floorf.asm	(revision 5424)
@@ -0,0 +1,68 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT floorf - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Compute the largest integral value not greater than rf.
+; @returns st(0)
+; @param    rf      32-bit: [ebp + 8]   64-bit: xmm0
+BEGINPROC RT_NOCRT(floorf)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 10h
+
+%ifdef RT_ARCH_AMD64
+    movss   [_SP], xmm0
+    fld     dword [_SP]
+%else
+    fld     dword [_BP + _S*2]
+%endif
+
+    ; Make it round down by modifying the fpu control word.
+    fstcw   [_BP - 10h]
+    mov     eax, [_BP - 10h]
+    or      eax, 00400h
+    and     eax, 0f7ffh
+    mov     [_BP - 08h], eax
+    fldcw   [_BP - 08h]
+
+    ; Round ST(0) to integer.
+    frndint
+
+    ; Restore the fpu control word.
+    fldcw   [_BP - 10h]
+
+%ifdef RT_ARCH_AMD64
+    fstp    dword [_SP]
+    movss   xmm0, [_SP]
+%endif
+    leave
+    ret
+ENDPROC   RT_NOCRT(floorf)
+
Index: trunk/src/VBox/Runtime/common/math/floorl.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/floorl.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/floorl.asm	(revision 5424)
@@ -0,0 +1,59 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT floorl - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Compute the largest integral value not greater than lrd.
+; @returns st(0)
+; @param    lrd     [rbp + 8]
+BEGINPROC RT_NOCRT(floorl)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 10h
+
+    fld     tword [_BP + _S*2]
+
+    ; Make it round down by modifying the fpu control word.
+    fstcw   [_BP - 10h]
+    mov     eax, [_BP - 10h]
+    or      eax, 00400h
+    and     eax, 0f7ffh
+    mov     [_BP - 08h], eax
+    fldcw   [_BP - 08h]
+
+    ; Round ST(0) to integer.
+    frndint
+
+    ; Restore the fpu control word.
+    fldcw   [_BP - 10h]
+
+    leave
+    ret
+ENDPROC   RT_NOCRT(floorl)
+
Index: trunk/src/VBox/Runtime/common/math/gcc/adddi3.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/adddi3.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/adddi3.c	(revision 5424)
@@ -0,0 +1,63 @@
+/*	$NetBSD: adddi3.c,v 1.9 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)adddi3.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: adddi3.c,v 1.9 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Add two quads.  This is trivial since a one-bit carry from a single
+ * u_int addition x+y occurs if and only if the sum x+y is less than
+ * either x or y (the choice to compare with x or y is arbitrary).
+ */
+quad_t
+__adddi3(a, b)
+	quad_t a, b;
+{
+	union uu aa, bb, sum;
+
+	aa.q = a;
+	bb.q = b;
+	sum.ul[L] = aa.ul[L] + bb.ul[L];
+	sum.ul[H] = aa.ul[H] + bb.ul[H] + (sum.ul[L] < bb.ul[L]);
+	return (sum.q);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/anddi3.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/anddi3.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/anddi3.c	(revision 5424)
@@ -0,0 +1,61 @@
+/*	$NetBSD: anddi3.c,v 1.8 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)anddi3.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: anddi3.c,v 1.8 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Return a & b, in quad.
+ */
+quad_t
+__anddi3(a, b)
+	quad_t a, b;
+{
+	union uu aa, bb;
+
+	aa.q = a;
+	bb.q = b;
+	aa.ul[0] &= bb.ul[0];
+	aa.ul[1] &= bb.ul[1];
+	return (aa.q);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/ashldi3.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/ashldi3.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/ashldi3.c	(revision 5424)
@@ -0,0 +1,70 @@
+/*	$NetBSD: ashldi3.c,v 1.9 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)ashldi3.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: ashldi3.c,v 1.9 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Shift a (signed) quad value left (arithmetic shift left).
+ * This is the same as logical shift left!
+ */
+quad_t
+__ashldi3(a, shift)
+	quad_t a;
+	qshift_t shift;
+{
+	union uu aa;
+
+	if (shift == 0)
+		return(a);
+	aa.q = a;
+	if (shift >= INT_BITS) {
+		aa.ul[H] = aa.ul[L] << (shift - INT_BITS);
+		aa.ul[L] = 0;
+	} else {
+		aa.ul[H] = (aa.ul[H] << shift) |
+		    (aa.ul[L] >> (INT_BITS - shift));
+		aa.ul[L] <<= shift;
+	}
+	return (aa.q);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/ashrdi3.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/ashrdi3.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/ashrdi3.c	(revision 5424)
@@ -0,0 +1,82 @@
+/*	$NetBSD: ashrdi3.c,v 1.10 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)ashrdi3.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: ashrdi3.c,v 1.10 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Shift a (signed) quad value right (arithmetic shift right).
+ */
+quad_t
+__ashrdi3(a, shift)
+	quad_t a;
+	qshift_t shift;
+{
+	union uu aa;
+
+	if (shift == 0)
+		return(a);
+	aa.q = a;
+	if (shift >= INT_BITS) {
+		int s;
+
+		/*
+		 * Smear bits rightward using the machine's right-shift
+		 * method, whether that is sign extension or zero fill,
+		 * to get the `sign word' s.  Note that shifting by
+		 * INT_BITS is undefined, so we shift (INT_BITS-1),
+		 * then 1 more, to get our answer.
+		 */
+		/* LINTED inherits machine dependency */
+		s = (aa.sl[H] >> (INT_BITS - 1)) >> 1;
+		/* LINTED inherits machine dependency*/
+		aa.ul[L] = aa.sl[H] >> (shift - INT_BITS);
+		aa.ul[H] = s;
+	} else {
+		aa.ul[L] = (aa.ul[L] >> shift) |
+		    (aa.ul[H] << (INT_BITS - shift));
+		/* LINTED inherits machine dependency */
+		aa.sl[H] >>= shift;
+	}
+	return (aa.q);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/cmpdi2.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/cmpdi2.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/cmpdi2.c	(revision 5424)
@@ -0,0 +1,62 @@
+/*	$NetBSD: cmpdi2.c,v 1.8 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)cmpdi2.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: cmpdi2.c,v 1.8 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Return 0, 1, or 2 as a <, =, > b respectively.
+ * Both a and b are considered signed---which means only the high word is
+ * signed.
+ */
+int
+__cmpdi2(a, b)
+	quad_t a, b;
+{
+	union uu aa, bb;
+
+	aa.q = a;
+	bb.q = b;
+	return (aa.sl[H] < bb.sl[H] ? 0 : aa.sl[H] > bb.sl[H] ? 2 :
+	    aa.ul[L] < bb.ul[L] ? 0 : aa.ul[L] > bb.ul[L] ? 2 : 1);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/divdi3.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/divdi3.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/divdi3.c	(revision 5424)
@@ -0,0 +1,70 @@
+/*	$NetBSD: divdi3.c,v 1.8 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)divdi3.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: divdi3.c,v 1.8 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Divide two signed quads.
+ * ??? if -1/2 should produce -1 on this machine, this code is wrong
+ */
+quad_t
+__divdi3(a, b)
+	quad_t a, b;
+{
+	u_quad_t ua, ub, uq;
+	int neg = 0;
+
+	ua = a;
+	ub = b;
+
+	if (a < 0)
+		ua = -ua, neg ^= 1;
+	if (b < 0)
+		ub = -ub, neg ^= 1;
+
+	uq = __qdivrem(ua, ub, (u_quad_t *)0);
+	if (neg)
+		uq = - uq;
+	return uq;
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/iordi3.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/iordi3.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/iordi3.c	(revision 5424)
@@ -0,0 +1,61 @@
+/*	$NetBSD: iordi3.c,v 1.8 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)iordi3.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: iordi3.c,v 1.8 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Return a | b, in quad.
+ */
+quad_t
+__iordi3(a, b)
+	quad_t a, b;
+{
+	union uu aa, bb;
+
+	aa.q = a;
+	bb.q = b;
+	aa.ul[0] |= bb.ul[0];
+	aa.ul[1] |= bb.ul[1];
+	return (aa.q);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/lshldi3.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/lshldi3.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/lshldi3.c	(revision 5424)
@@ -0,0 +1,70 @@
+/*	$NetBSD: lshldi3.c,v 1.9 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)lshldi3.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: lshldi3.c,v 1.9 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Shift an (unsigned) quad value left (logical shift left).
+ * This is the same as arithmetic shift left!
+ */
+quad_t
+__lshldi3(a, shift)
+	quad_t a;
+	qshift_t shift;
+{
+	union uu aa;
+
+	if (shift == 0)
+		return(a);
+	aa.q = a;
+	if (shift >= INT_BITS) {
+		aa.ul[H] = aa.ul[L] << (shift - INT_BITS);
+		aa.ul[L] = 0;
+	} else {
+		aa.ul[H] = (aa.ul[H] << shift) |
+		    (aa.ul[L] >> (INT_BITS - shift));
+		aa.ul[L] <<= shift;
+	}
+	return (aa.q);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/lshrdi3.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/lshrdi3.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/lshrdi3.c	(revision 5424)
@@ -0,0 +1,69 @@
+/*	$NetBSD: lshrdi3.c,v 1.9 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)lshrdi3.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: lshrdi3.c,v 1.9 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Shift an (unsigned) quad value right (logical shift right).
+ */
+quad_t
+__lshrdi3(a, shift)
+	quad_t a;
+	qshift_t shift;
+{
+	union uu aa;
+
+	if (shift == 0)
+		return(a);
+	aa.q = a;
+	if (shift >= INT_BITS) {
+		aa.ul[L] = aa.ul[H] >> (shift - INT_BITS);
+		aa.ul[H] = 0;
+	} else {
+		aa.ul[L] = (aa.ul[L] >> shift) |
+		    (aa.ul[H] << (INT_BITS - shift));
+		aa.ul[H] >>= shift;
+	}
+	return (aa.q);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/moddi3.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/moddi3.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/moddi3.c	(revision 5424)
@@ -0,0 +1,70 @@
+/*	$NetBSD: moddi3.c,v 1.8 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)moddi3.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: moddi3.c,v 1.8 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Return remainder after dividing two signed quads.
+ *
+ * XXX	we assume a % b < 0 iff a < 0, but this is actually machine-dependent.
+ */
+quad_t
+__moddi3(a, b)
+	quad_t a, b;
+{
+	u_quad_t ua, ub, ur;
+	int neg = 0;
+
+	ua = a;
+	ub = b;
+
+	if (a < 0)
+		ua = -ua, neg ^= 1;
+	if (b < 0)
+		ub = -ub;
+	(void)__qdivrem(ua, ub, &ur);
+	if (neg)
+		ur = -ur;
+	return (ur);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/muldi3.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/muldi3.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/muldi3.c	(revision 5424)
@@ -0,0 +1,249 @@
+/*	$NetBSD: muldi3.c,v 1.10 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)muldi3.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: muldi3.c,v 1.10 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Multiply two quads.
+ *
+ * Our algorithm is based on the following.  Split incoming quad values
+ * u and v (where u,v >= 0) into
+ *
+ *	u = 2^n u1  *  u0	(n = number of bits in `u_int', usu. 32)
+ *
+ * and
+ *
+ *	v = 2^n v1  *  v0
+ *
+ * Then
+ *
+ *	uv = 2^2n u1 v1  +  2^n u1 v0  +  2^n v1 u0  +  u0 v0
+ *	   = 2^2n u1 v1  +     2^n (u1 v0 + v1 u0)   +  u0 v0
+ *
+ * Now add 2^n u1 v1 to the first term and subtract it from the middle,
+ * and add 2^n u0 v0 to the last term and subtract it from the middle.
+ * This gives:
+ *
+ *	uv = (2^2n + 2^n) (u1 v1)  +
+ *	         (2^n)    (u1 v0 - u1 v1 + u0 v1 - u0 v0)  +
+ *	       (2^n + 1)  (u0 v0)
+ *
+ * Factoring the middle a bit gives us:
+ *
+ *	uv = (2^2n + 2^n) (u1 v1)  +			[u1v1 = high]
+ *		 (2^n)    (u1 - u0) (v0 - v1)  +	[(u1-u0)... = mid]
+ *	       (2^n + 1)  (u0 v0)			[u0v0 = low]
+ *
+ * The terms (u1 v1), (u1 - u0) (v0 - v1), and (u0 v0) can all be done
+ * in just half the precision of the original.  (Note that either or both
+ * of (u1 - u0) or (v0 - v1) may be negative.)
+ *
+ * This algorithm is from Knuth vol. 2 (2nd ed), section 4.3.3, p. 278.
+ *
+ * Since C does not give us a `int * int = quad' operator, we split
+ * our input quads into two ints, then split the two ints into two
+ * shorts.  We can then calculate `short * short = int' in native
+ * arithmetic.
+ *
+ * Our product should, strictly speaking, be a `long quad', with 128
+ * bits, but we are going to discard the upper 64.  In other words,
+ * we are not interested in uv, but rather in (uv mod 2^2n).  This
+ * makes some of the terms above vanish, and we get:
+ *
+ *	(2^n)(high) + (2^n)(mid) + (2^n + 1)(low)
+ *
+ * or
+ *
+ *	(2^n)(high + mid + low) + low
+ *
+ * Furthermore, `high' and `mid' can be computed mod 2^n, as any factor
+ * of 2^n in either one will also vanish.  Only `low' need be computed
+ * mod 2^2n, and only because of the final term above.
+ */
+static quad_t __lmulq(u_int, u_int);
+
+quad_t
+__muldi3(a, b)
+	quad_t a, b;
+{
+	union uu u, v, low, prod;
+	u_int high, mid, udiff, vdiff;
+	int negall, negmid;
+#define	u1	u.ul[H]
+#define	u0	u.ul[L]
+#define	v1	v.ul[H]
+#define	v0	v.ul[L]
+
+	/*
+	 * Get u and v such that u, v >= 0.  When this is finished,
+	 * u1, u0, v1, and v0 will be directly accessible through the
+	 * int fields.
+	 */
+	if (a >= 0)
+		u.q = a, negall = 0;
+	else
+		u.q = -a, negall = 1;
+	if (b >= 0)
+		v.q = b;
+	else
+		v.q = -b, negall ^= 1;
+
+	if (u1 == 0 && v1 == 0) {
+		/*
+		 * An (I hope) important optimization occurs when u1 and v1
+		 * are both 0.  This should be common since most numbers
+		 * are small.  Here the product is just u0*v0.
+		 */
+		prod.q = __lmulq(u0, v0);
+	} else {
+		/*
+		 * Compute the three intermediate products, remembering
+		 * whether the middle term is negative.  We can discard
+		 * any upper bits in high and mid, so we can use native
+		 * u_int * u_int => u_int arithmetic.
+		 */
+		low.q = __lmulq(u0, v0);
+
+		if (u1 >= u0)
+			negmid = 0, udiff = u1 - u0;
+		else
+			negmid = 1, udiff = u0 - u1;
+		if (v0 >= v1)
+			vdiff = v0 - v1;
+		else
+			vdiff = v1 - v0, negmid ^= 1;
+		mid = udiff * vdiff;
+
+		high = u1 * v1;
+
+		/*
+		 * Assemble the final product.
+		 */
+		prod.ul[H] = high + (negmid ? -mid : mid) + low.ul[L] +
+		    low.ul[H];
+		prod.ul[L] = low.ul[L];
+	}
+	return (negall ? -prod.q : prod.q);
+#undef u1
+#undef u0
+#undef v1
+#undef v0
+}
+
+/*
+ * Multiply two 2N-bit ints to produce a 4N-bit quad, where N is half
+ * the number of bits in an int (whatever that is---the code below
+ * does not care as long as quad.h does its part of the bargain---but
+ * typically N==16).
+ *
+ * We use the same algorithm from Knuth, but this time the modulo refinement
+ * does not apply.  On the other hand, since N is half the size of an int,
+ * we can get away with native multiplication---none of our input terms
+ * exceeds (UINT_MAX >> 1).
+ *
+ * Note that, for u_int l, the quad-precision result
+ *
+ *	l << N
+ *
+ * splits into high and low ints as HHALF(l) and LHUP(l) respectively.
+ */
+static quad_t
+__lmulq(u_int u, u_int v)
+{
+	u_int u1, u0, v1, v0, udiff, vdiff, high, mid, low;
+	u_int prodh, prodl, was;
+	union uu prod;
+	int neg;
+
+	u1 = HHALF(u);
+	u0 = LHALF(u);
+	v1 = HHALF(v);
+	v0 = LHALF(v);
+
+	low = u0 * v0;
+
+	/* This is the same small-number optimization as before. */
+	if (u1 == 0 && v1 == 0)
+		return (low);
+
+	if (u1 >= u0)
+		udiff = u1 - u0, neg = 0;
+	else
+		udiff = u0 - u1, neg = 1;
+	if (v0 >= v1)
+		vdiff = v0 - v1;
+	else
+		vdiff = v1 - v0, neg ^= 1;
+	mid = udiff * vdiff;
+
+	high = u1 * v1;
+
+	/* prod = (high << 2N) + (high << N); */
+	prodh = high + HHALF(high);
+	prodl = LHUP(high);
+
+	/* if (neg) prod -= mid << N; else prod += mid << N; */
+	if (neg) {
+		was = prodl;
+		prodl -= LHUP(mid);
+		prodh -= HHALF(mid) + (prodl > was);
+	} else {
+		was = prodl;
+		prodl += LHUP(mid);
+		prodh += HHALF(mid) + (prodl < was);
+	}
+
+	/* prod += low << N */
+	was = prodl;
+	prodl += LHUP(low);
+	prodh += HHALF(low) + (prodl < was);
+	/* ... + low; */
+	if ((prodl += low) < low)
+		prodh++;
+
+	/* return 4N-bit product */
+	prod.ul[H] = prodh;
+	prod.ul[L] = prodl;
+	return (prod.q);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/negdi2.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/negdi2.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/negdi2.c	(revision 5424)
@@ -0,0 +1,60 @@
+/*	$NetBSD: negdi2.c,v 1.8 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)negdi2.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: negdi2.c,v 1.8 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Return -a (or, equivalently, 0 - a), in quad.  See subdi3.c.
+ */
+quad_t
+__negdi2(a)
+	quad_t a;
+{
+	union uu aa, res;
+
+	aa.q = a;
+	res.ul[L] = -aa.ul[L];
+	res.ul[H] = -aa.ul[H] - (res.ul[L] > 0);
+	return (res.q);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/notdi2.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/notdi2.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/notdi2.c	(revision 5424)
@@ -0,0 +1,61 @@
+/*	$NetBSD: notdi2.c,v 1.8 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)notdi2.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: notdi2.c,v 1.8 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Return ~a.  For some reason gcc calls this `one's complement' rather
+ * than `not'.
+ */
+quad_t
+__one_cmpldi2(a)
+	quad_t a;
+{
+	union uu aa;
+
+	aa.q = a;
+	aa.ul[0] = ~aa.ul[0];
+	aa.ul[1] = ~aa.ul[1];
+	return (aa.q);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/qdivrem.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/qdivrem.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/qdivrem.c	(revision 5424)
@@ -0,0 +1,285 @@
+/*	$NetBSD: qdivrem.c,v 1.12 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)qdivrem.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: qdivrem.c,v 1.12 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+/*
+ * Multiprecision divide.  This algorithm is from Knuth vol. 2 (2nd ed),
+ * section 4.3.1, pp. 257--259.
+ */
+
+#include "quad.h"
+
+#define	B	((int)1 << HALF_BITS)	/* digit base */
+
+/* Combine two `digits' to make a single two-digit number. */
+#define	COMBINE(a, b) (((u_int)(a) << HALF_BITS) | (b))
+
+/* select a type for digits in base B: use unsigned short if they fit */
+#if UINT_MAX == 0xffffffffU && USHRT_MAX >= 0xffff
+typedef unsigned short digit;
+#else
+typedef u_int digit;
+#endif
+
+static void shl __P((digit *p, int len, int sh));
+
+/*
+ * __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v.
+ *
+ * We do this in base 2-sup-HALF_BITS, so that all intermediate products
+ * fit within u_int.  As a consequence, the maximum length dividend and
+ * divisor are 4 `digits' in this base (they are shorter if they have
+ * leading zeros).
+ */
+u_quad_t
+__qdivrem(uq, vq, arq)
+	u_quad_t uq, vq, *arq;
+{
+	union uu tmp;
+	digit *u, *v, *q;
+	digit v1, v2;
+	u_int qhat, rhat, t;
+	int m, n, d, j, i;
+	digit uspace[5], vspace[5], qspace[5];
+
+	/*
+	 * Take care of special cases: divide by zero, and u < v.
+	 */
+	if (vq == 0) {
+		/* divide by zero. */
+		static volatile const unsigned int zero = 0;
+
+		tmp.ul[H] = tmp.ul[L] = 1 / zero;
+		if (arq)
+			*arq = uq;
+		return (tmp.q);
+	}
+	if (uq < vq) {
+		if (arq)
+			*arq = uq;
+		return (0);
+	}
+	u = &uspace[0];
+	v = &vspace[0];
+	q = &qspace[0];
+
+	/*
+	 * Break dividend and divisor into digits in base B, then
+	 * count leading zeros to determine m and n.  When done, we
+	 * will have:
+	 *	u = (u[1]u[2]...u[m+n]) sub B
+	 *	v = (v[1]v[2]...v[n]) sub B
+	 *	v[1] != 0
+	 *	1 < n <= 4 (if n = 1, we use a different division algorithm)
+	 *	m >= 0 (otherwise u < v, which we already checked)
+	 *	m + n = 4
+	 * and thus
+	 *	m = 4 - n <= 2
+	 */
+	tmp.uq = uq;
+	u[0] = 0;
+	u[1] = (digit)HHALF(tmp.ul[H]);
+	u[2] = (digit)LHALF(tmp.ul[H]);
+	u[3] = (digit)HHALF(tmp.ul[L]);
+	u[4] = (digit)LHALF(tmp.ul[L]);
+	tmp.uq = vq;
+	v[1] = (digit)HHALF(tmp.ul[H]);
+	v[2] = (digit)LHALF(tmp.ul[H]);
+	v[3] = (digit)HHALF(tmp.ul[L]);
+	v[4] = (digit)LHALF(tmp.ul[L]);
+	for (n = 4; v[1] == 0; v++) {
+		if (--n == 1) {
+			u_int rbj;	/* r*B+u[j] (not root boy jim) */
+			digit q1, q2, q3, q4;
+
+			/*
+			 * Change of plan, per exercise 16.
+			 *	r = 0;
+			 *	for j = 1..4:
+			 *		q[j] = floor((r*B + u[j]) / v),
+			 *		r = (r*B + u[j]) % v;
+			 * We unroll this completely here.
+			 */
+			t = v[2];	/* nonzero, by definition */
+			q1 = (digit)(u[1] / t);
+			rbj = COMBINE(u[1] % t, u[2]);
+			q2 = (digit)(rbj / t);
+			rbj = COMBINE(rbj % t, u[3]);
+			q3 = (digit)(rbj / t);
+			rbj = COMBINE(rbj % t, u[4]);
+			q4 = (digit)(rbj / t);
+			if (arq)
+				*arq = rbj % t;
+			tmp.ul[H] = COMBINE(q1, q2);
+			tmp.ul[L] = COMBINE(q3, q4);
+			return (tmp.q);
+		}
+	}
+
+	/*
+	 * By adjusting q once we determine m, we can guarantee that
+	 * there is a complete four-digit quotient at &qspace[1] when
+	 * we finally stop.
+	 */
+	for (m = 4 - n; u[1] == 0; u++)
+		m--;
+	for (i = 4 - m; --i >= 0;)
+		q[i] = 0;
+	q += 4 - m;
+
+	/*
+	 * Here we run Program D, translated from MIX to C and acquiring
+	 * a few minor changes.
+	 *
+	 * D1: choose multiplier 1 << d to ensure v[1] >= B/2.
+	 */
+	d = 0;
+	for (t = v[1]; t < B / 2; t <<= 1)
+		d++;
+	if (d > 0) {
+		shl(&u[0], m + n, d);		/* u <<= d */
+		shl(&v[1], n - 1, d);		/* v <<= d */
+	}
+	/*
+	 * D2: j = 0.
+	 */
+	j = 0;
+	v1 = v[1];	/* for D3 -- note that v[1..n] are constant */
+	v2 = v[2];	/* for D3 */
+	do {
+		digit uj0, uj1, uj2;
+
+		/*
+		 * D3: Calculate qhat (\^q, in TeX notation).
+		 * Let qhat = min((u[j]*B + u[j+1])/v[1], B-1), and
+		 * let rhat = (u[j]*B + u[j+1]) mod v[1].
+		 * While rhat < B and v[2]*qhat > rhat*B+u[j+2],
+		 * decrement qhat and increase rhat correspondingly.
+		 * Note that if rhat >= B, v[2]*qhat < rhat*B.
+		 */
+		uj0 = u[j + 0];	/* for D3 only -- note that u[j+...] change */
+		uj1 = u[j + 1];	/* for D3 only */
+		uj2 = u[j + 2];	/* for D3 only */
+		if (uj0 == v1) {
+			qhat = B;
+			rhat = uj1;
+			goto qhat_too_big;
+		} else {
+			u_int nn = COMBINE(uj0, uj1);
+			qhat = nn / v1;
+			rhat = nn % v1;
+		}
+		while (v2 * qhat > COMBINE(rhat, uj2)) {
+	qhat_too_big:
+			qhat--;
+			if ((rhat += v1) >= B)
+				break;
+		}
+		/*
+		 * D4: Multiply and subtract.
+		 * The variable `t' holds any borrows across the loop.
+		 * We split this up so that we do not require v[0] = 0,
+		 * and to eliminate a final special case.
+		 */
+		for (t = 0, i = n; i > 0; i--) {
+			t = u[i + j] - v[i] * qhat - t;
+			u[i + j] = (digit)LHALF(t);
+			t = (B - HHALF(t)) & (B - 1);
+		}
+		t = u[j] - t;
+		u[j] = (digit)LHALF(t);
+		/*
+		 * D5: test remainder.
+		 * There is a borrow if and only if HHALF(t) is nonzero;
+		 * in that (rare) case, qhat was too large (by exactly 1).
+		 * Fix it by adding v[1..n] to u[j..j+n].
+		 */
+		if (HHALF(t)) {
+			qhat--;
+			for (t = 0, i = n; i > 0; i--) { /* D6: add back. */
+				t += u[i + j] + v[i];
+				u[i + j] = (digit)LHALF(t);
+				t = HHALF(t);
+			}
+			u[j] = (digit)LHALF(u[j] + t);
+		}
+		q[j] = (digit)qhat;
+	} while (++j <= m);		/* D7: loop on j. */
+
+	/*
+	 * If caller wants the remainder, we have to calculate it as
+	 * u[m..m+n] >> d (this is at most n digits and thus fits in
+	 * u[m+1..m+n], but we may need more source digits).
+	 */
+	if (arq) {
+		if (d) {
+			for (i = m + n; i > m; --i)
+				u[i] = (digit)(((u_int)u[i] >> d) |
+				    LHALF((u_int)u[i - 1] << (HALF_BITS - d)));
+			u[i] = 0;
+		}
+		tmp.ul[H] = COMBINE(uspace[1], uspace[2]);
+		tmp.ul[L] = COMBINE(uspace[3], uspace[4]);
+		*arq = tmp.q;
+	}
+
+	tmp.ul[H] = COMBINE(qspace[1], qspace[2]);
+	tmp.ul[L] = COMBINE(qspace[3], qspace[4]);
+	return (tmp.q);
+}
+
+/*
+ * Shift p[0]..p[len] left `sh' bits, ignoring any bits that
+ * `fall out' the left (there never will be any such anyway).
+ * We may assume len >= 0.  NOTE THAT THIS WRITES len+1 DIGITS.
+ */
+static void
+shl(digit *p, int len, int sh)
+{
+	int i;
+
+	for (i = 0; i < len; i++)
+		p[i] = (digit)(LHALF((u_int)p[i] << sh) |
+		    ((u_int)p[i + 1] >> (HALF_BITS - sh)));
+	p[i] = (digit)(LHALF((u_int)p[i] << sh));
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/quad.h
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/quad.h	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/quad.h	(revision 5424)
@@ -0,0 +1,165 @@
+/*	$NetBSD: quad.h,v 1.17 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)quad.h	8.1 (Berkeley) 6/4/93
+ */
+
+/*
+ * Quad arithmetic.
+ *
+ * This library makes the following assumptions:
+ *
+ *  - The type long long (aka quad_t) exists.
+ *
+ *  - A quad variable is exactly twice as long as `int'.
+ *
+ *  - The machine's arithmetic is two's complement.
+ *
+ * This library can provide 128-bit arithmetic on a machine with 128-bit
+ * quads and 64-bit ints, for instance, or 96-bit arithmetic on machines
+ * with 48-bit ints.
+ */
+
+#if 0 /* iprt */
+#include <sys/types.h>
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#include <limits.h>
+#else
+#include <machine/limits.h>
+#endif
+#else /* iprt */
+# include <iprt/types.h>
+# include <iprt/nocrt/limits.h>
+# undef __P
+# define __P(a) a
+# undef __GNUC_PREREQ__
+# define __GNUC_PREREQ__(m1,m2) 1
+# if 1 /* ASSUMES: little endian */
+#  define _QUAD_HIGHWORD        1
+#  define _QUAD_LOWWORD         0
+# else
+#  define _QUAD_HIGHWORD        0
+#  define _QUAD_LOWWORD         1
+# endif
+# if !defined(RT_OS_LINUX) || !defined(__KERNEL__) /* (linux/types.h defines u_int) */
+   typedef unsigned int	u_int;
+# endif
+# if !defined(RT_OS_SOLARIS)
+   typedef int64_t quad_t;
+# else
+#  define quad_t int64_t
+# endif
+   typedef uint64_t u_quad_t;
+   typedef quad_t *qaddr_t;
+#endif /* iprt */
+
+/*
+ * Depending on the desired operation, we view a `long long' (aka quad_t) in
+ * one or more of the following formats.
+ */
+union uu {
+	quad_t	q;		/* as a (signed) quad */
+	u_quad_t uq;		/* as an unsigned quad */
+	int	sl[2];		/* as two signed ints */
+	u_int	ul[2];		/* as two unsigned ints */
+};
+
+/*
+ * Define high and low parts of a quad_t.
+ */
+#define	H		_QUAD_HIGHWORD
+#define	L		_QUAD_LOWWORD
+
+/*
+ * Total number of bits in a quad_t and in the pieces that make it up.
+ * These are used for shifting, and also below for halfword extraction
+ * and assembly.
+ */
+#define	QUAD_BITS	(sizeof(quad_t) * CHAR_BIT)
+#define	INT_BITS	(sizeof(int) * CHAR_BIT)
+#define	HALF_BITS	(sizeof(int) * CHAR_BIT / 2)
+
+/*
+ * Extract high and low shortwords from longword, and move low shortword of
+ * longword to upper half of long, i.e., produce the upper longword of
+ * ((quad_t)(x) << (number_of_bits_in_int/2)).  (`x' must actually be u_int.)
+ *
+ * These are used in the multiply code, to split a longword into upper
+ * and lower halves, and to reassemble a product as a quad_t, shifted left
+ * (sizeof(int)*CHAR_BIT/2).
+ */
+#define	HHALF(x)	((u_int)(x) >> HALF_BITS)
+#define	LHALF(x)	((u_int)(x) & (((int)1 << HALF_BITS) - 1))
+#define	LHUP(x)		((u_int)(x) << HALF_BITS)
+
+/*
+ * XXX
+ * Compensate for gcc 1 vs gcc 2.  Gcc 1 defines ?sh?di3's second argument
+ * as u_quad_t, while gcc 2 correctly uses int.  Unfortunately, we still use
+ * both compilers.
+ */
+#if __GNUC_PREREQ__(2, 0) || defined(lint)
+typedef unsigned int	qshift_t;
+#else
+typedef u_quad_t	qshift_t;
+#endif
+
+__BEGIN_DECLS
+quad_t __adddi3 __P((quad_t, quad_t));
+quad_t __anddi3 __P((quad_t, quad_t));
+quad_t __ashldi3 __P((quad_t, qshift_t));
+quad_t __ashrdi3 __P((quad_t, qshift_t));
+int __cmpdi2 __P((quad_t, quad_t ));
+quad_t __divdi3 __P((quad_t, quad_t));
+quad_t __fixdfdi __P((double));
+quad_t __fixsfdi __P((float));
+u_quad_t __fixunsdfdi __P((double));
+u_quad_t __fixunssfdi __P((float));
+double __floatdidf __P((quad_t));
+float __floatdisf __P((quad_t));
+double __floatunsdidf __P((u_quad_t));
+quad_t __iordi3 __P((quad_t, quad_t));
+quad_t __lshldi3 __P((quad_t, qshift_t));
+quad_t __lshrdi3 __P((quad_t, qshift_t));
+quad_t __moddi3 __P((quad_t, quad_t));
+quad_t __muldi3 __P((quad_t, quad_t));
+quad_t __negdi2 __P((quad_t));
+quad_t __one_cmpldi2 __P((quad_t));
+u_quad_t __qdivrem __P((u_quad_t, u_quad_t, u_quad_t *));
+quad_t __subdi3 __P((quad_t, quad_t));
+int __ucmpdi2 __P((u_quad_t, u_quad_t));
+u_quad_t __udivdi3 __P((u_quad_t, u_quad_t ));
+u_quad_t __umoddi3 __P((u_quad_t, u_quad_t ));
+quad_t __xordi3 __P((quad_t, quad_t));
+__END_DECLS
Index: trunk/src/VBox/Runtime/common/math/gcc/subdi3.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/subdi3.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/subdi3.c	(revision 5424)
@@ -0,0 +1,62 @@
+/*	$NetBSD: subdi3.c,v 1.9 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)subdi3.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: subdi3.c,v 1.9 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Subtract two quad values.  This is trivial since a one-bit carry
+ * from a single u_int difference x-y occurs if and only if (x-y) > x.
+ */
+quad_t
+__subdi3(a, b)
+	quad_t a, b;
+{
+	union uu aa, bb, diff;
+
+	aa.q = a;
+	bb.q = b;
+	diff.ul[L] = aa.ul[L] - bb.ul[L];
+	diff.ul[H] = aa.ul[H] - bb.ul[H] - (diff.ul[L] > aa.ul[L]);
+	return (diff.q);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/ucmpdi2.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/ucmpdi2.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/ucmpdi2.c	(revision 5424)
@@ -0,0 +1,61 @@
+/*	$NetBSD: ucmpdi2.c,v 1.8 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)ucmpdi2.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: ucmpdi2.c,v 1.8 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Return 0, 1, or 2 as a <, =, > b respectively.
+ * Neither a nor b are considered signed.
+ */
+int
+__ucmpdi2(a, b)
+	u_quad_t a, b;
+{
+	union uu aa, bb;
+
+	aa.uq = a;
+	bb.uq = b;
+	return (aa.ul[H] < bb.ul[H] ? 0 : aa.ul[H] > bb.ul[H] ? 2 :
+	    aa.ul[L] < bb.ul[L] ? 0 : aa.ul[L] > bb.ul[L] ? 2 : 1);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/udivdi3.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/udivdi3.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/udivdi3.c	(revision 5424)
@@ -0,0 +1,56 @@
+/*	$NetBSD: udivdi3.c,v 1.8 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)udivdi3.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: udivdi3.c,v 1.8 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Divide two unsigned quads.
+ */
+u_quad_t
+__udivdi3(a, b)
+	u_quad_t a, b;
+{
+
+	return (__qdivrem(a, b, (u_quad_t *)0));
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/umoddi3.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/umoddi3.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/umoddi3.c	(revision 5424)
@@ -0,0 +1,58 @@
+/*	$NetBSD: umoddi3.c,v 1.8 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)umoddi3.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: umoddi3.c,v 1.8 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Return remainder after dividing two unsigned quads.
+ */
+u_quad_t
+__umoddi3(a, b)
+	u_quad_t a, b;
+{
+	u_quad_t r;
+
+	(void)__qdivrem(a, b, &r);
+	return (r);
+}
Index: trunk/src/VBox/Runtime/common/math/gcc/xordi3.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/gcc/xordi3.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/gcc/xordi3.c	(revision 5424)
@@ -0,0 +1,61 @@
+/*	$NetBSD: xordi3.c,v 1.8 2005/12/11 12:24:37 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)xordi3.c	8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: xordi3.c,v 1.8 2005/12/11 12:24:37 christos Exp $");
+#endif
+#endif*/ /* LIBC_SCCS and not lint */
+
+#include "quad.h"
+
+/*
+ * Return a ^ b, in quad.
+ */
+quad_t
+__xordi3(a, b)
+	quad_t a, b;
+{
+	union uu aa, bb;
+
+	aa.q = a;
+	bb.q = b;
+	aa.ul[0] ^= bb.ul[0];
+	aa.ul[1] ^= bb.ul[1];
+	return (aa.q);
+}
Index: trunk/src/VBox/Runtime/common/math/ldexpl.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/ldexpl.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/ldexpl.asm	(revision 5424)
@@ -0,0 +1,55 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT ldexpl - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Computes lrd * 2^exp
+; @returns st(0)
+; @param    lrd     [rbp + _S*2]
+; @param    exp     [ebp + 14h]  GCC:edi  MSC:ecx
+BEGINPROC RT_NOCRT(ldexpl)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 10h
+
+    ; load exp
+%ifdef RT_ARCH_AMD64 ; ASSUMES ONLY GCC HERE!
+    mov     [rsp], edi
+    fild    dword [rsp]
+%else
+    fild    dword [ebp + _S*2 + RTLRD_CB]
+%endif
+    fld     tword [_BP + _S*2]
+    fscale
+    fstp    st1
+
+    leave
+    ret
+ENDPROC   RT_NOCRT(ldexpl)
+
Index: trunk/src/VBox/Runtime/common/math/llrint.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/llrint.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/llrint.asm	(revision 5424)
@@ -0,0 +1,43 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT llrint - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Round rd to the nearest integer value, rounding according to the current rounding direction.
+; @returns 32-bit: edx:eax  64-bit: rax
+; @param    rd     32-bit: [esp + 4h]  64-bit: xmm0
+BEGINPROC RT_NOCRT(llrint)
+%ifdef RT_ARCH_AMD64
+    cvtsd2si rax, xmm0
+%else
+    push    ebp
+    mov     ebp, esp
+    sub     esp, 8h
+
+    fld     qword [ebp + 8h]
+    fistp   qword [esp]
+    fwait
+    mov     eax, [esp]
+    mov     edx, [esp + 4]
+
+    leave
+%endif
+    ret
+ENDPROC   RT_NOCRT(llrint)
+
Index: trunk/src/VBox/Runtime/common/math/llrintf.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/llrintf.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/llrintf.asm	(revision 5424)
@@ -0,0 +1,43 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT llrintf - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Round rd to the nearest integer value, rounding according to the current rounding direction.
+; @returns 32-bit: edx:eax  64-bit: rax
+; @param    rf     32-bit: [esp + 4h]  64-bit: xmm0
+BEGINPROC RT_NOCRT(llrintf)
+%ifdef RT_ARCH_AMD64
+    cvtss2si rax, xmm0
+%else
+    push    ebp
+    mov     ebp, esp
+    sub     esp, 8h
+
+    fld     dword [ebp + 8h]
+    fistp   qword [esp]
+    fwait
+    mov     eax, [esp]
+    mov     edx, [esp + 4]
+
+    leave
+%endif
+    ret
+ENDPROC   RT_NOCRT(llrintf)
+
Index: trunk/src/VBox/Runtime/common/math/llrintl.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/llrintl.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/llrintl.asm	(revision 5424)
@@ -0,0 +1,53 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT llrintl - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Round rd to the nearest integer value, rounding according to the current rounding direction.
+; @returns 32-bit: edx:eax  64-bit: rax
+; @param    lrd     [rbp + _S*2]
+BEGINPROC RT_NOCRT(llrintl)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 10h
+
+    fld     tword [_BP + _S*2]
+    fistp   qword [_SP]
+    fwait
+%ifdef RT_ARCH_AMD64
+    mov     rax, [_SP]
+%else
+    mov     eax, [_SP]
+    mov     edx, [_SP + 4]
+%endif
+
+    leave
+    ret
+ENDPROC   RT_NOCRT(llrintl)
+
Index: trunk/src/VBox/Runtime/common/math/logl.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/logl.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/logl.asm	(revision 5424)
@@ -0,0 +1,65 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT logl - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; compute the natural logarithm of lrd
+; @returns st(0)
+; @param    lrd     [rbp + _S*2]
+BEGINPROC RT_NOCRT(logl)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 10h
+
+    fldln2                              ; st0=log(2)
+    fld     tword [_BP + _S*2]          ; st1=log(2) st0=lrd
+    fld     st0                         ; st1=log(2) st0=lrd st0=lrd
+    fsub    qword [.one]                ; 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]              ; 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:
+    leave
+    ret
+.one:   dq  1.0
+.limit: dq  0.29
+ENDPROC   RT_NOCRT(logl)
+
Index: trunk/src/VBox/Runtime/common/math/lrint.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/lrint.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/lrint.asm	(revision 5424)
@@ -0,0 +1,42 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT lrint - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Round rd to the nearest integer value, rounding according to the current rounding direction.
+; @returns 32-bit: eax  64-bit: rax
+; @param    rd     32-bit: [esp + 4h]  64-bit: xmm0
+BEGINPROC RT_NOCRT(lrint)
+%ifdef RT_ARCH_AMD64
+    cvtsd2si rax, xmm0
+%else
+    push    ebp
+    mov     ebp, esp
+    sub     esp, 8h
+
+    fld     qword [ebp + 8h]
+    fistp   dword [esp]
+    fwait
+    mov     eax, [esp]
+
+    leave
+%endif
+    ret
+ENDPROC   RT_NOCRT(lrint)
+
Index: trunk/src/VBox/Runtime/common/math/lrintf.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/lrintf.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/lrintf.asm	(revision 5424)
@@ -0,0 +1,42 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT lrintf - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Round rd to the nearest integer value, rounding according to the current rounding direction.
+; @returns 32-bit: eax  64-bit: rax
+; @param    rf     32-bit: [esp + 4h]  64-bit: xmm0
+BEGINPROC RT_NOCRT(lrintf)
+%ifdef RT_ARCH_AMD64
+    cvtss2si rax, xmm0
+%else
+    push    ebp
+    mov     ebp, esp
+    sub     esp, 8h
+
+    fld     dword [ebp + 8h]
+    fistp   dword [esp]
+    fwait
+    mov     eax, [esp]
+
+    leave
+%endif
+    ret
+ENDPROC   RT_NOCRT(lrintf)
+
Index: trunk/src/VBox/Runtime/common/math/lrintl.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/lrintl.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/lrintl.asm	(revision 5424)
@@ -0,0 +1,55 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT lrintl - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Round rd to the nearest integer value, rounding according to the current rounding direction.
+; @returns 32-bit: eax  64-bit: rax
+; @param    lrd     [rbp + _S*2]
+BEGINPROC RT_NOCRT(lrintl)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 10h
+
+    fld     tword [_BP + _S*2]
+%ifdef RT_ARCH_AMD64
+    fistp   qword [_SP]
+    fwait
+    mov     rax, [_SP]
+%else
+    fistp   dword [_SP]
+    fwait
+    mov     eax, [_SP]
+%endif
+
+    leave
+    ret
+ENDPROC   RT_NOCRT(lrintl)
+
Index: trunk/src/VBox/Runtime/common/math/remainder.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/remainder.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/remainder.asm	(revision 5424)
@@ -0,0 +1,65 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT remainder - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+%else
+ %define _SP esp
+ %define _BP ebp
+%endif
+
+;;
+; See SUS.
+; @returns st(0)
+; @param    rd1    [ebp + 8h]  xmm0
+; @param    rd2    [ebp + 10h]  xmm1
+BEGINPROC RT_NOCRT(remainder)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 20h
+;int3
+
+%ifdef RT_ARCH_AMD64
+    movsd   [rsp + 10h], xmm1
+    movsd   [rsp], xmm0
+    fld     qword [rsp + 10h]
+    fld     qword [rsp]
+%else
+    fld     qword [ebp + 10h]
+    fld     qword [ebp + 8h]
+%endif
+
+    fprem1
+    fstsw   ax
+    test    ah, 04h
+    jnz     .done
+    fstp    st1
+
+.done:
+%ifdef RT_ARCH_AMD64
+    fstp    qword [rsp]
+    movsd   xmm0, [rsp]
+%endif
+
+    leave
+    ret
+ENDPROC   RT_NOCRT(remainder)
+
Index: trunk/src/VBox/Runtime/common/math/remainderf.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/remainderf.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/remainderf.asm	(revision 5424)
@@ -0,0 +1,65 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT remainderf - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+%else
+ %define _SP esp
+ %define _BP ebp
+%endif
+
+;;
+; See SUS.
+; @returns st(0)
+; @param    rf1    [ebp + 08h]  xmm0
+; @param    rf2    [ebp + 0ch]  xmm1
+BEGINPROC RT_NOCRT(remainderf)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 20h
+
+%ifdef RT_ARCH_AMD64
+    movss   [rsp], xmm1
+    movss   [rsp + 10h], xmm0
+    fld     dword [rsp]
+    fld     dword [rsp + 10h]
+%else
+    fld     dword [ebp + 0ch]
+    fld     dword [ebp + 8h]
+%endif
+
+    fprem1
+    fstsw   ax
+    test    ah, 04h
+    jnz     .done
+    fstp    st1
+
+.done:
+%ifdef RT_ARCH_AMD64
+    fstp    dword [rsp]
+    movss   xmm0, [rsp]
+%endif
+
+    leave
+    ret
+ENDPROC   RT_NOCRT(remainderf)
+
+
Index: trunk/src/VBox/Runtime/common/math/remainderl.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/remainderl.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/remainderl.asm	(revision 5424)
@@ -0,0 +1,56 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT remainderl - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+%else
+ %define _SP esp
+ %define _BP ebp
+%endif
+
+;;
+; See SUS.
+; @returns st(0)
+; @param    lrd1    [rbp + 10h]
+; @param    lrd2    [rbp + 20h]
+BEGINPROC RT_NOCRT(remainderl)
+    push    _BP
+    mov     _BP, _SP
+
+%ifdef RT_ARCH_AMD64
+    fld     tword [rbp + 10h + RTLRD_CB]
+    fld     tword [rbp + 10h]
+%else
+    fld     tword [ebp + 8h + RTLRD_CB]
+    fld     tword [ebp + 8h]
+%endif
+
+    fprem1
+    fstsw   ax
+    test    ah, 04h
+    jnz     .done
+    fstp    st1
+
+.done:
+    leave
+    ret
+ENDPROC   RT_NOCRT(remainderl)
+
Index: trunk/src/VBox/Runtime/common/math/sinl.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/sinl.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/sinl.asm	(revision 5424)
@@ -0,0 +1,62 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT sinl - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Compute the sine of lrd
+; @returns st(0)
+; @param    lrd     [_SP + _S*2]
+BEGINPROC RT_NOCRT(sinl)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 10h
+
+    fld     tword [_BP + _S*2]
+    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:
+    leave
+    ret
+ENDPROC   RT_NOCRT(sinl)
+
Index: trunk/src/VBox/Runtime/common/math/tanl.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/tanl.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/tanl.asm	(revision 5424)
@@ -0,0 +1,62 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT tanl - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Compute the sine of lrd
+; @returns st(0)
+; @param    lrd     [_SP + _S*2]
+BEGINPROC RT_NOCRT(tanl)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 10h
+
+    fld     tword [_BP + _S*2]
+    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
+    leave
+    ret
+ENDPROC   RT_NOCRT(tanl)
+
Index: trunk/src/VBox/Runtime/common/math/trunc.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/trunc.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/trunc.asm	(revision 5424)
@@ -0,0 +1,68 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT trunc - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Round to truncated integer value.
+; @returns 32-bit: st(0)   64-bit: xmm0
+; @param    rd      32-bit: [ebp + 8]   64-bit: xmm0
+BEGINPROC RT_NOCRT(trunc)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 10h
+
+%ifdef RT_ARCH_AMD64
+    movsd   [_SP], xmm0
+    fld     qword [_SP]
+%else
+    fld     qword [_BP + _S*2]
+%endif
+
+    ; Make it truncate up by modifying the fpu control word.
+    fstcw   [_BP - 10h]
+    mov     eax, [_BP - 10h]
+    or      eax, 00c00h
+    mov     [_BP - 08h], eax
+    fldcw   [_BP - 08h]
+
+    ; Round ST(0) to integer.
+    frndint
+
+    ; Restore the fpu control word.
+    fldcw   [_BP - 10h]
+
+%ifdef RT_ARCH_AMD64
+    fstp    qword [_SP]
+    movsd   xmm0, [_SP]
+%endif
+    leave
+    ret
+ENDPROC   RT_NOCRT(trunc)
+
Index: trunk/src/VBox/Runtime/common/math/truncf.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/truncf.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/truncf.asm	(revision 5424)
@@ -0,0 +1,68 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT truncf - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Round to truncated integer value.
+; @returns 32-bit: st(0)   64-bit: xmm0
+; @param    rf      32-bit: [ebp + 8]   64-bit: xmm0
+BEGINPROC RT_NOCRT(truncf)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 10h
+
+%ifdef RT_ARCH_AMD64
+    movss   [_SP], xmm0
+    fld     dword [_SP]
+%else
+    fld     dword [_BP + _S*2]
+%endif
+
+    ; Make it truncate up by modifying the fpu control word.
+    fstcw   [_BP - 10h]
+    mov     eax, [_BP - 10h]
+    or      eax, 00c00h
+    mov     [_BP - 08h], eax
+    fldcw   [_BP - 08h]
+
+    ; Round ST(0) to integer.
+    frndint
+
+    ; Restore the fpu control word.
+    fldcw   [_BP - 10h]
+
+%ifdef RT_ARCH_AMD64
+    fstp    dword [_SP]
+    movss   xmm0, [_SP]
+%endif
+    leave
+    ret
+ENDPROC   RT_NOCRT(truncf)
+
Index: trunk/src/VBox/Runtime/common/math/truncl.asm
===================================================================
--- trunk/src/VBox/Runtime/common/math/truncl.asm	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/truncl.asm	(revision 5424)
@@ -0,0 +1,59 @@
+; $Id$
+;; @file
+; innotek Portable Runtime - No-CRT truncl - AMD64 & X86.
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  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 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.
+
+
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+%ifdef RT_ARCH_AMD64
+ %define _SP rsp
+ %define _BP rbp
+ %define _S  8
+%else
+ %define _SP esp
+ %define _BP ebp
+ %define _S  4
+%endif
+
+;;
+; Round to truncated integer value.
+; @returns st(0)
+; @param    rd      [rbp + 8]
+BEGINPROC RT_NOCRT(truncl)
+    push    _BP
+    mov     _BP, _SP
+    sub     _SP, 10h
+
+    fld     tword [_BP + _S*2]
+
+    ; Make it truncate up by modifying the fpu control word.
+    fstcw   [_BP - 10h]
+    mov     eax, [_BP - 10h]
+    or      eax, 00c00h
+    mov     [_BP - 08h], eax
+    fldcw   [_BP - 08h]
+
+    ; Round ST(0) to integer.
+    frndint
+
+    ; Restore the fpu control word.
+    fldcw   [_BP - 10h]
+
+    leave
+    ret
+ENDPROC   RT_NOCRT(truncl)
+
Index: trunk/src/VBox/Runtime/common/math/x86/fenv-x86.c
===================================================================
--- trunk/src/VBox/Runtime/common/math/x86/fenv-x86.c	(revision 5424)
+++ trunk/src/VBox/Runtime/common/math/x86/fenv-x86.c	(revision 5424)
@@ -0,0 +1,218 @@
+/*-
+ * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/lib/msun/i387/fenv.c,v 1.2 2005/03/17 22:21:46 das Exp $
+ */
+
+/*#include "namespace.h"
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <machine/npx.h> 
+#include "fenv.h"*/
+#include <iprt/types.h>
+#include <iprt/nocrt/fenv.h>
+
+#if 0
+const fenv_t __fe_dfl_env = {
+	__INITIAL_NPXCW__,
+	0x0000,
+	0x0000,
+	0x1f80,
+	0xffffffff,
+	{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff }
+};
+#endif 
+
+enum __sse_support __has_sse =
+#ifdef __SSE__
+	__SSE_YES;
+#else
+	__SSE_UNK;
+#endif
+
+#define	getfl(x)	__asm __volatile("pushfl\n\tpopl %0" : "=mr" (*(x)))
+#define	setfl(x)	__asm __volatile("pushl %0\n\tpopfl" : : "g" (x))
+#define	cpuid_dx(x)	__asm __volatile("pushl %%ebx\n\tmovl $1, %%eax\n\t"  \
+					 "cpuid\n\tpopl %%ebx"		      \
+					: "=d" (*(x)) : : "eax", "ecx")
+
+/*
+ * Test for SSE support on this processor.  We need to do this because
+ * we need to use ldmxcsr/stmxcsr to get correct results if any part
+ * of the program was compiled to use SSE floating-point, but we can't
+ * use SSE on older processors.
+ */
+int
+__test_sse(void)
+{
+	int flag, nflag;
+	int dx_features;
+
+	/* Am I a 486? */
+	getfl(&flag);
+	nflag = flag ^ 0x200000;
+	setfl(nflag);
+	getfl(&nflag);
+	if (flag != nflag) {
+		/* Not a 486, so CPUID should work. */
+		cpuid_dx(&dx_features);
+		if (dx_features & 0x2000000) {
+			__has_sse = __SSE_YES;
+			return (1);
+		}
+	}
+	__has_sse = __SSE_NO;
+	return (0);
+}
+
+#if 0 /* later */
+int
+_STD(fesetexceptflag)(const fexcept_t *flagp, int excepts)
+{
+	fenv_t env;
+	int mxcsr;
+
+	__fnstenv(&env);
+	env.__status &= ~excepts;
+	env.__status |= *flagp & excepts;
+	__fldenv(env);
+
+	if (__HAS_SSE()) {
+		__stmxcsr(&mxcsr);
+		mxcsr &= ~excepts;
+		mxcsr |= *flagp & excepts;
+		__ldmxcsr(mxcsr);
+	}
+
+	return (0);
+}
+
+int
+_STD(feraiseexcept)(int excepts)
+{
+	fexcept_t ex = excepts;
+
+	fesetexceptflag(&ex, excepts);
+	__fwait();
+	return (0);
+}
+
+int
+_STD(fegetenv)(fenv_t *envp)
+{
+	int control, mxcsr;
+
+	/*
+	 * fnstenv masks all exceptions, so we need to save and
+	 * restore the control word to avoid this side effect.
+	 */
+	__fnstcw(&control);
+	__fnstenv(envp);
+	if (__HAS_SSE()) {
+		__stmxcsr(&mxcsr);
+		__set_mxcsr(*envp, mxcsr);
+	}
+	__fldcw(control);
+	return (0);
+}
+
+int
+_STD(feholdexcept)(fenv_t *envp)
+{
+	int mxcsr;
+
+	__fnstenv(envp);
+	__fnclex();
+	if (__HAS_SSE()) {
+		__stmxcsr(&mxcsr);
+		__set_mxcsr(*envp, mxcsr);
+		mxcsr &= ~FE_ALL_EXCEPT;
+		mxcsr |= FE_ALL_EXCEPT << _SSE_EMASK_SHIFT;
+		__ldmxcsr(mxcsr);
+	}
+	return (0);
+}
+
+int
+_STD(feupdateenv)(const fenv_t *envp)
+{
+	int mxcsr, status;
+
+	__fnstsw(&status);
+	if (__HAS_SSE())
+		__stmxcsr(&mxcsr);
+	else
+		mxcsr = 0;
+	fesetenv(envp);
+	feraiseexcept((mxcsr | status) & FE_ALL_EXCEPT);
+	return (0);
+}
+
+int
+__feenableexcept(int mask)
+{
+	int mxcsr, control, omask;
+
+	mask &= FE_ALL_EXCEPT;
+	__fnstcw(&control);
+	if (__HAS_SSE())
+		__stmxcsr(&mxcsr);
+	else
+		mxcsr = 0;
+	omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
+	control &= ~mask;
+	__fldcw(control);
+	if (__HAS_SSE()) {
+		mxcsr &= ~(mask << _SSE_EMASK_SHIFT);
+		__ldmxcsr(mxcsr);
+	}
+	return (~omask);
+}
+
+int
+__fedisableexcept(int mask)
+{
+	int mxcsr, control, omask;
+
+	mask &= FE_ALL_EXCEPT;
+	__fnstcw(&control);
+	if (__HAS_SSE())
+		__stmxcsr(&mxcsr);
+	else
+		mxcsr = 0;
+	omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
+	control |= mask;
+	__fldcw(control);
+	if (__HAS_SSE()) {
+		mxcsr |= mask << _SSE_EMASK_SHIFT;
+		__ldmxcsr(mxcsr);
+	}
+	return (~omask);
+}
+
+__weak_reference(__feenableexcept, feenableexcept);
+__weak_reference(__fedisableexcept, fedisableexcept);
+#endif /* later */
