The retry loop in js_waker_signal used `errno != EAGAIN || errno != EINTR`,
which is always true (any single errno value is unequal to at least one of
the two), so the loop bailed on the first short-write error and silently
dropped the wakeup. Replace with `&&` so the loop only exits on a fatal
errno.
No test: js_waker_signal's transient-error path is reached only when the
pipe is full or the syscall is interrupted by a signal, neither of which
is reliably reproducible in a portable unit test.
Co-authored-by: Claude <[email protected]>
The two failing tests are:
- a quine (imports itself); needs some more work in the module loader
- dynamic imports; the dynamic loader doesn't support attributes at all
at the moment
Statically initialized function pointers are not 100% portable because
functions may not have stable addresses at link time.
Simple fix: don't initialize the function pointers statically.
PATH_MAX is optional in POSIX, and it is not available on GNU/Hurd.
There is already a fallback definition called JS__PATH_MAX, so switch
all the common code (i.e. not the bits specific to a certain OS) to use
it.
Reintroduce JSValueConst and add a JS_CHECK_JSVALUE build mode that
catches reference counting bugs by making JSValue and JSValueConst
different types.
The *vast* majority of this commit is rote work to make our own sources
compile cleanly in said mode.
Refs: https://github.com/quickjs-ng/quickjs/issues/944
Replace js_load_file with something that doesn't choke on special files
and don't call realpath(3) on /dev files because that doesn't work.
Now `echo 'print("hello")' | qjs /dev/stdin` works.
Fixes: https://github.com/quickjs-ng/quickjs/issues/945
Roll all the source files into a single jumbo file and release that
along with quickjs.h in a zip file to make embedding for downstream
users easy.
Fixes: https://github.com/quickjs-ng/quickjs/issues/688
The version of tcc in CI merely warned on unrecognized pragmas but newer
versions treat them as fatal errors.
Upgrade tcc to prevent that from happening again.
Consider this script that throws an uncaught exception:
function f() {
throw "fail"
}
f()
Running with `qjs --script t.js` used to print merely:
fail
But now prints:
fail
at f (t.js:2:11)
at f (t.js:4:1)
qjs has been updated but no public API yet because I still need to think
through the corner cases.
Includes a one-line fix for line:column reporting for throw statements.
Refs: https://github.com/quickjs-ng/quickjs/issues/799
Before this commit, such objects were printed as `<exception>` because
print() and console.log() had no good way to turn them into strings.
Instead perform the C equivalent of Object.prototype.toString.call(o)
and print the result (which can still error but at least we tried.)
Fixes: https://github.com/quickjs-ng/quickjs/issues/832