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
|
@ -26,6 +26,7 @@
|
|||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
#include "libc/runtime/fenv.h"
|
||||
#include "libc/tinymath/internal.h"
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
|
@ -43,8 +44,18 @@ asm(".include \"libc/disclaimer.inc\"");
|
|||
#endif
|
||||
static const float_t toint = 1/EPS;
|
||||
|
||||
/**
|
||||
* Rounds 𝑥 to nearest integer, away from zero.
|
||||
*/
|
||||
float roundf(float x)
|
||||
{
|
||||
#ifdef __aarch64__
|
||||
|
||||
asm("frinta\t%s0,%s1" : "=w"(x) : "w"(x));
|
||||
return x;
|
||||
|
||||
#else
|
||||
|
||||
union {float f; uint32_t i;} u = {x};
|
||||
int e = u.i >> 23 & 0xff;
|
||||
float_t y;
|
||||
|
@ -67,4 +78,6 @@ float roundf(float x)
|
|||
if (u.i >> 31)
|
||||
y = -y;
|
||||
return y;
|
||||
|
||||
#endif /* __aarch64__ */
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue