mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Fix issues revealed by ECMAScript test262
Cosmopolitan's QuickJS is now equally conformant and performant, with the exception of Atomics, which have been disabled since Cosmopolitan currently doesn't support pthreads. QuickJS memory usage -- BigNum 2021-03-27 version, 64-bit, malloc limit: -1 NAME COUNT SIZE memory allocated 937 131764 (140.6 per block) memory used 938 116103 (8 overhead, 16.7 average slack) atoms 513 21408 (41.7 per atom) objects 170 12279 (72.2 per object) properties 864 15531 (5.1 per object) shapes 58 12995 (224.1 per shape) bytecode functions 13 1512 bytecode 13 867 (66.7 per function) C functions 99 arrays 1 fast arrays 1 elements 1 16 (1.0 per fast array) Result: 35/74740 errors, 1279 excluded, 485 skipped, 19 new, 2 fixed real 2m40.828s user 2m29.764s sys 0m10.939s
This commit is contained in:
parent
8f52c0d773
commit
8a91518633
38 changed files with 395 additions and 184 deletions
Binary file not shown.
|
@ -69,6 +69,9 @@ CONFIG_CCFLAGS += \
|
|||
$(BACKTRACES) \
|
||||
-O2
|
||||
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
|
||||
endif
|
||||
|
||||
# Debug Mode
|
||||
|
@ -88,7 +91,7 @@ CONFIG_CPPFLAGS += \
|
|||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
$(FTRACE) \
|
||||
-O2
|
||||
-Og
|
||||
|
||||
CONFIG_COPTS += \
|
||||
$(SECURITY_BLANKETS) \
|
||||
|
|
52
examples/walk.c
Normal file
52
examples/walk.c
Normal file
|
@ -0,0 +1,52 @@
|
|||
#if 0
|
||||
/*─────────────────────────────────────────────────────────────────╗
|
||||
│ To the extent possible under law, Justine Tunney has waived │
|
||||
│ all copyright and related or neighboring rights to this file, │
|
||||
│ as it is written in the following disclaimers: │
|
||||
│ • http://unlicense.org/ │
|
||||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "third_party/musl/ftw.h"
|
||||
|
||||
/**
|
||||
* @fileoverview Directory walker example.
|
||||
* Copied from IEEE Std 1003.1-2017
|
||||
*/
|
||||
|
||||
static int display_info(const char *fpath, const struct stat *sb, int tflag,
|
||||
struct FTW *ftwbuf) {
|
||||
printf("%-3s %2d %7jd %-40s %d %s\n",
|
||||
(tflag == FTW_D) ? "d"
|
||||
: (tflag == FTW_DNR) ? "dnr"
|
||||
: (tflag == FTW_DP) ? "dp"
|
||||
: (tflag == FTW_F) ? (S_ISBLK(sb->st_mode) ? "f b"
|
||||
: S_ISCHR(sb->st_mode) ? "f c"
|
||||
: S_ISFIFO(sb->st_mode) ? "f p"
|
||||
: S_ISREG(sb->st_mode) ? "f r"
|
||||
: S_ISSOCK(sb->st_mode) ? "f s"
|
||||
: "f ?")
|
||||
: (tflag == FTW_NS) ? "ns"
|
||||
: (tflag == FTW_SL) ? "sl"
|
||||
: (tflag == FTW_SLN) ? "sln"
|
||||
: "?",
|
||||
ftwbuf->level, (intmax_t)sb->st_size, fpath, ftwbuf->base,
|
||||
fpath + ftwbuf->base);
|
||||
return 0; /* To tell nftw() to continue */
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int flags = 0;
|
||||
if (argc > 2 && strchr(argv[2], 'd') != NULL) flags |= FTW_DEPTH;
|
||||
if (argc > 2 && strchr(argv[2], 'p') != NULL) flags |= FTW_PHYS;
|
||||
if (nftw((argc < 2) ? "." : argv[1], display_info, 20, flags) == -1) {
|
||||
perror("nftw");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
|
@ -18,8 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/runtime/fenv.h"
|
||||
|
||||
/* TODO(jart): This needs tests. */
|
||||
|
||||
/**
|
||||
* Sets rounding mode.
|
||||
*
|
||||
|
|
|
@ -19,16 +19,18 @@
|
|||
#include "libc/runtime/fenv.h"
|
||||
|
||||
int __flt_rounds(void) {
|
||||
switch (fegetround()) {
|
||||
case FE_TOWARDZERO:
|
||||
int x87cw;
|
||||
asm("fnstcw\t%0" : "=m"(x87cw));
|
||||
switch ((x87cw & 0x0c00) >> 10) {
|
||||
case FE_TOWARDZERO >> 10:
|
||||
return 0;
|
||||
case FE_TONEAREST:
|
||||
case FE_TONEAREST >> 10:
|
||||
return 1;
|
||||
case FE_UPWARD:
|
||||
case FE_UPWARD >> 10:
|
||||
return 2;
|
||||
case FE_DOWNWARD:
|
||||
case FE_DOWNWARD >> 10:
|
||||
return 3;
|
||||
default:
|
||||
return -1;
|
||||
unreachable;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,9 @@
|
|||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
|
||||
testonly char *testlib_formatfloat(long double x) {
|
||||
char buf[32];
|
||||
char *str = malloc(256);
|
||||
g_xfmt_p(buf, &x, 15, sizeof(buf), 0);
|
||||
sprintf(str, "%Lf (%s)", x, buf);
|
||||
return str;
|
||||
return xasprintf("%.15Lg", x);
|
||||
}
|
||||
|
|
|
@ -22,5 +22,5 @@
|
|||
* Returns inverse hyperbolic tangent of 𝑥.
|
||||
*/
|
||||
double atanh(double x) {
|
||||
return log((1 + x) / (1 - x)) / 2;
|
||||
return x ? log((1 + x) / (1 - x)) / 2 : x;
|
||||
}
|
||||
|
|
|
@ -22,5 +22,5 @@
|
|||
* Returns inverse hyperbolic tangent of 𝑥.
|
||||
*/
|
||||
float atanhf(float x) {
|
||||
return logf((1 + x) / (1 - x)) / 2;
|
||||
return x ? logf((1 + x) / (1 - x)) / 2 : x;
|
||||
}
|
||||
|
|
|
@ -22,5 +22,5 @@
|
|||
* Returns inverse hyperbolic tangent of 𝑥.
|
||||
*/
|
||||
long double atanhl(long double x) {
|
||||
return logl((1 + x) / (1 - x)) / 2;
|
||||
return x ? logl((1 + x) / (1 - x)) / 2 : x;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "libc/runtime/pc.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
// Returns 𝑒^x-1.
|
||||
// Returns 𝑒^𝑥-𝟷.
|
||||
//
|
||||
// @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
|
||||
// @return result of exponentiation on FPU stack in %st
|
||||
|
@ -27,11 +27,13 @@ expm1l: push %rbp
|
|||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 16(%rbp)
|
||||
fxam # isinf(x)
|
||||
fxam
|
||||
fstsw %ax
|
||||
mov %ah,%al
|
||||
and $0x45,%ah
|
||||
cmp $5,%ah
|
||||
and $(FPU_C3|FPU_C2|FPU_C0)>>8,%ah
|
||||
cmp $(FPU_C3)>>8,%ah # !x
|
||||
je 0f
|
||||
cmp $(FPU_C2|FPU_C0)>>8,%ah # isinf(x)
|
||||
je 1f
|
||||
fldl2e
|
||||
fmulp %st,%st(1)
|
||||
|
@ -50,7 +52,7 @@ expm1l: push %rbp
|
|||
faddp %st,%st(1)
|
||||
0: pop %rbp
|
||||
ret
|
||||
1: test $2,%al # signbit(x)
|
||||
1: test $FPU_C1>>8,%al # signbit(x)
|
||||
jz 0b
|
||||
fstp %st
|
||||
fld1
|
||||
|
|
|
@ -46,7 +46,11 @@ long double powl(long double x, long double y) {
|
|||
return 1;
|
||||
}
|
||||
} else if (y > 0) {
|
||||
return y == 1 ? x : 0;
|
||||
if (signbit(x) && y == truncl(y) && ((int64_t)y & 1)) {
|
||||
return -0.;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else if (!y) {
|
||||
return 1;
|
||||
} else {
|
||||
|
|
|
@ -22,5 +22,6 @@
|
|||
* Returns hyperbolic sine of 𝑥.
|
||||
*/
|
||||
double sinh(double x) {
|
||||
if (!x) return x;
|
||||
return (exp(x) - exp(-x)) / 2;
|
||||
}
|
||||
|
|
|
@ -22,5 +22,6 @@
|
|||
* Returns hyperbolic sine of 𝑥.
|
||||
*/
|
||||
float sinhf(float x) {
|
||||
if (!x) return x;
|
||||
return (expf(x) - expf(-x)) / 2;
|
||||
}
|
||||
|
|
|
@ -22,5 +22,6 @@
|
|||
* Returns hyperbolic sine of 𝑥.
|
||||
*/
|
||||
long double sinhl(long double x) {
|
||||
if (!x) return x;
|
||||
return (expl(x) - expl(-x)) / 2;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* Returns hyperbolic tangent of 𝑥.
|
||||
*/
|
||||
double tanh(double x) {
|
||||
if (!x) return x;
|
||||
if (isinf(x)) return copysign(1, x);
|
||||
return sinh(x) / cosh(x);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* Returns hyperbolic tangent of 𝑥.
|
||||
*/
|
||||
float tanhf(float x) {
|
||||
if (!x) return x;
|
||||
if (isinf(x)) return copysignf(1, x);
|
||||
return sinhf(x) / coshf(x);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* Returns hyperbolic tangent of 𝑥.
|
||||
*/
|
||||
long double tanhl(long double x) {
|
||||
if (!x) return x;
|
||||
if (isinf(x)) return copysignl(1, x);
|
||||
return sinhl(x) / coshl(x);
|
||||
}
|
||||
|
|
|
@ -282,6 +282,11 @@ TEST(atan2, test) {
|
|||
gc(xasprintf("%.15g", atan2(__DBL_MAX__, __DBL_MIN__))));
|
||||
EXPECT_STREQ("0.785398163397448",
|
||||
gc(xasprintf("%.15g", atan2(__DBL_MAX__, __DBL_MAX__))));
|
||||
EXPECT_STREQ("-0",
|
||||
gc(xasprintf("%.15g", atan2(-0.000000000000001, INFINITY))));
|
||||
EXPECT_STREQ("-0", gc(xasprintf("%.15g", atan2(-1, INFINITY))));
|
||||
EXPECT_STREQ(
|
||||
"-0", gc(xasprintf("%.15g", atan2(-1.7976931348623157e308, INFINITY))));
|
||||
}
|
||||
|
||||
BENCH(atan2, bench) {
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
TEST(atanh, test) {
|
||||
EXPECT_STREQ("0", gc(xdtoa(atanh(0))));
|
||||
EXPECT_STREQ("-0", gc(xdtoa(atanh(-0.))));
|
||||
EXPECT_STREQ(".549306144334055", gc(xdtoa(atanh(.5))));
|
||||
EXPECT_STREQ("-.549306144334055", gc(xdtoa(atanh(-.5))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoa(atanh(+1))));
|
||||
|
@ -37,6 +38,7 @@ TEST(atanh, test) {
|
|||
|
||||
TEST(atanhl, test) {
|
||||
EXPECT_STREQ("0", gc(xdtoal(atanhl(0))));
|
||||
EXPECT_STREQ("-0", gc(xdtoal(atanhl(-0.))));
|
||||
EXPECT_STREQ(".5493061443340548", gc(xdtoal(atanhl(.5))));
|
||||
EXPECT_STREQ("-.5493061443340548", gc(xdtoal(atanhl(-.5))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoal(atanhl(+1))));
|
||||
|
@ -47,6 +49,7 @@ TEST(atanhl, test) {
|
|||
|
||||
TEST(atanhf, test) {
|
||||
EXPECT_STREQ("0", gc(xdtoaf(atanhf(0))));
|
||||
EXPECT_STREQ("-0", gc(xdtoaf(atanhf(-0.))));
|
||||
EXPECT_STREQ(".549306", gc(xdtoaf(atanhf(.5))));
|
||||
EXPECT_STREQ("-.549306", gc(xdtoaf(atanhf(-.5))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoaf(atanhf(+1))));
|
||||
|
|
|
@ -25,11 +25,37 @@
|
|||
#define expm1(x) expm1(VEIL("x", (double)(x)))
|
||||
#define expm1f(x) expm1f(VEIL("x", (float)(x)))
|
||||
|
||||
TEST(expm1, test) {
|
||||
EXPECT_STREQ("0", gc(xdtoa(expm1(0))));
|
||||
EXPECT_STREQ("-0", gc(xdtoa(expm1(-0.))));
|
||||
EXPECT_STREQ("NAN", gc(xdtoa(expm1(NAN))));
|
||||
EXPECT_STREQ("-1", gc(xdtoa(expm1(-INFINITY))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoa(expm1(INFINITY))));
|
||||
/* EXPECT_STREQ("-INFINITY", gc(xdtoa(expm1(-132098844872390)))); */
|
||||
/* EXPECT_STREQ("INFINITY", gc(xdtoa(expm1(132098844872390)))); */
|
||||
EXPECT_STREQ("0", gc(xasprintf("%.15g", expm1(0.))));
|
||||
EXPECT_STREQ("-0", gc(xasprintf("%.15g", expm1(-0.))));
|
||||
EXPECT_STREQ("0.648721270700128", gc(xasprintf("%.15g", expm1(.5))));
|
||||
EXPECT_STREQ("-0.393469340287367", gc(xasprintf("%.15g", expm1(-.5))));
|
||||
EXPECT_STREQ("1.71828182845905", gc(xasprintf("%.15g", expm1(1.))));
|
||||
EXPECT_STREQ("-0.632120558828558", gc(xasprintf("%.15g", expm1(-1.))));
|
||||
EXPECT_STREQ("3.48168907033806", gc(xasprintf("%.15g", expm1(1.5))));
|
||||
EXPECT_STREQ("-0.77686983985157", gc(xasprintf("%.15g", expm1(-1.5))));
|
||||
EXPECT_STREQ("6.38905609893065", gc(xasprintf("%.15g", expm1(2.))));
|
||||
EXPECT_TRUE(isnan(expm1(NAN)));
|
||||
EXPECT_TRUE(isnan(expm1(-NAN)));
|
||||
EXPECT_STREQ("inf", gc(xasprintf("%.15g", expm1(INFINITY))));
|
||||
EXPECT_STREQ("-1", gc(xasprintf("%.15g", expm1(-INFINITY))));
|
||||
EXPECT_STREQ("2.2250738585072e-308",
|
||||
gc(xasprintf("%.15g", expm1(__DBL_MIN__))));
|
||||
EXPECT_STREQ("inf", gc(xasprintf("%.15g", expm1(__DBL_MAX__))));
|
||||
}
|
||||
|
||||
TEST(expm1l, test) {
|
||||
EXPECT_STREQ("1.718281828459045", gc(xdtoal(expm1l(1))));
|
||||
EXPECT_STREQ("1.718281828459045", gc(xdtoal(expl(1) - 1)));
|
||||
EXPECT_STREQ("0", gc(xdtoal(expm1l(0))));
|
||||
EXPECT_STREQ("0", gc(xdtoal(expm1l(-0.))));
|
||||
EXPECT_STREQ("-0", gc(xdtoal(expm1l(-0.))));
|
||||
EXPECT_STREQ("NAN", gc(xdtoal(expm1l(NAN))));
|
||||
EXPECT_STREQ("-1", gc(xdtoal(expm1l(-INFINITY))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoal(expm1l(INFINITY))));
|
||||
|
@ -37,19 +63,9 @@ TEST(expm1l, test) {
|
|||
/* EXPECT_STREQ("INFINITY", gc(xdtoal(expm1l(132098844872390)))); */
|
||||
}
|
||||
|
||||
TEST(expm1, test) {
|
||||
EXPECT_STREQ("0", gc(xdtoa(expm1(0))));
|
||||
EXPECT_STREQ("0", gc(xdtoa(expm1(-0.))));
|
||||
EXPECT_STREQ("NAN", gc(xdtoa(expm1(NAN))));
|
||||
EXPECT_STREQ("-1", gc(xdtoa(expm1(-INFINITY))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoa(expm1(INFINITY))));
|
||||
/* EXPECT_STREQ("-INFINITY", gc(xdtoa(expm1(-132098844872390)))); */
|
||||
/* EXPECT_STREQ("INFINITY", gc(xdtoa(expm1(132098844872390)))); */
|
||||
}
|
||||
|
||||
TEST(expm1f, test) {
|
||||
EXPECT_STREQ("0", gc(xdtoaf(expm1f(0))));
|
||||
EXPECT_STREQ("0", gc(xdtoaf(expm1f(-0.))));
|
||||
EXPECT_STREQ("-0", gc(xdtoaf(expm1f(-0.))));
|
||||
EXPECT_STREQ("NAN", gc(xdtoaf(expm1f(NAN))));
|
||||
EXPECT_STREQ("-1", gc(xdtoaf(expm1f(-INFINITY))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoaf(expm1f(INFINITY))));
|
||||
|
|
|
@ -100,6 +100,8 @@ TEST(powl, test) {
|
|||
EXPECT_TRUE(isnan(powl(-3, -(1. / MAX(rando, 2)))));
|
||||
EXPECT_STREQ("-.3333333333333333", gc(xdtoal(powl(-3, -1))));
|
||||
EXPECT_STREQ(".1111111111111111", gc(xdtoal(powl(-3, -2))));
|
||||
EXPECT_STREQ("-0", gc(xdtoal(powl(-0., MAX(1, rando) | 1))));
|
||||
EXPECT_STREQ("0", gc(xdtoal(powl(-0., MAX(1, rando) & ~1))));
|
||||
}
|
||||
|
||||
TEST(pow, test) {
|
||||
|
@ -150,6 +152,8 @@ TEST(pow, test) {
|
|||
EXPECT_STREQ("inf", fmtd(pow(-0., -(rando & -2))));
|
||||
EXPECT_STREQ("-0.333333333333333", fmtd(pow(-3, -1)));
|
||||
EXPECT_STREQ("0.111111111111111", fmtd(pow(-3, -2)));
|
||||
EXPECT_STREQ("-0", gc(xdtoa(pow(-0., MAX(1, rando) | 1))));
|
||||
EXPECT_STREQ("0", gc(xdtoa(pow(-0., MAX(1, rando) & ~1))));
|
||||
}
|
||||
|
||||
TEST(powf, test) {
|
||||
|
@ -200,6 +204,8 @@ TEST(powf, test) {
|
|||
EXPECT_STREQ("inf", fmtf(powf(-0., -(rando & -2))));
|
||||
EXPECT_STREQ("-0.333333", fmtf(powf(-3, -1)));
|
||||
EXPECT_STREQ("0.111111", fmtf(powf(-3, -2)));
|
||||
EXPECT_STREQ("-0", gc(xdtoaf(powf(-0., MAX(1, rando) | 1))));
|
||||
EXPECT_STREQ("0", gc(xdtoaf(powf(-0., MAX(1, rando) & ~1))));
|
||||
}
|
||||
|
||||
TEST(powl, errors) {
|
||||
|
@ -537,6 +543,15 @@ TEST(powl, errors) {
|
|||
errno = 0;
|
||||
EXPECT_STREQ("inf", fmtd(pow(__DBL_MAX__, __DBL_MAX__)));
|
||||
/* EXPECT_EQ(ERANGE, errno); */
|
||||
EXPECT_STREQ("1", gc(xasprintf("%.15g", pow(0., 0))));
|
||||
EXPECT_STREQ("1", gc(xasprintf("%.15g", pow(-0., 0))));
|
||||
EXPECT_STREQ("-0", gc(xasprintf("%.15g", pow(-0., 1))));
|
||||
EXPECT_STREQ("-0", gc(xasprintf("%.15g", pow(-0., 11))));
|
||||
EXPECT_STREQ("-0", gc(xasprintf("%.15g", pow(-0., 111))));
|
||||
EXPECT_STREQ("0", gc(xasprintf("%.15g", pow(-0., 2))));
|
||||
EXPECT_STREQ("0", gc(xasprintf("%.15g", pow(-0., 22))));
|
||||
EXPECT_STREQ("0", gc(xasprintf("%.15g", pow(-0., 222))));
|
||||
EXPECT_STREQ("0", gc(xasprintf("%.15g", pow(-0., 2.5))));
|
||||
}
|
||||
|
||||
BENCH(powl, bench) {
|
||||
|
|
|
@ -31,6 +31,7 @@ TEST(sinh, test) {
|
|||
EXPECT_STREQ("INFINITY", gc(xdtoa(sinh(30000))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoa(sinh(-30000))));
|
||||
EXPECT_STREQ("0", gc(xdtoa(sinh(0))));
|
||||
EXPECT_STREQ("-0", gc(xdtoa(sinh(-0.))));
|
||||
EXPECT_STREQ("NAN", gc(xdtoa(sinh(NAN))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoa(sinh(INFINITY))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoa(sinh(-INFINITY))));
|
||||
|
@ -42,6 +43,7 @@ TEST(sinhl, test) {
|
|||
EXPECT_STREQ("INFINITY", gc(xdtoal(sinhl(30000))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoal(sinhl(-30000))));
|
||||
EXPECT_STREQ("0", gc(xdtoal(sinhl(0))));
|
||||
EXPECT_STREQ("-0", gc(xdtoal(sinhl(-0.))));
|
||||
EXPECT_STREQ("NAN", gc(xdtoal(sinhl(NAN))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoal(sinhl(INFINITY))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoal(sinhl(-INFINITY))));
|
||||
|
@ -53,6 +55,7 @@ TEST(sinhf, test) {
|
|||
EXPECT_STREQ("INFINITY", gc(xdtoaf(sinhf(30000))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoaf(sinhf(-30000))));
|
||||
EXPECT_STREQ("0", gc(xdtoaf(sinhf(0))));
|
||||
EXPECT_STREQ("-0", gc(xdtoaf(sinhf(-0.))));
|
||||
EXPECT_STREQ("NAN", gc(xdtoaf(sinhf(NAN))));
|
||||
EXPECT_STREQ("INFINITY", gc(xdtoaf(sinhf(INFINITY))));
|
||||
EXPECT_STREQ("-INFINITY", gc(xdtoaf(sinhf(-INFINITY))));
|
||||
|
|
57
test/libc/tinymath/strtod_test.c
Normal file
57
test/libc/tinymath/strtod_test.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/runtime/fenv.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/gdtoa/gdtoa.h"
|
||||
|
||||
int oldround;
|
||||
|
||||
void SetUp(void) {
|
||||
oldround = fegetround();
|
||||
}
|
||||
|
||||
void TearDown(void) {
|
||||
fesetround(oldround);
|
||||
}
|
||||
|
||||
TEST(strtod, testNearest) {
|
||||
fesetround(FE_TONEAREST);
|
||||
EXPECT_STREQ("-1.79769313486231e+308",
|
||||
gc(xasprintf("%.15g", strtod("-1.79769313486231e+308", NULL))));
|
||||
}
|
||||
|
||||
TEST(strtod, testDownward) {
|
||||
fesetround(FE_DOWNWARD);
|
||||
EXPECT_STREQ("-1.79769313486232e+308",
|
||||
gc(xasprintf("%.15g", strtod("-1.79769313486231e+308", NULL))));
|
||||
}
|
||||
|
||||
TEST(strtod, testUpward) {
|
||||
fesetround(FE_UPWARD);
|
||||
EXPECT_STREQ("-1.7976931348623e+308",
|
||||
gc(xasprintf("%.15g", strtod("-1.79769313486231e+308", NULL))));
|
||||
}
|
||||
|
||||
TEST(strtod, testTowardzero) {
|
||||
fesetround(FE_TOWARDZERO);
|
||||
EXPECT_STREQ("-1.7976931348623e+308",
|
||||
gc(xasprintf("%.15g", strtod("-1.79769313486231e+308", NULL))));
|
||||
}
|
|
@ -29,6 +29,7 @@ TEST(tanhl, test) {
|
|||
EXPECT_STREQ(".09966799462495582", gc(xdtoal(tanhl(+.1))));
|
||||
EXPECT_STREQ("-.09966799462495582", gc(xdtoal(tanhl(-.1))));
|
||||
EXPECT_STREQ("0", gc(xdtoal(tanhl(0))));
|
||||
EXPECT_STREQ("-0", gc(xdtoal(tanhl(-0.))));
|
||||
EXPECT_TRUE(isnan(tanhl(NAN)));
|
||||
EXPECT_STREQ("1", gc(xdtoal(tanhl(INFINITY))));
|
||||
EXPECT_STREQ("-1", gc(xdtoal(tanhl(-INFINITY))));
|
||||
|
@ -38,6 +39,7 @@ TEST(tanh, test) {
|
|||
EXPECT_STREQ(".0996679946249559", gc(xdtoa(tanh(+.1))));
|
||||
EXPECT_STREQ("-.0996679946249559", gc(xdtoa(tanh(-.1))));
|
||||
EXPECT_STREQ("0", gc(xdtoa(tanh(0))));
|
||||
EXPECT_STREQ("-0", gc(xdtoa(tanh(-0.))));
|
||||
EXPECT_TRUE(isnan(tanh(NAN)));
|
||||
EXPECT_STREQ("1", gc(xdtoa(tanh(INFINITY))));
|
||||
EXPECT_STREQ("-1", gc(xdtoa(tanh(-INFINITY))));
|
||||
|
@ -47,6 +49,7 @@ TEST(tanhf, test) {
|
|||
EXPECT_STREQ(".099668", gc(xdtoaf(tanhf(+.1))));
|
||||
EXPECT_STREQ("-.099668", gc(xdtoaf(tanhf(-.1))));
|
||||
EXPECT_STREQ("0", gc(xdtoaf(tanhf(0))));
|
||||
EXPECT_STREQ("-0", gc(xdtoaf(tanhf(-0.))));
|
||||
EXPECT_TRUE(isnan(tanhf(NAN)));
|
||||
EXPECT_STREQ("1", gc(xdtoaf(tanhf(INFINITY))));
|
||||
EXPECT_STREQ("-1", gc(xdtoaf(tanhf(-INFINITY))));
|
||||
|
|
|
@ -37,7 +37,8 @@ TEST_LIBC_TINYMATH_DIRECTDEPS = \
|
|||
LIBC_TESTLIB \
|
||||
LIBC_TINYMATH \
|
||||
LIBC_UNICODE \
|
||||
LIBC_X
|
||||
LIBC_X \
|
||||
THIRD_PARTY_GDTOA
|
||||
|
||||
TEST_LIBC_TINYMATH_DEPS := \
|
||||
$(call uniq,$(foreach x,$(TEST_LIBC_TINYMATH_DIRECTDEPS),$($(x))))
|
||||
|
|
3
third_party/gdtoa/gdtoa.internal.h
vendored
3
third_party/gdtoa/gdtoa.internal.h
vendored
|
@ -18,6 +18,9 @@ asm(".include \"libc/disclaimer.inc\"");
|
|||
#define d_QNAN0 0x7ff80000
|
||||
#define d_QNAN1 0x0
|
||||
|
||||
#define Check_FLT_ROUNDS 1
|
||||
#define Trust_FLT_ROUNDS 1
|
||||
|
||||
/****************************************************************
|
||||
|
||||
The author of this software is David M. Gay.
|
||||
|
|
7
third_party/gdtoa/gdtoa.mk
vendored
7
third_party/gdtoa/gdtoa.mk
vendored
|
@ -46,13 +46,6 @@ $(THIRD_PARTY_GDTOA_A).pkg: \
|
|||
$(THIRD_PARTY_GDTOA_A_OBJS) \
|
||||
$(foreach x,$(THIRD_PARTY_GDTOA_A_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
||||
$(THIRD_PARTY_GDTOA_A_OBJS): \
|
||||
OVERRIDE_CFLAGS += \
|
||||
$(OLD_CODE) \
|
||||
$(IEEE_MATH) \
|
||||
-ffunction-sections \
|
||||
-fdata-sections
|
||||
|
||||
THIRD_PARTY_GDTOA_LIBS = $(foreach x,$(THIRD_PARTY_GDTOA_ARTIFACTS),$($(x)))
|
||||
THIRD_PARTY_GDTOA_SRCS = $(foreach x,$(THIRD_PARTY_GDTOA_ARTIFACTS),$($(x)_SRCS))
|
||||
THIRD_PARTY_GDTOA_HDRS = $(foreach x,$(THIRD_PARTY_GDTOA_ARTIFACTS),$($(x)_HDRS))
|
||||
|
|
2
third_party/gdtoa/strtod.c
vendored
2
third_party/gdtoa/strtod.c
vendored
|
@ -729,7 +729,7 @@ strtod(CONST char *s00, char **se)
|
|||
}
|
||||
#endif /*Sudden_Underflow*/
|
||||
#endif /*Avoid_Underflow*/
|
||||
dval(&adj) *= ulp(&rv);
|
||||
dval(&adj) *= ulp(&rv); /* XXX */
|
||||
if (dsign) {
|
||||
if (word0(&rv) == Big0 && word1(&rv) == Big1)
|
||||
goto ovfl;
|
||||
|
|
2
third_party/lua/lua.mk
vendored
2
third_party/lua/lua.mk
vendored
|
@ -41,7 +41,7 @@ THIRD_PARTY_LUA_DEPS := \
|
|||
$(THIRD_PARTY_LUA_A): \
|
||||
third_party/lua/ \
|
||||
$(THIRD_PARTY_LUA_A).pkg \
|
||||
$(filter-out %/lua.c,$(THIRD_PARTY_LUA_OBJS))
|
||||
$(filter-out %/lua.o,$(THIRD_PARTY_LUA_OBJS))
|
||||
|
||||
$(THIRD_PARTY_LUA_A).pkg: \
|
||||
$(THIRD_PARTY_LUA_OBJS) \
|
||||
|
|
6
third_party/musl/ftw.c
vendored
6
third_party/musl/ftw.c
vendored
|
@ -34,6 +34,12 @@ asm(".include \"libc/disclaimer.inc\"");
|
|||
|
||||
/* clang-format off */
|
||||
|
||||
/**
|
||||
* Walks file tree.
|
||||
*
|
||||
* @see examples/walk.c for example
|
||||
* @see nftw()
|
||||
*/
|
||||
int ftw(const char *path, int (*fn)(const char *, const struct stat *, int), int fd_limit)
|
||||
{
|
||||
/* The following cast assumes that calling a function with one
|
||||
|
|
19
third_party/musl/nftw.c
vendored
19
third_party/musl/nftw.c
vendored
|
@ -38,7 +38,13 @@ Musl libc (MIT License)\\n\
|
|||
Copyright 2005-2014 Rich Felker, et. al.\"");
|
||||
asm(".include \"libc/disclaimer.inc\"");
|
||||
|
||||
#define pthread_setcancelstate(...) /* no cosmo pthreads support atm */
|
||||
/* no reason to impose windows limit
|
||||
small enough to fit in stack frame
|
||||
should be changed to use realloc */
|
||||
#define PATH_MAX2 2048
|
||||
|
||||
/* no cosmo pthreads support atm */
|
||||
#define pthread_setcancelstate(...)
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -123,7 +129,7 @@ static int do_nftw(char *path, int (*fn)(const char *, const struct stat *, int,
|
|||
&& (!de->d_name[1]
|
||||
|| (de->d_name[1]=='.'
|
||||
&& !de->d_name[2]))) continue;
|
||||
if (strlen(de->d_name) >= PATH_MAX-l) {
|
||||
if (strlen(de->d_name) >= PATH_MAX2-l) {
|
||||
errno = ENAMETOOLONG;
|
||||
closedir(d);
|
||||
return -1;
|
||||
|
@ -149,16 +155,21 @@ static int do_nftw(char *path, int (*fn)(const char *, const struct stat *, int,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Walks file tree.
|
||||
*
|
||||
* @see examples/walk.c for example
|
||||
*/
|
||||
int nftw(const char *path, int (*fn)(const char *, const struct stat *, int, struct FTW *), int fd_limit, int flags)
|
||||
{
|
||||
int r, cs;
|
||||
size_t l;
|
||||
char pathbuf[PATH_MAX+1];
|
||||
char pathbuf[PATH_MAX2+1];
|
||||
|
||||
if (fd_limit <= 0) return 0;
|
||||
|
||||
l = strlen(path);
|
||||
if (l > PATH_MAX) {
|
||||
if (l > PATH_MAX2) {
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
|
|
7
third_party/quickjs/README.cosmo
vendored
7
third_party/quickjs/README.cosmo
vendored
|
@ -1,2 +1,7 @@
|
|||
Source:
|
||||
https://bellard.org/quickjs/quickjs-2021-03-27.tar.xz
|
||||
- https://bellard.org/quickjs/quickjs-2021-03-27.tar.xz
|
||||
|
||||
Local Changes:
|
||||
- Replace snprintf with xasprintf in find_unique_cname
|
||||
- Squash uninitialized read of harnessbuf in run-test262.c
|
||||
- Change run-test262.c to not rebase configured paths
|
||||
|
|
57
third_party/quickjs/quickjs-libc.c
vendored
57
third_party/quickjs/quickjs-libc.c
vendored
|
@ -2764,61 +2764,6 @@ static char **build_envp(JSContext *ctx, JSValueConst obj)
|
|||
goto done;
|
||||
}
|
||||
|
||||
/* execvpe is not available on non GNU systems */
|
||||
static int my_execvpe(const char *filename, char **argv, char **envp)
|
||||
{
|
||||
char *path, *p, *p_next, *p1;
|
||||
char buf[PATH_MAX];
|
||||
size_t filename_len, path_len;
|
||||
BOOL eacces_error;
|
||||
|
||||
filename_len = strlen(filename);
|
||||
if (filename_len == 0) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
if (strchr(filename, '/'))
|
||||
return execve(filename, argv, envp);
|
||||
|
||||
path = getenv("PATH");
|
||||
if (!path)
|
||||
path = (char *)"/bin:/usr/bin";
|
||||
eacces_error = FALSE;
|
||||
p = path;
|
||||
for(p = path; p != NULL; p = p_next) {
|
||||
p1 = strchr(p, ':');
|
||||
if (!p1) {
|
||||
p_next = NULL;
|
||||
path_len = strlen(p);
|
||||
} else {
|
||||
p_next = p1 + 1;
|
||||
path_len = p1 - p;
|
||||
}
|
||||
/* path too long */
|
||||
if ((path_len + 1 + filename_len + 1) > PATH_MAX)
|
||||
continue;
|
||||
memcpy(buf, p, path_len);
|
||||
buf[path_len] = '/';
|
||||
memcpy(buf + path_len + 1, filename, filename_len);
|
||||
buf[path_len + 1 + filename_len] = '\0';
|
||||
|
||||
execve(buf, argv, envp);
|
||||
|
||||
if (errno == EACCES) {
|
||||
eacces_error = TRUE;
|
||||
} else if (errno == ENOENT) {
|
||||
/* do nothing */
|
||||
} else if (errno == ENOTDIR) {
|
||||
/* do nothing */
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (eacces_error)
|
||||
errno = EACCES;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* exec(args[, options]) -> exitcode */
|
||||
static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
|
@ -2973,7 +2918,7 @@ static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val,
|
|||
if (!file)
|
||||
file = exec_argv[0];
|
||||
if (use_path)
|
||||
ret = my_execvpe(file, (char **)exec_argv, envp);
|
||||
ret = execvpe(file, (char **)exec_argv, envp);
|
||||
else
|
||||
ret = execve(file, (char **)exec_argv, envp);
|
||||
_exit(127);
|
||||
|
|
20
third_party/quickjs/quickjs.c
vendored
20
third_party/quickjs/quickjs.c
vendored
|
@ -11296,11 +11296,11 @@ static char *i64toa(char *buf_end, int64_t n, unsigned int base)
|
|||
static void js_ecvt1(double d, int n_digits, int *decpt, int *sign, char *buf,
|
||||
int rounding_mode, char *buf1, int buf1_size)
|
||||
{
|
||||
/* if (rounding_mode != FE_TONEAREST) */
|
||||
/* fesetround(rounding_mode); */
|
||||
if (rounding_mode != FE_TONEAREST)
|
||||
fesetround(rounding_mode);
|
||||
snprintf(buf1, buf1_size, "%+.*e", n_digits - 1, d);
|
||||
/* if (rounding_mode != FE_TONEAREST) */
|
||||
/* fesetround(FE_TONEAREST); */
|
||||
if (rounding_mode != FE_TONEAREST)
|
||||
fesetround(FE_TONEAREST);
|
||||
*sign = (buf1[0] == '-');
|
||||
/* mantissa */
|
||||
buf[0] = buf1[1];
|
||||
|
@ -53608,12 +53608,12 @@ static JSValue js_atomics_op(JSContext *ctx,
|
|||
a = func_name((_Atomic(uint32_t) *)ptr, v); \
|
||||
break;
|
||||
#endif
|
||||
/* OP(ADD, atomic_fetch_add) */
|
||||
/* OP(AND, atomic_fetch_and) */
|
||||
/* OP(OR, atomic_fetch_or) */
|
||||
/* OP(SUB, atomic_fetch_sub) */
|
||||
/* OP(XOR, atomic_fetch_xor) */
|
||||
/* OP(EXCHANGE, atomic_exchange) */
|
||||
OP(ADD, atomic_fetch_add)
|
||||
OP(AND, atomic_fetch_and)
|
||||
OP(OR, atomic_fetch_or)
|
||||
OP(SUB, atomic_fetch_sub)
|
||||
OP(XOR, atomic_fetch_xor)
|
||||
OP(EXCHANGE, atomic_exchange)
|
||||
#undef OP
|
||||
|
||||
case ATOMICS_OP_LOAD | (0 << 3):
|
||||
|
|
182
third_party/quickjs/quickjs.mk
vendored
182
third_party/quickjs/quickjs.mk
vendored
|
@ -3,83 +3,151 @@
|
|||
|
||||
PKGS += THIRD_PARTY_QUICKJS
|
||||
|
||||
THIRD_PARTY_QUICKJS_FILES := $(wildcard third_party/quickjs/*)
|
||||
THIRD_PARTY_QUICKJS_SRCS = $(filter %.c,$(THIRD_PARTY_QUICKJS_FILES))
|
||||
THIRD_PARTY_QUICKJS_HDRS = $(filter %.h,$(THIRD_PARTY_QUICKJS_FILES))
|
||||
THIRD_PARTY_QUICKJS_ARTIFACTS += THIRD_PARTY_QUICKJS_A
|
||||
THIRD_PARTY_QUICKJS_BINS = $(THIRD_PARTY_QUICKJS_COMS) $(THIRD_PARTY_QUICKJS_COMS:%=%.dbg)
|
||||
THIRD_PARTY_QUICKJS = $(THIRD_PARTY_QUICKJS_DEPS) $(THIRD_PARTY_QUICKJS_A)
|
||||
THIRD_PARTY_QUICKJS = $(THIRD_PARTY_QUICKJS_A_DEPS) $(THIRD_PARTY_QUICKJS_A)
|
||||
THIRD_PARTY_QUICKJS_A = o/$(MODE)/third_party/quickjs/quickjs.a
|
||||
THIRD_PARTY_QUICKJS_HDRS = $(foreach x,$(THIRD_PARTY_QUICKJS_ARTIFACTS),$($(x)_HDRS))
|
||||
|
||||
THIRD_PARTY_QUICKJS_OBJS = \
|
||||
$(THIRD_PARTY_QUICKJS_SRCS:%.c=o/$(MODE)/%.o)
|
||||
THIRD_PARTY_QUICKJS_A_SRCS = \
|
||||
third_party/quickjs/cutils.c \
|
||||
third_party/quickjs/libbf.c \
|
||||
third_party/quickjs/libregexp.c \
|
||||
third_party/quickjs/libunicode.c \
|
||||
third_party/quickjs/quickjs-libc.c \
|
||||
third_party/quickjs/quickjs.c \
|
||||
third_party/quickjs/wut.c
|
||||
|
||||
THIRD_PARTY_QUICKJS_COMS = \
|
||||
o/$(MODE)/third_party/quickjs/qjs.com
|
||||
THIRD_PARTY_QUICKJS_A_HDRS = \
|
||||
third_party/quickjs/cutils.h \
|
||||
third_party/quickjs/libbf.h \
|
||||
third_party/quickjs/libregexp.h \
|
||||
third_party/quickjs/libunicode.h \
|
||||
third_party/quickjs/list.h \
|
||||
third_party/quickjs/quickjs-libc.h \
|
||||
third_party/quickjs/quickjs.h
|
||||
|
||||
THIRD_PARTY_QUICKJS_CHECKS = \
|
||||
$(THIRD_PARTY_QUICKJS_A).pkg \
|
||||
$(THIRD_PARTY_QUICKJS_HDRS:%=o/$(MODE)/%.ok)
|
||||
THIRD_PARTY_QUICKJS_A_OBJS = \
|
||||
o/$(MODE)/third_party/quickjs/cutils.o \
|
||||
o/$(MODE)/third_party/quickjs/libbf.o \
|
||||
o/$(MODE)/third_party/quickjs/libregexp.o \
|
||||
o/$(MODE)/third_party/quickjs/libunicode.o \
|
||||
o/$(MODE)/third_party/quickjs/quickjs-libc.o \
|
||||
o/$(MODE)/third_party/quickjs/quickjs.o \
|
||||
o/$(MODE)/third_party/quickjs/wut.o
|
||||
|
||||
THIRD_PARTY_QUICKJS_DIRECTDEPS = \
|
||||
LIBC_ALG \
|
||||
LIBC_CALLS \
|
||||
LIBC_FMT \
|
||||
LIBC_INTRIN \
|
||||
LIBC_LOG \
|
||||
LIBC_MEM \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_RUNTIME \
|
||||
LIBC_SOCK \
|
||||
LIBC_STDIO \
|
||||
LIBC_STR \
|
||||
LIBC_SYSV \
|
||||
LIBC_SYSV_CALLS \
|
||||
LIBC_TIME \
|
||||
LIBC_TINYMATH \
|
||||
LIBC_UNICODE \
|
||||
LIBC_X \
|
||||
THIRD_PARTY_COMPILER_RT \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_GETOPT \
|
||||
THIRD_PARTY_QUICKJS_A_DIRECTDEPS = \
|
||||
LIBC_ALG \
|
||||
LIBC_CALLS \
|
||||
LIBC_FMT \
|
||||
LIBC_INTRIN \
|
||||
LIBC_LOG \
|
||||
LIBC_MEM \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_RUNTIME \
|
||||
LIBC_SOCK \
|
||||
LIBC_STDIO \
|
||||
LIBC_STR \
|
||||
LIBC_SYSV \
|
||||
LIBC_SYSV_CALLS \
|
||||
LIBC_TIME \
|
||||
LIBC_TINYMATH \
|
||||
LIBC_UNICODE \
|
||||
LIBC_X \
|
||||
THIRD_PARTY_COMPILER_RT \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_GETOPT \
|
||||
THIRD_PARTY_MUSL
|
||||
|
||||
THIRD_PARTY_QUICKJS_DEPS := \
|
||||
$(call uniq,$(foreach x,$(THIRD_PARTY_QUICKJS_DIRECTDEPS),$($(x))))
|
||||
THIRD_PARTY_QUICKJS_A_DEPS := \
|
||||
$(call uniq,$(foreach x,$(THIRD_PARTY_QUICKJS_A_DIRECTDEPS),$($(x))))
|
||||
|
||||
$(THIRD_PARTY_QUICKJS_A): \
|
||||
third_party/quickjs/ \
|
||||
$(THIRD_PARTY_QUICKJS_A).pkg \
|
||||
$(filter-out %/quickjs.c,$(THIRD_PARTY_QUICKJS_OBJS))
|
||||
$(THIRD_PARTY_QUICKJS_A): \
|
||||
third_party/quickjs/ \
|
||||
$(THIRD_PARTY_QUICKJS_A).pkg \
|
||||
$(THIRD_PARTY_QUICKJS_A_OBJS)
|
||||
|
||||
$(THIRD_PARTY_QUICKJS_A).pkg: \
|
||||
$(THIRD_PARTY_QUICKJS_OBJS) \
|
||||
$(foreach x,$(THIRD_PARTY_QUICKJS_DIRECTDEPS),$($(x)_A).pkg)
|
||||
$(THIRD_PARTY_QUICKJS_A).pkg: \
|
||||
$(THIRD_PARTY_QUICKJS_A_OBJS) \
|
||||
$(foreach x,$(THIRD_PARTY_QUICKJS_A_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
||||
o/$(MODE)/third_party/quickjs/qjs.com.dbg: \
|
||||
$(THIRD_PARTY_QUICKJS_DEPS) \
|
||||
$(THIRD_PARTY_QUICKJS_A) \
|
||||
$(THIRD_PARTY_QUICKJS_A).pkg \
|
||||
o/$(MODE)/third_party/quickjs/qjs.o \
|
||||
$(CRT) \
|
||||
THIRD_PARTY_QUICKJS_SRCS = \
|
||||
third_party/quickjs/qjs.c \
|
||||
third_party/quickjs/qjsc.c \
|
||||
third_party/quickjs/run-test262.c \
|
||||
$(foreach x,$(THIRD_PARTY_QUICKJS_ARTIFACTS),$($(x)_SRCS))
|
||||
|
||||
THIRD_PARTY_QUICKJS_OBJS = \
|
||||
o/$(MODE)/third_party/quickjs/qjs.o \
|
||||
o/$(MODE)/third_party/quickjs/qjsc.o \
|
||||
o/$(MODE)/third_party/quickjs/run-test262.o \
|
||||
$(THIRD_PARTY_QUICKJS_A_OBJS)
|
||||
|
||||
THIRD_PARTY_QUICKJS_COMS = \
|
||||
o/$(MODE)/third_party/quickjs/qjs.com \
|
||||
o/$(MODE)/third_party/quickjs/qjsc.com \
|
||||
o/$(MODE)/third_party/quickjs/run-test262.com \
|
||||
o/$(MODE)/third_party/quickjs/unicode_gen.com
|
||||
|
||||
THIRD_PARTY_QUICKJS_CHECKS = \
|
||||
$(THIRD_PARTY_QUICKJS_A).pkg \
|
||||
$(THIRD_PARTY_QUICKJS_A_HDRS:%=o/$(MODE)/%.ok)
|
||||
|
||||
o/$(MODE)/third_party/quickjs/qjs.com.dbg: \
|
||||
$(THIRD_PARTY_QUICKJS_A_DEPS) \
|
||||
$(THIRD_PARTY_QUICKJS_A) \
|
||||
$(THIRD_PARTY_QUICKJS_A).pkg \
|
||||
o/$(MODE)/third_party/quickjs/qjs.o \
|
||||
$(CRT) \
|
||||
$(APE)
|
||||
-@$(APELINK)
|
||||
|
||||
$(THIRD_PARTY_QUICKJS_OBJS): \
|
||||
OVERRIDE_CPPFLAGS += \
|
||||
-DCONFIG_BIGNUM \
|
||||
o/$(MODE)/third_party/quickjs/qjsc.com.dbg: \
|
||||
$(THIRD_PARTY_QUICKJS_A_DEPS) \
|
||||
$(THIRD_PARTY_QUICKJS_A) \
|
||||
$(THIRD_PARTY_QUICKJS_A).pkg \
|
||||
o/$(MODE)/third_party/quickjs/qjsc.o \
|
||||
$(CRT) \
|
||||
$(APE)
|
||||
-@$(APELINK)
|
||||
|
||||
# git clone git@github.com:tc39/test262 /opt/test262
|
||||
# make -j8 MODE=dbg o/dbg/third_party/quickjs/run-test262.com
|
||||
# o/dbg/third_party/quickjs/run-test262.com -m -c third_party/quickjs/test262.conf -a
|
||||
o/$(MODE)/third_party/quickjs/run-test262.com.dbg: \
|
||||
$(THIRD_PARTY_QUICKJS_A_DEPS) \
|
||||
$(THIRD_PARTY_QUICKJS_A) \
|
||||
$(THIRD_PARTY_QUICKJS_A).pkg \
|
||||
o/$(MODE)/third_party/quickjs/run-test262.o \
|
||||
$(CRT) \
|
||||
$(APE)
|
||||
-@$(APELINK)
|
||||
|
||||
o/$(MODE)/third_party/quickjs/unicode_gen.com.dbg: \
|
||||
$(THIRD_PARTY_QUICKJS_A_DEPS) \
|
||||
$(THIRD_PARTY_QUICKJS_A) \
|
||||
$(THIRD_PARTY_QUICKJS_A).pkg \
|
||||
o/$(MODE)/third_party/quickjs/unicode_gen.o \
|
||||
$(CRT) \
|
||||
$(APE)
|
||||
-@$(APELINK)
|
||||
|
||||
$(THIRD_PARTY_QUICKJS_OBJS): \
|
||||
OVERRIDE_CPPFLAGS += \
|
||||
-DCONFIG_BIGNUM \
|
||||
-DCONFIG_VERSION=\"$(shell cat third_party/quickjs/VERSION)\"
|
||||
|
||||
o/$(MODE)/third_party/quickjs/unicode_gen.o: \
|
||||
OVERRIDE_CPPFLAGS += \
|
||||
o/$(MODE)/third_party/quickjs/unicode_gen.o: \
|
||||
OVERRIDE_CPPFLAGS += \
|
||||
-DSTACK_FRAME_UNLIMITED
|
||||
|
||||
# TODO(jart): Replace alloca() calls with malloc().
|
||||
o/$(MODE)/third_party/quickjs/libregexp.o \
|
||||
o/$(MODE)/third_party/quickjs/quickjs.o: \
|
||||
OVERRIDE_CPPFLAGS += \
|
||||
o/$(MODE)/third_party/quickjs/libregexp.o \
|
||||
o/$(MODE)/third_party/quickjs/quickjs.o: \
|
||||
OVERRIDE_CPPFLAGS += \
|
||||
-DSTACK_FRAME_UNLIMITED
|
||||
|
||||
.PHONY: o/$(MODE)/third_party/quickjs
|
||||
o/$(MODE)/third_party/quickjs: \
|
||||
$(THIRD_PARTY_QUICKJS_BINS) \
|
||||
o/$(MODE)/third_party/quickjs: \
|
||||
$(THIRD_PARTY_QUICKJS_BINS) \
|
||||
$(THIRD_PARTY_QUICKJS_CHECKS)
|
||||
|
|
7
third_party/quickjs/run-test262.c
vendored
7
third_party/quickjs/run-test262.c
vendored
|
@ -931,7 +931,8 @@ void load_config(const char *filename)
|
|||
if (!f) {
|
||||
perror_exit(1, filename);
|
||||
}
|
||||
base_name = get_basename(filename);
|
||||
/* base_name = get_basename(filename); */
|
||||
base_name = strdup("");
|
||||
|
||||
while (fgets(buf, sizeof(buf), f) != NULL) {
|
||||
char *p, *q;
|
||||
|
@ -1672,6 +1673,8 @@ int run_test(const char *filename, int index)
|
|||
if (p) {
|
||||
snprintf(harnessbuf, sizeof(harnessbuf), "%.*s%s",
|
||||
(int)(p - filename), filename, "test/harness");
|
||||
} else {
|
||||
strcpy(harnessbuf, ""); /* XXX */
|
||||
}
|
||||
harness = harnessbuf;
|
||||
}
|
||||
|
@ -1947,6 +1950,8 @@ int main(int argc, char **argv)
|
|||
BOOL is_test262_harness = FALSE;
|
||||
BOOL is_module = FALSE;
|
||||
|
||||
showcrashreports();
|
||||
|
||||
#if !defined(_WIN32)
|
||||
/* Date tests assume California local time */
|
||||
setenv("TZ", "America/Los_Angeles", 1);
|
||||
|
|
23
third_party/quickjs/test262.conf
vendored
23
third_party/quickjs/test262.conf
vendored
|
@ -26,22 +26,22 @@ module=yes
|
|||
verbose=yes
|
||||
|
||||
# load harness files from this directory
|
||||
harnessdir=test262/harness
|
||||
harnessdir=/opt/test262/harness
|
||||
|
||||
# names of harness include files to skip
|
||||
#harnessexclude=
|
||||
|
||||
# name of the error file for known errors
|
||||
errorfile=test262_errors.txt
|
||||
errorfile=third_party/quickjs/test262_errors.txt
|
||||
|
||||
# exclude tests enumerated in this file (see also [exclude] section)
|
||||
#excludefile=test262_exclude.txt
|
||||
|
||||
# report test results to this file
|
||||
reportfile=test262_report.txt
|
||||
reportfile=o/test262_report.txt
|
||||
|
||||
# enumerate tests from this directory
|
||||
testdir=test262/test
|
||||
testdir=/opt/test262/test
|
||||
|
||||
[features]
|
||||
# Standard language features and proposed extensions
|
||||
|
@ -184,16 +184,19 @@ __setter__
|
|||
# list excluded tests and directories here
|
||||
|
||||
# intl not supported
|
||||
test262/test/intl402/
|
||||
/opt/test262/test/intl402/
|
||||
|
||||
# incompatible with the "caller" feature
|
||||
test262/test/built-ins/Function/prototype/restricted-property-caller.js
|
||||
test262/test/built-ins/Function/prototype/restricted-property-arguments.js
|
||||
test262/test/built-ins/ThrowTypeError/unique-per-realm-function-proto.js
|
||||
/opt/test262/test/built-ins/Function/prototype/restricted-property-caller.js
|
||||
/opt/test262/test/built-ins/Function/prototype/restricted-property-arguments.js
|
||||
/opt/test262/test/built-ins/ThrowTypeError/unique-per-realm-function-proto.js
|
||||
|
||||
# slow tests
|
||||
#test262/test/built-ins/RegExp/CharacterClassEscapes/
|
||||
#test262/test/built-ins/RegExp/property-escapes/
|
||||
#/opt/test262/test/built-ins/RegExp/CharacterClassEscapes/
|
||||
#/opt/test262/test/built-ins/RegExp/property-escapes/
|
||||
|
||||
# No threads in Cosmopolitan ATM
|
||||
/opt/test262/test/built-ins/Atomics/
|
||||
|
||||
[tests]
|
||||
# list test files or use config.testdir
|
||||
|
|
|
@ -421,6 +421,11 @@ int main(int argc, char *argv[]) {
|
|||
} else if (isclang && startswith(argv[i], "--debug-prefix-map")) {
|
||||
/* llvm doesn't provide a gas interface so simulate w/ clang */
|
||||
AddArg(xasprintf("-f%s", argv[i] + 2));
|
||||
} else if (isgcc && (!strcmp(argv[i], "-Os") || !strcmp(argv[i], "-O2") ||
|
||||
!strcmp(argv[i], "-O3"))) {
|
||||
/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97623 */
|
||||
AddArg(argv[i]);
|
||||
AddArg("-fno-code-hoisting");
|
||||
} else {
|
||||
AddArg(argv[i]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue