Make improvements

- More timspec_*() and timeval_*() APIs have been introduced.
- The copyfd() function is now simplified thanks to POSIX rules.
- More Cosmo-specific APIs have been moved behind the COSMO define.
- The setitimer() polyfill for Windows NT is now much higher quality.
- Fixed build error for MODE=aarch64 due to -mstringop-strategy=loop.
- This change introduces `make MODE=nox87 toolchain` which makes it
  possible to build programs using your cosmocc toolchain that don't
  have legacy fpu instructions. This is useful, for example, if you
  want to have a ~22kb tinier blink virtual machine.
This commit is contained in:
Justine Tunney 2023-06-15 13:50:42 -07:00
parent 8dc11afcf6
commit c3440d040c
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
132 changed files with 539 additions and 587 deletions

View file

@ -12,6 +12,8 @@
// default rounding (to nearest, ties to even).
//
//===----------------------------------------------------------------------===//
#include "libc/math.h"
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
STATIC_YOINK("huge_compiler_rt_license");
@ -26,3 +28,5 @@ COMPILER_RT_ABI long double __addtf3(long double a, long double b){
}
#endif
#endif /* long double is long */

View file

@ -12,6 +12,8 @@
*
*===----------------------------------------------------------------------===
*/
#include "libc/math.h"
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
STATIC_YOINK("huge_compiler_rt_license");
@ -64,3 +66,5 @@ __divtc3(long double __a, long double __b, long double __c, long double __d)
}
return z;
}
#endif /* long double is long */

View file

@ -11,6 +11,8 @@
* This file implements __divxc3 for the compiler_rt library.
*
*/
#include "libc/math.h"
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
STATIC_YOINK("huge_compiler_rt_license");
@ -64,3 +66,5 @@ __divxc3(long double __a, long double __b, long double __c, long double __d)
}
#endif
#endif /* long double is long */

View file

@ -12,6 +12,8 @@
*
* ===----------------------------------------------------------------------===
*/
#include "libc/math.h"
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
STATIC_YOINK("huge_compiler_rt_license");
@ -47,3 +49,5 @@ __fixunsxfdi(long double a)
}
#endif
#endif /* long double is long */

View file

@ -12,6 +12,8 @@
*
* ===----------------------------------------------------------------------===
*/
#include "libc/math.h"
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
STATIC_YOINK("huge_compiler_rt_license");
@ -46,3 +48,5 @@ __fixunsxfsi(long double a)
}
#endif /* !_ARCH_PPC */
#endif /* long double is long */

View file

@ -12,6 +12,8 @@
*
* ===----------------------------------------------------------------------===
*/
#include "libc/math.h"
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
STATIC_YOINK("huge_compiler_rt_license");
@ -51,3 +53,5 @@ __fixunsxfti(long double a)
}
#endif /* CRT_HAS_128BIT */
#endif /* long double is long */

View file

@ -12,6 +12,8 @@
*
* ===----------------------------------------------------------------------===
*/
#include "libc/math.h"
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
STATIC_YOINK("huge_compiler_rt_license");
@ -49,3 +51,5 @@ __fixxfdi(long double a)
}
#endif /* !_ARCH_PPC */
#endif /* long double is long */

View file

@ -12,6 +12,8 @@
*
* ===----------------------------------------------------------------------===
*/
#include "libc/math.h"
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
STATIC_YOINK("huge_compiler_rt_license");
@ -52,3 +54,5 @@ __fixxfti(long double a)
}
#endif /* CRT_HAS_128BIT */
#endif /* long double is long */

View file

@ -29,22 +29,21 @@
#include "libc/math.h"
#include "libc/tinymath/internal.h"
#include "libc/tinymath/ldshape.internal.h"
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
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
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
/**
* Returns log𝑥 exponent part of double.
*/
int ilogbl(long double x)
{
return ilogb(x);
}
#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
int ilogbl(long double x)
{
//#pragma STDC FENV_ACCESS ON
#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
// #pragma STDC FENV_ACCESS ON
union ldshape u = {x};
uint64_t m = u.i.m;
int e = u.i.se & 0x7fff;
@ -63,11 +62,8 @@ int ilogbl(long double x)
return m<<1 ? FP_ILOGBNAN : INT_MAX;
}
return e - 0x3fff;
}
#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
int ilogbl(long double x)
{
//#pragma STDC FENV_ACCESS ON
// #pragma STDC FENV_ACCESS ON
union ldshape u = {x};
int e = u.i.se & 0x7fff;
@ -86,5 +82,7 @@ int ilogbl(long double x)
return u.f ? FP_ILOGBNAN : INT_MAX;
}
return e - 0x3fff;
}
#endif
}
#endif /* long double is long */

View file

@ -26,19 +26,14 @@
*/
#include "libc/math.h"
#if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
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
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double logbl(long double x)
{
return logb(x);
}
#else
long double logbl(long double x)
{
if (!isfinite(x))
@ -47,4 +42,5 @@ long double logbl(long double x)
return -1/(x*x);
return ilogbl(x);
}
#endif
#endif /* long double is long */