mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +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/tinymath/internal.h"
|
||||
#include "third_party/intel/smmintrin.internal.h"
|
||||
#include "third_party/libcxx/math.h"
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
|
@ -34,8 +35,35 @@ Copyright 2005-2014 Rich Felker, et. al.\"");
|
|||
asm(".include \"libc/disclaimer.inc\"");
|
||||
// clang-format off
|
||||
|
||||
/**
|
||||
* Returns largest integral value not greater than 𝑥.
|
||||
*/
|
||||
float floorf(float x)
|
||||
{
|
||||
#ifdef __aarch64__
|
||||
|
||||
asm("frintm\t%s0,%s1" : "=w"(x) : "w"(x));
|
||||
return x;
|
||||
|
||||
#elif defined(__powerpc64__) && defined(_ARCH_PWR5X)
|
||||
|
||||
asm("frim\t%0,%1" : "=f"(x) : "f"(x));
|
||||
return x;
|
||||
|
||||
#elif defined(__s390x__) && (defined(__HTM__) || __ARCH__ >= 9)
|
||||
|
||||
asm("fiebra\t%0,7,%1,4" : "=f"(x) : "f"(x));
|
||||
return x;
|
||||
|
||||
#elif defined(__x86_64__) && defined(__SSE4_1__)
|
||||
|
||||
asm("roundss\t%2,%1,%0"
|
||||
: "=x"(x)
|
||||
: "x"(x), "i"(_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC));
|
||||
return x;
|
||||
|
||||
#else
|
||||
|
||||
union {float f; uint32_t i;} u = {x};
|
||||
int e = (int)(u.i >> 23 & 0xff) - 0x7f;
|
||||
uint32_t m;
|
||||
|
@ -58,4 +86,6 @@ float floorf(float x)
|
|||
u.f = -1.0;
|
||||
}
|
||||
return u.f;
|
||||
|
||||
#endif /* __aarch64__ */
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue