mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Make further progress on non-x86 support
This commit is contained in:
parent
aef9a69a60
commit
036b9a0002
155 changed files with 2307 additions and 653 deletions
|
@ -18,6 +18,21 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* Rounds to nearest integer.
|
||||
*/
|
||||
long lrintf(float x) {
|
||||
return rintf(x);
|
||||
long res;
|
||||
#ifdef __x86_64__
|
||||
asm("cvtss2si\t%1,%0" : "=res"(res) : "x"(x));
|
||||
#elif defined(__aarch64__)
|
||||
asm("frintx\t%s1,%s1\n\t"
|
||||
"fcvtzs\t%x0,%s1"
|
||||
: "=r"(res), "+w"(x));
|
||||
#elif defined(__powerpc64__)
|
||||
asm("fctid\t%0,%1" : "=d"(res) : "f"(x));
|
||||
#else
|
||||
res = rintf(x);
|
||||
#endif /* __x86_64__ */
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue