mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Make pow() conform to standard definition
This commit is contained in:
parent
754974faaa
commit
8af91bcbe7
15 changed files with 253 additions and 85 deletions
|
@ -17,18 +17,23 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
.source __FILE__
|
||||
|
||||
truncl: .profilable
|
||||
sub $24,%rsp
|
||||
fldt 32(%rsp)
|
||||
fnstcw 14(%rsp)
|
||||
movzwl 14(%rsp),%eax
|
||||
// Rounds to integer, toward zero.
|
||||
//
|
||||
// @param 𝑥 is long double passed on stack
|
||||
// @return long double in %st
|
||||
truncl: pushq %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
sub $16,%rsp
|
||||
fnstcw -2(%rbp)
|
||||
fldt 16(%rbp)
|
||||
movzwl -2(%rbp),%eax
|
||||
or $0b1100,%ah # round to zero
|
||||
mov %ax,12(%rsp)
|
||||
fldcw 12(%rsp)
|
||||
mov %ax,-4(%rbp)
|
||||
fldcw -4(%rbp)
|
||||
frndint
|
||||
fldcw 14(%rsp)
|
||||
add $24,%rsp
|
||||
fldcw -2(%rbp)
|
||||
leave
|
||||
ret
|
||||
.endfn truncl,globl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue