mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 06:48:31 +00:00
Workaround WSL misconfiguring the x87 FPU
This commit is contained in:
parent
f44d88707e
commit
d6ff4c754e
2 changed files with 26 additions and 19 deletions
|
@ -44,6 +44,32 @@ cosmo: push %rbp
|
|||
mov %eax,%r12d
|
||||
#endif /* SYSDEBUG */
|
||||
|
||||
// Windows always initializes FPU to douuble precision.
|
||||
// WSL breaks Linux ABI by initializing FPU to double precision.
|
||||
// This code makes long double long again.
|
||||
//
|
||||
// @see System V Application Binary Interface NexGen32e Architecture
|
||||
// Processor Supplement, Version 1.0, December 5th, 2018
|
||||
// Section 3.4.1: Initial Stack and Register State
|
||||
fldcw 1f(%rip)
|
||||
.rodata
|
||||
.align 2
|
||||
// 8087 FPU Control Word
|
||||
// IM: Invalid Operation ───────────────┐
|
||||
// DM: Denormal Operand ───────────────┐│
|
||||
// ZM: Zero Divide ───────────────────┐││
|
||||
// OM: Overflow ─────────────────────┐│││
|
||||
// UM: Underflow ───────────────────┐││││
|
||||
// PM: Precision ──────────────────┐│││││
|
||||
// PC: Precision Control ───────┐ ││││││
|
||||
// {float,∅,double,long double}│ ││││││
|
||||
// RC: Rounding Control ──────┐ │ ││││││
|
||||
// {even, →-∞, →+∞, →0} │┌┤ ││││││
|
||||
// ┌┤││ ││││││
|
||||
// d││││rr││││││
|
||||
1: .short 0b00000000000000000001101111111
|
||||
.previous
|
||||
|
||||
#ifdef __FAST_MATH__
|
||||
push %rax
|
||||
stmxcsr (%rsp)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue