diff --git a/.gitignore b/.gitignore index 089f578ae..54be88957 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ .metadata bin/ tmp/ +toolchain/ *.tmp *.bak *.swp diff --git a/librt/libm/i386/_atan2.S b/librt/libm/i386/_atan2.S deleted file mode 100644 index ae013e2b0..000000000 --- a/librt/libm/i386/_atan2.S +++ /dev/null @@ -1,44 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math ATAN2 - -bits 32 -segment .text - -;Functions in this asm -global _atan2 -global __CIatan2 - -; double __cdecl atan2(double y, double x) -_atan2: - ; Stack Frame - push ebp - mov ebp, esp - - fld qword [ebp + 8] - fld qword [ebp + 16] - fpatan - - ; Unwind & return - pop ebp - ret - -; Msvc version of atan2 -__CIatan2: - fpatan - ret \ No newline at end of file diff --git a/librt/libm/i386/_ceil.S b/librt/libm/i386/_ceil.S deleted file mode 100644 index 335480443..000000000 --- a/librt/libm/i386/_ceil.S +++ /dev/null @@ -1,131 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math CEILING - -bits 32 -segment .text - -;Functions in this asm -global _ceil -global _ceilf -global _ceill - -; Ceils a value -_ceil: - ; Stack Frame - push ebp - mov ebp, esp - - ; Allocate temporary space - sub esp, 8 - - ; Store control word - fstcw word [ebp - 4] - mov dx, word [ebp - 4] - - ; Round towards +oo - or dx, 0x0800 - and dx, 0xFBFF - mov word [ebp - 8], dx - - ; Load modfied control word - fldcw word [ebp - 8] - - ; Load real from stack - fld qword [ebp + 8] - - ; Round - frndint - - ; Restore control word - fldcw [ebp - 4] - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -; Ceils a value float -_ceilf: - ; Stack Frame - push ebp - mov ebp, esp - - ; Allocate temporary space - sub esp, 8 - - ; Store control word - fstcw word [ebp - 4] - mov dx, word [ebp - 4] - - ; Round towards +oo - or dx, 0x0800 - and dx, 0xFBFF - mov word [ebp - 8], dx - - ; Load modfied control word - fldcw word [ebp - 8] - - ; Load real from stack - fld dword [ebp + 8] - - ; Round - frndint - - ; Restore control word - fldcw [ebp - 4] - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -; Ceils a value long double -_ceill: - ; Stack Frame - push ebp - mov ebp, esp - - ; Allocate temporary space - sub esp, 8 - - ; Store control word - fstcw word [ebp - 4] - mov dx, word [ebp - 4] - - ; Round towards +oo - or dx, 0x0800 - and dx, 0xFBFF - mov word [ebp - 8], dx - - ; Load modfied control word - fldcw word [ebp - 8] - - ; Load real from stack - fld tword [ebp + 8] - - ; Round - frndint - - ; Restore control word - fldcw [ebp - 4] - - ; Unwind & return - mov esp, ebp - pop ebp - ret \ No newline at end of file diff --git a/librt/libm/i386/_copysign.S b/librt/libm/i386/_copysign.S deleted file mode 100644 index ea403ff8d..000000000 --- a/librt/libm/i386/_copysign.S +++ /dev/null @@ -1,92 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math CopySign - -bits 32 -segment .text - -;Functions in this asm -global _copysign -global _copysignf -global _copysignl - -; Copysign, has two params -_copysign: - ; Stack Frame - push ebp - mov ebp, esp - - ; Do some tests - ; High part of x - mov edx, dword [ebp + 20] - and edx, 0x80000000 - mov eax, dword [ebp + 12] - and eax, 0x7FFFFFFF - or eax, edx - mov dword [ebp + 12], eax - - ; Load real from stack - fld qword [ebp + 8] - - ; Unwind & return - pop ebp - ret - -; Copysign float, has two params -_copysignf: - ; Stack Frame - push ebp - mov ebp, esp - - ; Do some tests - ; High part of x - mov edx, dword [ebp + 12] - and edx, 0x80000000 - mov eax, dword [ebp + 8] - and eax, 0x7FFFFFFF - or eax, edx - mov dword [ebp + 8], eax - - ; Load real from stack - fld dword [ebp + 8] - - ; Unwind & return - pop ebp - ret - -; Copysign long, has two params -_copysignl: - ; Stack Frame - push ebp - mov ebp, esp - - ; Do some tests - ; High part of x - mov edx, dword [ebp + 28] - and edx, 0x00008000 - mov eax, dword [ebp + 16] - and eax, 0x00007FFF - or eax, edx - mov dword [ebp + 16], eax - - ; Load real from stack - fld tword [ebp + 8] - - ; Unwind & return - pop ebp - ret \ No newline at end of file diff --git a/librt/libm/i386/_cos.S b/librt/libm/i386/_cos.S deleted file mode 100644 index 1dd8c6da8..000000000 --- a/librt/libm/i386/_cos.S +++ /dev/null @@ -1,93 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math COSINUS - -bits 32 -segment .text - -;Functions in this asm -global _cos -global __CIcos - -; takes the cosinus value -_cos: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load real from stack - fld qword [ebp + 8] - - ; Take the cosine - fcos - - ; Modify control word - fnstsw ax - and ax, 0x0400 - jnz .Try1 - jmp .Leave - - .Try1: - fldpi - fadd st0 - fxch st1 - - .Try2: - fprem1 - fnstsw ax - and ax, 0x0400 - jnz .Try2 - fstp st1 - fcos - - ; Unwind & return - .Leave: - pop ebp - ret - -; Msvc version of cos -__CIcos: - ; We trash eax - push eax - - ; Take the cosine - fcos - - ; Modify control word - fnstsw ax - and ax, 0x0400 - jnz .Try1 - jmp .Leave - - .Try1: - fldpi - fadd st0 - fxch st1 - - .Try2: - fprem1 - fnstsw ax - and ax, 0x0400 - jnz .Try2 - fstp st1 - fcos - - ; Restore and ret - .Leave: - pop eax - ret \ No newline at end of file diff --git a/librt/libm/i386/_exp.S b/librt/libm/i386/_exp.S deleted file mode 100644 index 4904b6986..000000000 --- a/librt/libm/i386/_exp.S +++ /dev/null @@ -1,104 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math EXP - -bits 32 -segment .text - -;Functions in this asm -global _exp -global __CIexp - -; double __cdecl exp(double x) -; e^x = 2^(x * log2(e)) -_exp: - ; Stack Frame - push ebp - mov ebp, esp - - ; If x is +-Inf, then the subtraction would give Inf-Inf = NaN. - ; Avoid this. Also avoid it if x is NaN for convenience. - mov eax, dword [ebp + 12] - and eax, 0x7FFFFFFF - cmp eax, 0x7FF00000 - jae .IsInf - - ; Load 64 bit - fld qword [ebp + 8] - - ; Extended precision is needed to reduce the maximum error from - ; hundreds of ulps to less than 1 ulp. Switch to it if necessary. - ; We may as well set the rounding mode to to-nearest and mask traps - ; if we switch. - fstcw word [ebp + 8] - mov eax, dword [ebp + 8] - and eax, 0x00000300 - cmp eax, 0x00000300 - je .Start - mov dword [ebp + 12], 0x0000137F - fldcw word [ebp + 12] - - .Start: - fldl2e - fmulp st1, st0 ; x * log2(e) - fst st1 - frndint ; int(x * log2(e)) - fsub st1, st0 - fxch - f2xm1 ; 2^(fract(x * log2(e))) - 1 - fld1 - fadd - fscale ; e^x - fstp st1 - je .Leave - fldcw word [ebp + 8] - jmp .Leave - - ; Return 0 if x is -Inf. Otherwise just return x; when x is Inf - ; this gives Inf, and when x is a NaN this gives the same result - ; as (x + x) (x quieted). - .IsInf: - cmp dword [ebp + 12], 0xFFF00000 - jne .PlusInf - cmp dword [ebp + 8], 0 - jne .PlusInf - fldz - jmp .Leave - - .PlusInf: - fld qword [ebp + 8] - - .Leave: - ; Unwind & return - pop ebp - ret - -; Msvc version of exp -__CIexp: - ; Stack Frame - push ebp - mov ebp, esp - sub esp, 8 - - fstp qword [esp] - call _exp - - ; Restore and leave - mov esp, ebp - pop ebp - ret \ No newline at end of file diff --git a/librt/libm/i386/_floor.S b/librt/libm/i386/_floor.S deleted file mode 100644 index 25abae3ab..000000000 --- a/librt/libm/i386/_floor.S +++ /dev/null @@ -1,119 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math FLOOR - -bits 32 -segment .text - -;Functions in this asm -global _floor -global _floorf -global _floorl - -; Floors a value -_floor: - ; Stack Frame - push ebp - mov ebp, esp - sub esp, 8 ; Allocate temporary space - - ; Save control word - fstcw word [ebp - 4] - mov dx, word [ebp - 4] - - ; Round towards -oo - or dx, 0x0400 - and dx, 0xF7FF - mov word [ebp - 8], dx - - ; Set new rounding control - fldcw word [ebp - 8] - - ; Load real from stack - fld qword [ebp+8] - frndint - - ; Restore control word - fldcw word [ebp - 4] - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -; Floors a value float -_floorf: - ; Stack Frame - push ebp - mov ebp, esp - sub esp, 8 ; Allocate temporary space - - ; Save control word - fstcw word [ebp - 4] - mov dx, word [ebp - 4] - - ; Round towards -oo - or dx, 0x0400 - and dx, 0xF7FF - mov word [ebp - 8], dx - - ; Set new rounding control - fldcw word [ebp - 8] - - ; Load real from stack - fld dword [ebp+8] - frndint - - ; Restore control word - fldcw word [ebp - 4] - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -; Floors a value long -_floorl: - ; Stack Frame - push ebp - mov ebp, esp - sub esp, 8 ; Allocate temporary space - - ; Save control word - fstcw word [ebp - 4] - mov dx, word [ebp - 4] - - ; Round towards -oo - or dx, 0x0400 - and dx, 0xF7FF - mov word [ebp - 8], dx - - ; Set new rounding control - fldcw word [ebp - 8] - - ; Load real from stack - fld tword [ebp+8] - frndint - - ; Restore control word - fldcw word [ebp - 4] - - ; Unwind & return - mov esp, ebp - pop ebp - ret \ No newline at end of file diff --git a/librt/libm/i386/_fmod.S b/librt/libm/i386/_fmod.S deleted file mode 100644 index e5f0529af..000000000 --- a/librt/libm/i386/_fmod.S +++ /dev/null @@ -1,84 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math floating point remainder of x/y - -bits 32 -segment .text - -;Functions in this asm -global _fmod -global __CIfmod - -; double __cdecl fmod(double x, double y) -; floating point remainder of x/y -_fmod: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load x and y from stack - fld qword [ebp + 16] - fld qword [ebp + 8] - -__fmod1: - ; Get the partial remainder - fprem - - ; Get coprocessor status - fstsw ax - - ; Complete remainder ? - sahf - - ; No, go get next remainder - jp __fmod1 - - ; Set new top of stack - fstp st1 - - ; Unwind & return - pop ebp - ret - -; Msvc version of fmod -__CIfmod: - ; Save eax - push eax - - ; Swap arguments - fxch st1 - -__CIfmod1: - ; Get the partial remainder - fprem - - ; Get coprocessor status - fstsw ax - - ; Complete remainder ? - sahf - - ; No, go get next remainder - jp __CIfmod1 - - ; Set new top of stack - fstp st1 - - ; Unwind & return - pop eax - ret \ No newline at end of file diff --git a/librt/libm/i386/_ftol.s b/librt/libm/i386/_ftol.s deleted file mode 100644 index 1e7765aa4..000000000 --- a/librt/libm/i386/_ftol.s +++ /dev/null @@ -1,38 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math floating point to integer conversion - -bits 32 -segment .text - -;Functions in this asm -global __ftol - -; This routine is called by MSVC-generated code to convert from floating point -; to integer representation -__ftol: - fnstcw word [esp-2] - mov ax, word [esp-2] - or ax, 0C00h - mov word [esp-4], ax - fldcw word [esp-4] - fistp qword [esp-12] - fldcw word [esp-2] - mov eax, dword [esp-12] - mov edx, dword [esp-8] - ret diff --git a/librt/libm/i386/_ftol2.s b/librt/libm/i386/_ftol2.s deleted file mode 100644 index aef9083a5..000000000 --- a/librt/libm/i386/_ftol2.s +++ /dev/null @@ -1,79 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math FTOL2 - -bits 32 -segment .text - -;Functions in this asm -extern __ftol -global __ftol2 -global __ftol2_sse - -; This routine is called by MSVC-generated code to convert from floating point -; to integer representation. -__ftol2: - push ebp - mov ebp,esp - sub esp,20h - - and esp,0FFFFFFF0h - fld st0 - fst dword [esp+18h] - fistp qword [esp+10h] - fild qword [esp+10h] - mov edx,dword [esp+18h] - mov eax,dword [esp+10h] - test eax,eax - je integer_QnaN_or_zero - -arg_is_not_integer_QnaN: - fsubp st1, st0 - test edx,edx - jns positive - fstp dword [esp] - mov ecx,dword [esp] - xor ecx,80000000h - add ecx,7FFFFFFFh - adc eax,0 - mov edx,dword [esp+14h] - adc edx,0 - jmp localexit - -positive: - fstp dword [esp] - mov ecx,dword [esp] - add ecx,7FFFFFFFh - sbb eax,0 - mov edx,dword [esp+14h] - sbb edx,0 - jmp localexit - -integer_QnaN_or_zero: - mov edx,dword [esp+14h] - test edx,7FFFFFFFh - jne arg_is_not_integer_QnaN - fstp dword [esp+18h] - fstp dword [esp+18h] - -localexit: - leave - ret - -__ftol2_sse: - jmp __ftol2 diff --git a/librt/libm/i386/_llrint.S b/librt/libm/i386/_llrint.S deleted file mode 100644 index 894106e6a..000000000 --- a/librt/libm/i386/_llrint.S +++ /dev/null @@ -1,80 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math Round To Int - -bits 32 -segment .text - -;Functions in this asm -global _llrint -global _llrintf -global _llrintl - -; Rounds double to long long -_llrint: - ; Stack Frame - push ebp - mov ebp, esp - sub esp, 8 - - ; Load real from stack - fld qword [ebp + 8] - fistp qword [ebp - 8] - pop eax - pop edx - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -; Rounds float to long long -_llrintf: - ; Stack Frame - push ebp - mov ebp, esp - sub esp, 8 - - ; Load real from stack - fld dword [ebp + 8] - fistp qword [ebp - 8] - pop eax - pop edx - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -; Rounds long double to long long -_llrintl: - ; Stack Frame - push ebp - mov ebp, esp - sub esp, 8 - - ; Load real from stack - fld tword [ebp + 8] - fistp qword [ebp - 8] - pop eax - pop edx - - ; Unwind & return - mov esp, ebp - pop ebp - ret \ No newline at end of file diff --git a/librt/libm/i386/_log.S b/librt/libm/i386/_log.S deleted file mode 100644 index d374e0852..000000000 --- a/librt/libm/i386/_log.S +++ /dev/null @@ -1,93 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math LOG - -bits 32 -segment .text - -;Functions in this asm -global _log -global _logf -global _logl -global __CIlog - -; takes the logorithmic value in base 2 -_log: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load log base e of 2 - fldln2 - - ; Load real from stack - fld qword [ebp + 8] - - ; Compute the natural log(x) - fyl2x - - ; Unwind & return - pop ebp - ret - -; takes the logorithmic value in base 2 float -_logf: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load log base e of 2 - fldln2 - - ; Load real from stack - fld dword [ebp + 8] - - ; Compute the natural log(x) - fyl2x - - ; Unwind & return - pop ebp - ret - -; takes the logorithmic value in base 2 float -_logl: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load log base e of 2 - fldln2 - - ; Load real from stack - fld tword [ebp + 8] - - ; Compute the natural log(x) - fyl2x - - ; Unwind & return - pop ebp - ret - -; Msvc version of log -__CIlog: - fldln2 - fxch - fyl2x - - ; Done - ret \ No newline at end of file diff --git a/librt/libm/i386/_log10.S b/librt/libm/i386/_log10.S deleted file mode 100644 index ebb9d22dc..000000000 --- a/librt/libm/i386/_log10.S +++ /dev/null @@ -1,90 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math LOG 10 - -bits 32 -segment .text - -;Functions in this asm -global _log10 -global _log10f -global _log10l -global __CIlog10 - -; takes the logorithmic value in base 10 -_log10: - ; Stack Frame - push ebp - mov ebp, esp - - ; Do the magic - fldlg2 ; Load log base 10 of 2 - fld qword [ebp + 8] ; Load real from stack - - ; Compute the log base 10(x) - fyl2x - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -; takes the logorithmic value in base 10 float -_log10f: - ; Stack Frame - push ebp - mov ebp, esp - - ; Do the magic - fldlg2 ; Load log base 10 of 2 - fld dword [ebp + 8] ; Load real from stack - - ; Compute the log base 10(x) - fyl2x - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -; takes the logorithmic value in base 10 long double -_log10l: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load log base 10 of 2 - fldlg2 - - ; Load real from stack - fld tword [ebp + 8] - - ; Compute the log base 10(x) - fyl2x - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -; Msvc version of log10 -__CIlog10: - fldlg2 - fxch - fyl2x - ret \ No newline at end of file diff --git a/librt/libm/i386/_log2.S b/librt/libm/i386/_log2.S deleted file mode 100644 index 0556d4e32..000000000 --- a/librt/libm/i386/_log2.S +++ /dev/null @@ -1,95 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math LOG2 - -bits 32 -segment .text - -;Functions in this asm -global _log2 - -; double __cdecl log2(double) -; Take the log value 2 -_log2: - ; Stack Frame - push ebp - mov ebp, esp - - ; Push 1 to stack - fld1 - fld qword [ebp + 8] - fxam - fnstsw ax - - ; x : x : 1 - fld st0 - sahf - - ; in case x is NaN or ħInf - jc t3 -t4: - ; x-1 : x : 1 - fsub st0, st2 - - ; x-1 : x-1 : x : 1 - fld st0 - - ; |x-1| : x-1 : x : 1 - fabs - - ; x-1 : x : 1 - fcomp - - ; x-1 : x : 1 - fnstsw ax - and ah, 0x45 - jz t2 - - ; x-1 : 1 - fstp st1 - - ; log(x) - fyl2xp1 - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -t2: - ; x : 1 - fstp st0 - - ; log(x) - fyl2x - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -t3: - ; in case x is ħInf - jp t4 - fstp st1 - fstp st1 - - ; Unwind & return - mov esp, ebp - pop ebp - ret \ No newline at end of file diff --git a/librt/libm/i386/_logb.S b/librt/libm/i386/_logb.S deleted file mode 100644 index 7f7602d65..000000000 --- a/librt/libm/i386/_logb.S +++ /dev/null @@ -1,77 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math LOGB - -bits 32 -segment .text - -;Functions in this asm -global _logb -global _logbf -global _logbl - -; takes the logorithmic value -_logb: - ; Stack Frame - push ebp - mov ebp, esp - - ; Do the magic - fld qword [ebp + 8] ; Load real from stack - fxtract - - ; Store - fstp st0 - - ; Unwind & return - pop ebp - ret - -; takes the logorithmic value -_logbf: - ; Stack Frame - push ebp - mov ebp, esp - - ; Do the magic - fld dword [ebp + 8] ; Load single from stack - fxtract - - ; Store - fstp st0 - - ; Unwind & return - pop ebp - ret - -; takes the logorithmic value -_logbl: - ; Stack Frame - push ebp - mov ebp, esp - - ; Do the magic - fld tword [ebp + 8] ; Load 80bit from stack - fxtract - - ; Store - fstp st0 - - ; Unwind & return - pop ebp - ret \ No newline at end of file diff --git a/librt/libm/i386/_lrint.S b/librt/libm/i386/_lrint.S deleted file mode 100644 index 7c52c6d93..000000000 --- a/librt/libm/i386/_lrint.S +++ /dev/null @@ -1,77 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math Round To Int - -bits 32 -segment .text - -;Functions in this asm -global _lrint -global _lrintf -global _lrintl - -; Rounds a double to long -_lrint: - ; Stack Frame - push ebp - mov ebp, esp - sub esp, 4 - - ; Load real from stack - fld qword [ebp + 8] - fistp dword [ebp - 4] - pop eax - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -; Rounds a float to long -_lrintf: - ; Stack Frame - push ebp - mov ebp, esp - sub esp, 4 - - ; Load real from stack - fld dword [ebp + 8] - fistp dword [ebp - 4] - pop eax - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -; Rounds a long double to long -_lrintl: - ; Stack Frame - push ebp - mov ebp, esp - sub esp, 4 - - ; Load real from stack - fld tword [ebp + 8] - fistp dword [ebp - 4] - pop eax - - ; Unwind & return - mov esp, ebp - pop ebp - ret \ No newline at end of file diff --git a/librt/libm/i386/_remainder.S b/librt/libm/i386/_remainder.S deleted file mode 100644 index 19e9861e6..000000000 --- a/librt/libm/i386/_remainder.S +++ /dev/null @@ -1,116 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math LOG - -bits 32 -segment .text - -;Functions in this asm -global _remainder -global _remainderf -global _remainderl - -; takes the remainder -_remainder: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load x and y from stack - fld qword [ebp + 16] - fld qword [ebp + 8] - - .TryAgain: - ; Get fp remainder - fprem1 - - ; Get flags - fstsw ax - - ; Is there more? - sahf - - ; Load real from stack - jp .TryAgain - - ; Store result on stack - fstp st1 - - ; Unwind & return - pop ebp - ret - -; takes the remainder float -_remainderf: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load x and y from stack - fld dword [ebp + 12] - fld dword [ebp + 8] - - .TryAgain: - ; Get fp remainder - fprem1 - - ; Get flags - fstsw ax - - ; Is there more? - sahf - - ; Load real from stack - jp .TryAgain - - ; Store result on stack - fstp st1 - - ; Unwind & return - pop ebp - ret - -; takes the remainder long double -_remainderl: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load x and y from stack - fld tword [ebp + 20] - fld tword [ebp + 8] - - .TryAgain: - ; Get fp remainder - fprem1 - - ; Get flags - fstsw ax - - ; Is there more? - sahf - - ; Load real from stack - jp .TryAgain - - ; Store result on stack - fstp st1 - - ; Unwind & return - pop ebp - ret \ No newline at end of file diff --git a/librt/libm/i386/_rint.S b/librt/libm/i386/_rint.S deleted file mode 100644 index e2cfde516..000000000 --- a/librt/libm/i386/_rint.S +++ /dev/null @@ -1,68 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math Round To Int - -bits 32 -segment .text - -;Functions in this asm -global _rint -global _rintf -global _rintl - -; Rounds a double to int -_rint: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load real from stack - fld qword [ebp + 8] - frndint - - ; Unwind & return - pop ebp - ret - -; Rounds a float to int -_rintf: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load real from stack - fld dword [ebp + 8] - frndint - - ; Unwind & return - pop ebp - ret - -; Rounds a long double to int -_rintl: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load real from stack - fld tword [ebp + 8] - frndint - - ; Unwind & return - pop ebp - ret \ No newline at end of file diff --git a/librt/libm/i386/_scalbn.S b/librt/libm/i386/_scalbn.S deleted file mode 100644 index 31684d6f4..000000000 --- a/librt/libm/i386/_scalbn.S +++ /dev/null @@ -1,80 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math SCALBN - -bits 32 -segment .text - -;Functions in this asm -global _scalbn -global _scalbnf -global _scalbnl - -; The math scale -_scalbn: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load real from stack - fild dword [ebp + 16] - fld qword [ebp + 8] - fscale - - ; Store result + restore stack - fstp st1 - - ; Unwind & return - pop ebp - ret - -; The math scale float -_scalbnf: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load real from stack - fild dword [ebp + 12] - fld dword [ebp + 8] - fscale - - ; Store result - fstp st1 - - ; Unwind & return - pop ebp - ret - -; The math scale long double -_scalbnl: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load real from stack - fild dword [ebp + 20] - fld tword [ebp + 8] - fscale - - ; Store result - fstp st1 - - ; Unwind & return - pop ebp - ret \ No newline at end of file diff --git a/librt/libm/i386/_sin.S b/librt/libm/i386/_sin.S deleted file mode 100644 index 7ea73be51..000000000 --- a/librt/libm/i386/_sin.S +++ /dev/null @@ -1,93 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math SINUS - -bits 32 -segment .text - -;Functions in this asm -global _sin -global __CIsin - -; computes the sinus value -_sin: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load real from stack - fld qword [ebp + 8] - fsin - - ; Do some validation - fnstsw ax - and ax, 0x0400 - - jnz .Try1 - jmp .Leave - - .Try1: - fldpi - fadd st0 - fxch st1 - - .Try2: - fprem1 - fnstsw ax - and ax, 0x0400 - jnz .Try2 - fstp st1 - fsin - - .Leave: - ; Unwind & return - pop ebp - ret - -; Msvc version of sin -__CIsin: - ; We trash eax - push eax - - ; Do the fsin - fsin - - ; Do some validation - fnstsw ax - and ax, 0x0400 - - jnz .Try1 - jmp .Leave - - .Try1: - fldpi - fadd st0 - fxch st1 - - .Try2: - fprem1 - fnstsw ax - and ax, 0x0400 - jnz .Try2 - fstp st1 - fsin - - .Leave: - ; Unwind & return - pop eax - ret \ No newline at end of file diff --git a/librt/libm/i386/_sqrt.S b/librt/libm/i386/_sqrt.S deleted file mode 100644 index 366343232..000000000 --- a/librt/libm/i386/_sqrt.S +++ /dev/null @@ -1,80 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math SQRT - -bits 32 -segment .text - -;Functions in this asm -global _sqrt -global _sqrtf -global _sqrtl -global __CIsqrt - -; Computes the square-root -_sqrt: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load real from stack - fld qword [ebp + 8] - - ; Take the square root - fsqrt - - ; Unwind & return - pop ebp - ret - -; Computes the square-root -_sqrtf: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load real from stack - fld dword [ebp + 8] - - ; Take the square root - fsqrt - - ; Unwind & return - pop ebp - ret - -; Computes the square-root -_sqrtl: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load real from stack - fld tword [ebp + 8] - - ; Take the square root - fsqrt - - ; Unwind & return - pop ebp - ret - -; Msvc version of sqrt -__CIsqrt: - fsqrt - ret \ No newline at end of file diff --git a/librt/libm/i386/_tan.S b/librt/libm/i386/_tan.S deleted file mode 100644 index b42aecada..000000000 --- a/librt/libm/i386/_tan.S +++ /dev/null @@ -1,142 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math floating point tangent - -bits 32 -segment .text - -;Functions in this asm -global _tan -global _tanf -global __CItan - -; double __cdecl tan(double x) -; floating point tangent -_tan: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load real from stack - fld qword [ebp+8] - - ; Take the tangent - fptan - - ; Use ax for temporary storage - fnstsw ax - and ax, 0x400 - jnz .NotZero - - fstp st0 - jmp .Leave - - .NotZero: - fldpi - fadd st0 - fxch st1 - - .Repeat: - fprem1 - fnstsw ax - and ax, 0x400 - jnz .Repeat - fstp st1 - fptan - fstp st0 - - ; Unwind & return - .Leave: - pop ebp - ret - -; float __cdecl tan(float x) -; floating point tangent -_tanf: - ; Stack Frame - push ebp - mov ebp, esp - - ; Load real from stack - fld dword [ebp+8] - - ; Take the tangent - fptan - - ; Use ax for temporary storage - fnstsw ax - and ax, 0x400 - jnz .NotZero - - fstp st0 - jmp .Leave - - .NotZero: - fldpi - fadd st0 - fxch st1 - - .Repeat: - fprem1 - fnstsw ax - and ax, 0x400 - jnz .Repeat - fstp st1 - fptan - fstp st0 - - ; Unwind & return - .Leave: - pop ebp - ret - -; Msvc version of tan -__CItan: - ; Store eax, we trash it - push eax - - ; Take the tangent - fptan - - ; Use ax for temporary storage - fnstsw ax - and ax, 0x400 - jnz .NotZero - fstp st0 - - ; Restore and return - pop eax - ret - - .NotZero: - fldpi - fadd st0 - fxch st1 - - .Repeat: - fprem1 - fnstsw ax - and ax, 0x400 - jnz .Repeat - fstp st1 - fptan - fstp st0 - - ; Restore and return - pop eax - ret \ No newline at end of file diff --git a/librt/libm/i386/_trunc.S b/librt/libm/i386/_trunc.S deleted file mode 100644 index d2759cef9..000000000 --- a/librt/libm/i386/_trunc.S +++ /dev/null @@ -1,116 +0,0 @@ -; MollenOS -; Copyright 2011-2016, Philip Meulengracht -; -; This program 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?, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . -; -; -; MollenOS x86-32 Math Truncate - -bits 32 -segment .text - -;Functions in this asm -global _trunc -global _truncf -global _truncl - -; Truncates the double -_trunc: - ; Stack Frame - push ebp - mov ebp, esp - sub esp, 8 ; Allocate temporary space - - ; Save control word - fstcw word [ebp - 4] - mov dx, word [ebp - 4] - - ; Round towards -oo - or dx, 0x0C00 - mov word [ebp - 8], dx - - ; Set new rounding control - fldcw word [ebp - 8] - - ; Load real from stack - fld qword [ebp+8] - frndint - - ; Restore control word - fldcw word [ebp - 4] - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -; Truncates the float -_truncf: - ; Stack Frame - push ebp - mov ebp, esp - sub esp, 8 ; Allocate temporary space - - ; Save control word - fstcw word [ebp - 4] - mov dx, word [ebp - 4] - - ; Round towards -oo - or dx, 0x0C00 - mov word [ebp - 8], dx - - ; Set new rounding control - fldcw word [ebp - 8] - - ; Load real from stack - fld dword [ebp+8] - frndint - - ; Restore control word - fldcw word [ebp - 4] - - ; Unwind & return - mov esp, ebp - pop ebp - ret - -; Floors a value long -_truncl: - ; Stack Frame - push ebp - mov ebp, esp - sub esp, 8 ; Allocate temporary space - - ; Save control word - fstcw word [ebp - 4] - mov dx, word [ebp - 4] - - ; Round towards -oo - or dx, 0x0C00 - mov word [ebp - 8], dx - - ; Set new rounding control - fldcw word [ebp - 8] - - ; Load real from stack - fld tword [ebp+8] - frndint - - ; Restore control word - fldcw word [ebp - 4] - - ; Unwind & return - mov esp, ebp - pop ebp - ret \ No newline at end of file diff --git a/librt/libm/i386/bsd_npx.h b/librt/libm/i386/bsd_npx.h deleted file mode 100644 index 62437dc1a..000000000 --- a/librt/libm/i386/bsd_npx.h +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * 4. 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. - * - * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 - * $FreeBSD: src/sys/i386/include/npx.h,v 1.29.2.1 2006/07/01 00:57:55 davidxu Exp $ - */ - -/* - * 287/387 NPX Coprocessor Data Structures and Constants - * W. Jolitz 1/90 - */ - -#ifndef _MACHINE_NPX_H_ -#define _MACHINE_NPX_H_ - -#include -#include - -/* Environment information of floating point unit */ -struct env87 { - long en_cw; /* control word (16bits) */ - long en_sw; /* status word (16bits) */ - long en_tw; /* tag word (16bits) */ - long en_fip; /* floating point instruction pointer */ - unsigned short en_fcs; /* floating code segment selector */ - unsigned short en_opcode; /* opcode last executed (11 bits ) */ - long en_foo; /* floating operand offset */ - long en_fos; /* floating operand segment selector */ -}; - -/* Contents of each floating point accumulator */ -struct fpacc87 { -#ifdef dontdef /* too unportable */ - unsigned long fp_mantlo; /* mantissa low (31:0) */ - unsigned long fp_manthi; /* mantissa high (63:32) */ - int fp_exp:15; /* exponent */ - int fp_sgn:1; /* mantissa sign */ -#else - unsigned char fp_bytes[10]; -#endif -}; - -/* Floating point context */ -struct save87 { - struct env87 sv_env; /* floating point control/status */ - struct fpacc87 sv_ac[8]; /* accumulator contents, 0-7 */ - unsigned char sv_pad0[4]; /* padding for (now unused) saved status word */ - /* - * Bogus padding for emulators. Emulators should use their own - * struct and arrange to store into this struct (ending here) - * before it is inspected for ptracing or for core dumps. Some - * emulators overwrite the whole struct. We have no good way of - * knowing how much padding to leave. Leave just enough for the - * GPL emulator's i387_union (176 bytes total). - */ - unsigned char sv_pad[64]; /* padding; used by emulators */ -}; - -struct envxmm { - uint16_t en_cw; /* control word (16bits) */ - uint16_t en_sw; /* status word (16bits) */ - uint16_t en_tw; /* tag word (16bits) */ - uint16_t en_opcode; /* opcode last executed (11 bits ) */ - uint32_t en_fip; /* floating point instruction pointer */ - uint16_t en_fcs; /* floating code segment selector */ - uint16_t en_pad0; /* padding */ - uint32_t en_foo; /* floating operand offset */ - uint16_t en_fos; /* floating operand segment selector */ - uint16_t en_pad1; /* padding */ - uint32_t en_mxcsr; /* SSE sontorol/status register */ - uint32_t en_mxcsr_mask; /* valid bits in mxcsr */ -}; - -/* Contents of each SSE extended accumulator */ -struct xmmacc { - unsigned char xmm_bytes[16]; -}; - -struct savexmm { - struct envxmm sv_env; - struct { - struct fpacc87 fp_acc; - unsigned char fp_pad[6]; /* padding */ - } sv_fp[8]; - struct xmmacc sv_xmm[8]; - unsigned char sv_pad[224]; -#if defined(_MSC_VER) && !defined(__clang__) -} __declspec(align(16)); -#else -} __attribute__((__aligned__(16))); -#endif - -union savefpu { - struct save87 sv_87; - struct savexmm sv_xmm; -}; - -/* - * The hardware default control word for i387's and later coprocessors is - * 0x37F, giving: - * - * round to nearest - * 64-bit precision - * all exceptions masked. - * - * We modify the affine mode bit and precision bits in this to give: - * - * affine mode for 287's (if they work at all) (1 in bitfield 1<<12) - * 53-bit precision (2 in bitfield 3<<8) - * - * 64-bit precision often gives bad results with high level languages - * because it makes the results of calculations depend on whether - * intermediate values are stored in memory or in FPU registers. - */ -#define __INITIAL_NPXCW__ 0x127F -#define __INITIAL_MXCSR__ 0x1F80 - -#ifdef _KERNEL - -#define IO_NPX 0x0F0 /* Numeric Coprocessor */ -#define IO_NPXSIZE 16 /* 80387/80487 NPX registers */ - -#define IRQ_NPX 13 - -/* full reset on some systems, NOP on others */ -#define npx_full_reset() outb(IO_NPX + 1, 0) - -int npxdna(void); -void npxdrop(void); -void npxexit(struct thread *td); -int npxformat(void); -int npxgetregs(struct thread *td, union savefpu *addr); -void npxinit(unsigned short control); -void npxsave(union savefpu *addr); -void npxsetregs(struct thread *td, union savefpu *addr); -int npxtrap(void); -#endif - -#endif /* !_MACHINE_NPX_H_ */ \ No newline at end of file diff --git a/librt/libm/i386/fenv.c b/librt/libm/i386/fenv.c deleted file mode 100644 index 8aecb202c..000000000 --- a/librt/libm/i386/fenv.c +++ /dev/null @@ -1,208 +0,0 @@ -/*- - * Copyright (c) 2004-2005 David Schultz - * 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.8 2011/10/21 06:25:31 das Exp $ - */ - -#include -#include "bsd_npx.h" - -#define __fenv_static -#define __fenv_extern -#include - -const fenv_t __fe_dfl_env = { - __INITIAL_NPXCW__, - 0x0000, - 0x0000, - 0x1F80, - 0xFFFF, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -enum __sse_support __has_sse = -#ifdef __SSE__ - __SSE_YES; -#else - __SSE_UNK; -#endif - -#ifdef _MSC_VER -#include -#define getfl(x) x = __readeflags() -#define setfl(x) __writeeflags(x) -#define cpuid_dx(x) int cpufeats[4]; __cpuid(cpufeats, 1); x = cpufeats[3] -#else -#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") -#endif - -/* - * 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); -} - -int fesetexceptflag(const fexcept_t *flagp, int excepts) -{ - fenv_t env; - uint32_t mxcsr; - fenv_t *envp = &env; - - __fnstenv(envp); - env.__status_word &= ~excepts; - env.__status_word |= *flagp & excepts; - __fldenv(envp); - - if (__HAS_SSE()) { - __stmxcsr(mxcsr); - mxcsr &= ~excepts; - mxcsr |= *flagp & excepts; - __ldmxcsr(mxcsr); - } - - return (0); -} - -int feraiseexcept(int excepts) -{ - fexcept_t ex = (fexcept_t)excepts; - fesetexceptflag(&ex, excepts); - __fwait(); - return (0); -} - -/* fnstenv masks all exceptions, so we need to restore - * the old control word to avoid this side effect. */ -int fegetenv(fenv_t *envp) -{ - uint32_t mxcsr; - uint16_t control = envp->__control_word; - __fnstenv(envp); - __fldcw(control); - if (__HAS_SSE()) { - __stmxcsr(mxcsr); - envp->__mxcsr = mxcsr; - } - return (0); -} - -int feholdexcept(fenv_t *envp) -{ - uint32_t mxcsr; - - __fnstenv(envp); - __fnclex(); - if (__HAS_SSE()) { - __stmxcsr(mxcsr); - envp->__mxcsr = mxcsr; - mxcsr &= ~FE_ALL_EXCEPT; - mxcsr |= FE_ALL_EXCEPT << _SSE_EMASK_SHIFT; - __ldmxcsr(mxcsr); - } - return (0); -} - -int feupdateenv(const fenv_t *envp) -{ - uint32_t mxcsr; - uint16_t 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) -{ - uint32_t mxcsr, omask; - uint16_t control; - - 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) -{ - uint32_t mxcsr, omask; - uint16_t control; - - 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); -} diff --git a/librt/libm/i386/fpmath.h b/librt/libm/i386/fpmath.h deleted file mode 100644 index 3a1065511..000000000 --- a/librt/libm/i386/fpmath.h +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 2002, 2003 David Schultz - * 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/libc/i386/_fpmath.h,v 1.6 2008/01/17 16:39:06 bde Exp $ - */ - -union IEEEl2bits { - long double e; - struct { - unsigned int manl :32; - unsigned int manh :32; - unsigned int exp :15; - unsigned int sign :1; - unsigned int junk :16; - } bits; - struct { - unsigned long long man :64; - unsigned int expsign :16; - unsigned int junk : 16; - unsigned int morejunk; - } xbits; -}; - -#define LDBL_NBIT 0x80000000 -#define mask_nbit_l(u) ((u).bits.manh &= ~LDBL_NBIT) - -#define LDBL_MANH_SIZE 32 -#define LDBL_MANL_SIZE 32 - -#define LDBL_TO_ARRAY32(u, a) do { \ - (a)[0] = (uint32_t)(u).bits.manl; \ - (a)[1] = (uint32_t)(u).bits.manh; \ -} while (0) diff --git a/librt/libm/private.h b/librt/libm/private.h index bef1b3228..3d285de5a 100644 --- a/librt/libm/private.h +++ b/librt/libm/private.h @@ -69,7 +69,7 @@ union IEEEd2bits { /* This is a shortcut for MSVC double intrinsincs * that are generated ONLY by msvc, used by __CI* functions */ -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) #define FPU_DOUBLE(var) double var; \ __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var) : ) #define FPU_DOUBLES(var1,var2) double var1,var2; \