Get libc/tinymath/ compiling on aarch64

This commit is contained in:
Justine Tunney 2023-05-02 18:35:25 -07:00
parent 2b73e72d59
commit 135080fd3e
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
243 changed files with 7773 additions and 4027 deletions

View file

@ -27,16 +27,19 @@
*/
#include "libc/math.h"
#include "libc/tinymath/feval.internal.h"
#include "libc/tinymath/internal.h"
#include "libc/tinymath/ldshape.internal.h"
asm(".ident\t\"\\n\\n\
Musl libc (MIT License)\\n\
Copyright 2005-2014 Rich Felker, et. al.\"");
asm(".include \"libc/disclaimer.inc\"");
/* clang-format off */
// clang-format off
long double nextafterl(long double x, long double y)
{
long double nextafterl(long double x, long double y) {
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
return nextafter(x, y);
#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
union ldshape ux, uy;
if (isnan(x) || isnan(y))
@ -67,6 +70,35 @@ long double nextafterl(long double x, long double y)
return x + x;
/* raise underflow if ux is subnormal or zero */
if ((ux.i.se & 0x7fff) == 0)
fevall(x*x + ux.f*ux.f);
FORCE_EVAL(x*x + ux.f*ux.f);
return ux.f;
#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
union ldshape ux, uy;
if (isnan(x) || isnan(y))
return x + y;
if (x == y)
return y;
ux.f = x;
if (x == 0) {
uy.f = y;
ux.i.lo = 1;
ux.i.se = uy.i.se & 0x8000;
} else if ((x < y) == !(ux.i.se & 0x8000)) {
ux.i2.lo++;
if (ux.i2.lo == 0)
ux.i2.hi++;
} else {
if (ux.i2.lo == 0)
ux.i2.hi--;
ux.i2.lo--;
}
/* raise overflow if ux is infinite and x is finite */
if ((ux.i.se & 0x7fff) == 0x7fff)
return x + x;
/* raise underflow if ux is subnormal or zero */
if ((ux.i.se & 0x7fff) == 0)
FORCE_EVAL(x*x + ux.f*ux.f);
return ux.f;
#endif
}