@ai-ecoverse/slicc-kernel 1.107.1 → 1.108.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/dist/kernel-worker.js +27 -5
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +191 -166
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +27 -5
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +191 -166
- package/dist/process-worker.js.map +4 -4
- package/dist/types/kernel/children.d.ts +3 -0
- package/dist/types/kernel/process.d.ts +6 -0
- package/dist/types/process/process-signals.d.ts +8 -6
- package/dist/types/process/wasi/wasi-fds.d.ts +1 -1
- package/dist/types/process/wasi/wasi-host.d.ts +1 -1
- package/dist/types/process/wasi/wasi-signals.d.ts +4 -7
- package/package.json +1 -1
package/dist/process-worker.js
CHANGED
|
@@ -2491,7 +2491,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
2491
2491
|
var init_version = __esm({
|
|
2492
2492
|
"src/version.ts"() {
|
|
2493
2493
|
"use strict";
|
|
2494
|
-
KERNEL_VERSION = true ? "1.
|
|
2494
|
+
KERNEL_VERSION = true ? "1.108.1" : "0.0.0-dev";
|
|
2495
2495
|
OS_RELEASE = "6.0.0-slicc";
|
|
2496
2496
|
}
|
|
2497
2497
|
});
|
|
@@ -4721,7 +4721,7 @@ var init_process_signals = __esm({
|
|
|
4721
4721
|
init_signals();
|
|
4722
4722
|
init_sync_sab_wire();
|
|
4723
4723
|
SignalGate = class {
|
|
4724
|
-
reported = { caught: 0, ignored: 0 };
|
|
4724
|
+
reported = { caught: 0, ignored: 0, nocldwait: false };
|
|
4725
4725
|
restart = 0;
|
|
4726
4726
|
lastDelivered = 0;
|
|
4727
4727
|
depth = 0;
|
|
@@ -4774,10 +4774,18 @@ var init_process_signals = __esm({
|
|
|
4774
4774
|
if (!masks) return;
|
|
4775
4775
|
this.restart = masks.restart;
|
|
4776
4776
|
const { caught, ignored, defaults = 0 } = masks;
|
|
4777
|
-
const
|
|
4777
|
+
const nocldwait = masks.nocldwait === true;
|
|
4778
|
+
const was = this.reported;
|
|
4779
|
+
const same = caught === was.caught && ignored === was.ignored && nocldwait === was.nocldwait;
|
|
4778
4780
|
if (same && defaults === 0) return;
|
|
4779
|
-
this.reported = { caught, ignored };
|
|
4780
|
-
const req = {
|
|
4781
|
+
this.reported = { caught, ignored, nocldwait };
|
|
4782
|
+
const req = {
|
|
4783
|
+
op: "sig-mask",
|
|
4784
|
+
caught,
|
|
4785
|
+
ignored,
|
|
4786
|
+
...defaults ? { defaults } : {},
|
|
4787
|
+
...nocldwait ? { nocldwait } : {}
|
|
4788
|
+
};
|
|
4781
4789
|
this.raw.call(req, Number.POSITIVE_INFINITY, "sig-mask");
|
|
4782
4790
|
}
|
|
4783
4791
|
quiet(fn) {
|
|
@@ -7600,7 +7608,7 @@ var init_wasi_fds = __esm({
|
|
|
7600
7608
|
const flags = want === 6 ? O_RDWR4 : want === 2 ? O_WRONLY4 : 0;
|
|
7601
7609
|
return openDevice2.call(this.kernel.sys, flags);
|
|
7602
7610
|
}
|
|
7603
|
-
open(path, oflags, rights, fdflags) {
|
|
7611
|
+
open(path, oflags, rights, fdflags, mode) {
|
|
7604
7612
|
const device2 = deviceOf(path);
|
|
7605
7613
|
if (device2) return this.install({ type: "device", device: device2 });
|
|
7606
7614
|
const kernelDevice = this.openKernelDevice(path, oflags, fdflags, rights);
|
|
@@ -7621,13 +7629,16 @@ var init_wasi_fds = __esm({
|
|
|
7621
7629
|
}
|
|
7622
7630
|
if (!s && !(oflags & OFLAGS.CREAT)) throw new WasiError("ENOENT");
|
|
7623
7631
|
refuseWrite(s, oflags, rights);
|
|
7624
|
-
return this.regular(path, s, oflags, rights, fdflags);
|
|
7632
|
+
return this.regular(path, s, oflags, rights, fdflags, mode);
|
|
7625
7633
|
}
|
|
7626
|
-
regular(path, s, oflags, rights, fdflags) {
|
|
7634
|
+
regular(path, s, oflags, rights, fdflags, mode) {
|
|
7627
7635
|
if (this.shared || this.kernelHolds(path, s)) {
|
|
7628
|
-
return this.kernelFile(path, s, oflags, rights, fdflags);
|
|
7636
|
+
return this.kernelFile(path, s, oflags, rights, fdflags, mode);
|
|
7629
7637
|
}
|
|
7630
|
-
return this.install({
|
|
7638
|
+
return this.install({
|
|
7639
|
+
type: "file",
|
|
7640
|
+
file: this.file(path, s, oflags, rights, fdflags, mode)
|
|
7641
|
+
});
|
|
7631
7642
|
}
|
|
7632
7643
|
kernelHolds(path, st) {
|
|
7633
7644
|
for (const [fd, e] of this.table) {
|
|
@@ -7649,7 +7660,7 @@ var init_wasi_fds = __esm({
|
|
|
7649
7660
|
} catch {
|
|
7650
7661
|
}
|
|
7651
7662
|
}
|
|
7652
|
-
file(path, existing, oflags, rights, fdflags) {
|
|
7663
|
+
file(path, existing, oflags, rights, fdflags, mode) {
|
|
7653
7664
|
const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
|
|
7654
7665
|
let buffer = this.buffers.get(path);
|
|
7655
7666
|
if (buffer?.handle !== void 0 && this.fs.kept?.(buffer.handle)) {
|
|
@@ -7662,13 +7673,13 @@ var init_wasi_fds = __esm({
|
|
|
7662
7673
|
if (this.fs.owners) this.fs.access?.(path, want, "open");
|
|
7663
7674
|
if (oflags & OFLAGS.TRUNC) buffer.truncate(0);
|
|
7664
7675
|
} else {
|
|
7665
|
-
buffer = this.freshBuffer(path, existing, oflags, want);
|
|
7676
|
+
buffer = this.freshBuffer(path, existing, oflags, want, mode);
|
|
7666
7677
|
}
|
|
7667
7678
|
buffer.opens++;
|
|
7668
7679
|
return new LocalFile(buffer, readable3, writable2, (fdflags & FDFLAGS.APPEND) !== 0);
|
|
7669
7680
|
}
|
|
7670
|
-
freshBuffer(path, existing, oflags, want) {
|
|
7671
|
-
const made = !existing && this.createNew(path, oflags);
|
|
7681
|
+
freshBuffer(path, existing, oflags, want, mode) {
|
|
7682
|
+
const made = !existing && this.createNew(path, oflags, mode);
|
|
7672
7683
|
const empty = made || (oflags & OFLAGS.TRUNC) !== 0;
|
|
7673
7684
|
if (existing?.ranged) this.fs.invalidate?.();
|
|
7674
7685
|
const seen = this.fs.changes?.now();
|
|
@@ -7698,11 +7709,11 @@ var init_wasi_fds = __esm({
|
|
|
7698
7709
|
if (id !== void 0) this.know(buffer, id);
|
|
7699
7710
|
return buffer;
|
|
7700
7711
|
}
|
|
7701
|
-
kernelFile(path, existing, oflags, rights, fdflags) {
|
|
7712
|
+
kernelFile(path, existing, oflags, rights, fdflags, mode) {
|
|
7702
7713
|
const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
|
|
7703
7714
|
const append = (fdflags & FDFLAGS.APPEND) !== 0;
|
|
7704
7715
|
const flags = (writable2 ? readable3 ? O_RDWR4 : O_WRONLY4 : 0) | (append ? O_APPEND2 : 0);
|
|
7705
|
-
const made = !existing && this.createNew(path, oflags);
|
|
7716
|
+
const made = !existing && this.createNew(path, oflags, mode);
|
|
7706
7717
|
const truncate = made || (oflags & OFLAGS.TRUNC) !== 0;
|
|
7707
7718
|
const fd = this.kernel.sys.openVfs(path, flags, 0, {
|
|
7708
7719
|
...truncate ? { truncate } : {},
|
|
@@ -7715,13 +7726,13 @@ var init_wasi_fds = __esm({
|
|
|
7715
7726
|
this.bump();
|
|
7716
7727
|
return fd;
|
|
7717
7728
|
}
|
|
7718
|
-
createNew(path, oflags) {
|
|
7729
|
+
createNew(path, oflags, mode) {
|
|
7719
7730
|
if (!this.fs.create) {
|
|
7720
7731
|
this.fs.writeFile(path, new Uint8Array(0));
|
|
7721
7732
|
return true;
|
|
7722
7733
|
}
|
|
7723
7734
|
try {
|
|
7724
|
-
this.fs.create(path,
|
|
7735
|
+
this.fs.create(path, mode, true);
|
|
7725
7736
|
return true;
|
|
7726
7737
|
} catch (err) {
|
|
7727
7738
|
if (oflags & OFLAGS.EXCL || err.code !== "EEXIST") throw err;
|
|
@@ -7959,6 +7970,136 @@ var init_wasi_poll = __esm({
|
|
|
7959
7970
|
}
|
|
7960
7971
|
});
|
|
7961
7972
|
|
|
7973
|
+
// src/process/wasi/wasi-sigmask.ts
|
|
7974
|
+
var UNBLOCKABLE, LIBC_UNBLOCKABLE, FOREVER, NS_PER_MS2, POLL_MS, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
|
|
7975
|
+
var init_wasi_sigmask = __esm({
|
|
7976
|
+
"src/process/wasi/wasi-sigmask.ts"() {
|
|
7977
|
+
"use strict";
|
|
7978
|
+
init_signals();
|
|
7979
|
+
init_sync_sab_wire();
|
|
7980
|
+
init_wasi_abi();
|
|
7981
|
+
UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
|
|
7982
|
+
LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
|
|
7983
|
+
FOREVER = 0xffffffffffffffffn;
|
|
7984
|
+
NS_PER_MS2 = 1000000n;
|
|
7985
|
+
POLL_MS = 50;
|
|
7986
|
+
SIG_BLOCK = 0;
|
|
7987
|
+
SIG_UNBLOCK = 1;
|
|
7988
|
+
SIG_SETMASK = 2;
|
|
7989
|
+
kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
|
|
7990
|
+
libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
|
|
7991
|
+
apply = (how, mask, set) => {
|
|
7992
|
+
if (how === SIG_BLOCK) return mask | set;
|
|
7993
|
+
if (how === SIG_UNBLOCK) return mask & ~set;
|
|
7994
|
+
return set;
|
|
7995
|
+
};
|
|
7996
|
+
WasiSigmask = class {
|
|
7997
|
+
lo;
|
|
7998
|
+
hi;
|
|
7999
|
+
header;
|
|
8000
|
+
deliver;
|
|
8001
|
+
process;
|
|
8002
|
+
tid;
|
|
8003
|
+
constructor(header, deliver, process, tid = 1) {
|
|
8004
|
+
this.header = header;
|
|
8005
|
+
this.deliver = deliver;
|
|
8006
|
+
this.process = process;
|
|
8007
|
+
this.tid = tid;
|
|
8008
|
+
this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
|
|
8009
|
+
this.hi = Atomics.load(header, SAB_I_BLOCKED_HI);
|
|
8010
|
+
}
|
|
8011
|
+
static unsupported(header) {
|
|
8012
|
+
storeBlocked(header, [0, 0]);
|
|
8013
|
+
}
|
|
8014
|
+
set(how, setLo, setHi, old) {
|
|
8015
|
+
if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
|
|
8016
|
+
old(this.lo >>> 0, this.hi >>> 0);
|
|
8017
|
+
this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
|
|
8018
|
+
this.hi = apply(how, this.hi, setHi | 0);
|
|
8019
|
+
const now = kernelBits(this.lo);
|
|
8020
|
+
storeBlocked(this.header, [now, this.hi]);
|
|
8021
|
+
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
|
|
8022
|
+
return E.SUCCESS;
|
|
8023
|
+
}
|
|
8024
|
+
swap(setLo, setHi) {
|
|
8025
|
+
const old = [this.lo, this.hi];
|
|
8026
|
+
this.lo = setLo & ~LIBC_UNBLOCKABLE;
|
|
8027
|
+
this.hi = setHi | 0;
|
|
8028
|
+
storeBlocked(this.header, [kernelBits(this.lo), this.hi]);
|
|
8029
|
+
return old;
|
|
8030
|
+
}
|
|
8031
|
+
deliverUnblocked() {
|
|
8032
|
+
const now = Atomics.load(this.header, SAB_I_BLOCKED);
|
|
8033
|
+
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) === 0) return false;
|
|
8034
|
+
this.deliver();
|
|
8035
|
+
return true;
|
|
8036
|
+
}
|
|
8037
|
+
restore([lo, hi]) {
|
|
8038
|
+
this.set(SIG_SETMASK, lo, hi, () => {
|
|
8039
|
+
});
|
|
8040
|
+
}
|
|
8041
|
+
blockedBits() {
|
|
8042
|
+
return Atomics.load(this.header, SAB_I_BLOCKED);
|
|
8043
|
+
}
|
|
8044
|
+
blocks(sig) {
|
|
8045
|
+
return (Atomics.load(this.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
|
|
8046
|
+
}
|
|
8047
|
+
inherited() {
|
|
8048
|
+
return [kernelBits(this.lo), this.hi];
|
|
8049
|
+
}
|
|
8050
|
+
discard(sig) {
|
|
8051
|
+
Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
|
|
8052
|
+
if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
|
|
8053
|
+
}
|
|
8054
|
+
sigwait(setLo, timeoutNs, publish, took, entered = false) {
|
|
8055
|
+
const set = kernelBits(setLo | 0);
|
|
8056
|
+
const value2 = BigInt.asUintN(64, timeoutNs);
|
|
8057
|
+
const deadline = value2 === FOREVER ? Number.POSITIVE_INFINITY : performance.now() + Number((value2 + NS_PER_MS2 - 1n) / NS_PER_MS2);
|
|
8058
|
+
publish(set);
|
|
8059
|
+
try {
|
|
8060
|
+
for (; ; ) {
|
|
8061
|
+
const seen = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
8062
|
+
const sig = this.take(set);
|
|
8063
|
+
if (sig !== 0) {
|
|
8064
|
+
took(sig);
|
|
8065
|
+
return E.SUCCESS;
|
|
8066
|
+
}
|
|
8067
|
+
if (entered || this.deliverUnblocked() || this.interrupted()) return E.INTR;
|
|
8068
|
+
const left = deadline - performance.now();
|
|
8069
|
+
if (left <= 0) return E.AGAIN;
|
|
8070
|
+
Atomics.wait(this.header, SAB_I_SIGNALS, seen, Math.min(left, POLL_MS));
|
|
8071
|
+
}
|
|
8072
|
+
} finally {
|
|
8073
|
+
publish(0);
|
|
8074
|
+
}
|
|
8075
|
+
}
|
|
8076
|
+
take(set) {
|
|
8077
|
+
for (const header of this.process ? [this.header, this.process] : [this.header]) {
|
|
8078
|
+
const ready = Atomics.load(header, SAB_I_SIGNALS) & set;
|
|
8079
|
+
if (ready === 0) continue;
|
|
8080
|
+
const bit = ready & -ready;
|
|
8081
|
+
if ((Atomics.and(header, SAB_I_SIGNALS, ~bit) & bit) !== 0) return 31 - Math.clz32(bit);
|
|
8082
|
+
}
|
|
8083
|
+
return 0;
|
|
8084
|
+
}
|
|
8085
|
+
interrupted() {
|
|
8086
|
+
const killed = this.process ?? this.header;
|
|
8087
|
+
if (Atomics.load(killed, SAB_I_KILLED) !== 0) {
|
|
8088
|
+
this.deliver();
|
|
8089
|
+
return true;
|
|
8090
|
+
}
|
|
8091
|
+
if (Atomics.load(killed, SAB_I_STOP) !== 1) return false;
|
|
8092
|
+
while (Atomics.load(killed, SAB_I_STOP) === 1) Atomics.wait(killed, SAB_I_STOP, 1);
|
|
8093
|
+
return true;
|
|
8094
|
+
}
|
|
8095
|
+
pending() {
|
|
8096
|
+
const own = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
8097
|
+
return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
|
|
8098
|
+
}
|
|
8099
|
+
};
|
|
8100
|
+
}
|
|
8101
|
+
});
|
|
8102
|
+
|
|
7962
8103
|
// src/process/wasi/wasi-termios.ts
|
|
7963
8104
|
function writeTermios(mem, ptr, termios) {
|
|
7964
8105
|
mem.bytes(ptr, OSPEED + 4).fill(0);
|
|
@@ -8037,8 +8178,8 @@ var init_wasi_termios = __esm({
|
|
|
8037
8178
|
// src/process/wasi/wasix-epoll.ts
|
|
8038
8179
|
function timeoutMs(ns) {
|
|
8039
8180
|
const value2 = BigInt.asUintN(64, ns);
|
|
8040
|
-
if (value2 ===
|
|
8041
|
-
const ms = (value2 +
|
|
8181
|
+
if (value2 === FOREVER2) return -1;
|
|
8182
|
+
const ms = (value2 + NS_PER_MS3 - 1n) / NS_PER_MS3;
|
|
8042
8183
|
return ms > BigInt(MAX_TIMEOUT_MS) ? -1 : Number(ms);
|
|
8043
8184
|
}
|
|
8044
8185
|
function wasixEpollImports(host) {
|
|
@@ -8099,7 +8240,7 @@ function wasixEpollImports(host) {
|
|
|
8099
8240
|
}
|
|
8100
8241
|
};
|
|
8101
8242
|
}
|
|
8102
|
-
var EVENT_SIZE, DATA_OFFSET, DATA_SIZE, MAX_EVENTS,
|
|
8243
|
+
var EVENT_SIZE, DATA_OFFSET, DATA_SIZE, MAX_EVENTS, FOREVER2, MAX_TIMEOUT_MS, NS_PER_MS3, EVENTFD_SEMAPHORE, EVENTFD_NONBLOCK, EVENTFD_MAX, WASIX_OPS, DUAL_OPS;
|
|
8103
8244
|
var init_wasix_epoll = __esm({
|
|
8104
8245
|
"src/process/wasi/wasix-epoll.ts"() {
|
|
8105
8246
|
"use strict";
|
|
@@ -8109,9 +8250,9 @@ var init_wasix_epoll = __esm({
|
|
|
8109
8250
|
DATA_OFFSET = 8;
|
|
8110
8251
|
DATA_SIZE = 24;
|
|
8111
8252
|
MAX_EVENTS = 4096;
|
|
8112
|
-
|
|
8253
|
+
FOREVER2 = 0xffffffffffffffffn;
|
|
8113
8254
|
MAX_TIMEOUT_MS = 2147483647;
|
|
8114
|
-
|
|
8255
|
+
NS_PER_MS3 = 1000000n;
|
|
8115
8256
|
EVENTFD_SEMAPHORE = 1;
|
|
8116
8257
|
EVENTFD_NONBLOCK = 4;
|
|
8117
8258
|
EVENTFD_MAX = 0xfffffffffffffffen;
|
|
@@ -8506,7 +8647,7 @@ function filestatOf(path, s) {
|
|
|
8506
8647
|
size: BigInt(s.size),
|
|
8507
8648
|
ino: s.ino !== void 0 ? BigInt(s.ino) : pathInode(path),
|
|
8508
8649
|
...s.nlink !== void 0 ? { nlink: BigInt(s.nlink) } : {},
|
|
8509
|
-
mtimeNs: BigInt(Math.round(s.mtimeMs ?? 0)) *
|
|
8650
|
+
mtimeNs: BigInt(Math.round(s.mtimeMs ?? 0)) * NS_PER_MS4
|
|
8510
8651
|
};
|
|
8511
8652
|
}
|
|
8512
8653
|
function kernelFiletype(kind) {
|
|
@@ -8556,7 +8697,7 @@ function wrap(table) {
|
|
|
8556
8697
|
}
|
|
8557
8698
|
return out;
|
|
8558
8699
|
}
|
|
8559
|
-
var WasiExit, IDS,
|
|
8700
|
+
var WasiExit, IDS, NS_PER_MS4, AT_SYMLINK_NOFOLLOW2, AT_EACCESS2, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
|
|
8560
8701
|
var init_wasi_host = __esm({
|
|
8561
8702
|
"src/process/wasi/wasi-host.ts"() {
|
|
8562
8703
|
"use strict";
|
|
@@ -8573,6 +8714,7 @@ var init_wasi_host = __esm({
|
|
|
8573
8714
|
init_wasi_files();
|
|
8574
8715
|
init_wasi_memory();
|
|
8575
8716
|
init_wasi_poll();
|
|
8717
|
+
init_wasi_sigmask();
|
|
8576
8718
|
init_wasi_termios();
|
|
8577
8719
|
init_wasix_epoll();
|
|
8578
8720
|
init_wasix_sockets();
|
|
@@ -8584,14 +8726,14 @@ var init_wasi_host = __esm({
|
|
|
8584
8726
|
}
|
|
8585
8727
|
};
|
|
8586
8728
|
IDS = ["ruid", "euid", "suid", "rgid", "egid", "sgid"];
|
|
8587
|
-
|
|
8729
|
+
NS_PER_MS4 = 1000000n;
|
|
8588
8730
|
AT_SYMLINK_NOFOLLOW2 = 1;
|
|
8589
8731
|
AT_EACCESS2 = 2;
|
|
8590
8732
|
ROOT_IDS = Object.freeze({ uid: 0, gid: 0 });
|
|
8591
8733
|
GONE = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
|
|
8592
8734
|
S_IFIFO = 4096;
|
|
8593
8735
|
DEFAULT_UMASK = 18;
|
|
8594
|
-
MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) *
|
|
8736
|
+
MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS4;
|
|
8595
8737
|
MAX_READ = 1024 * 1024;
|
|
8596
8738
|
SIGPIPE_EXIT = 128 + SIG.PIPE;
|
|
8597
8739
|
SIG_IGN = 1;
|
|
@@ -8868,6 +9010,11 @@ var init_wasi_host = __esm({
|
|
|
8868
9010
|
this.entered
|
|
8869
9011
|
);
|
|
8870
9012
|
},
|
|
9013
|
+
sigaction_inherited: (out) => {
|
|
9014
|
+
const bits = this.o.kernel.call({ op: "sig-inherited" });
|
|
9015
|
+
mem.view().setBigUint64(out, BigInt(libcBits(bits) >>> 0), true);
|
|
9016
|
+
return E.SUCCESS;
|
|
9017
|
+
},
|
|
8871
9018
|
sigpending_get: (out) => {
|
|
8872
9019
|
if (!this.sigmask) return E.NOSYS;
|
|
8873
9020
|
mem.view().setBigUint64(out, BigInt(this.sigmask.pending()), true);
|
|
@@ -8947,7 +9094,7 @@ var init_wasi_host = __esm({
|
|
|
8947
9094
|
return this.cache;
|
|
8948
9095
|
}
|
|
8949
9096
|
now(id) {
|
|
8950
|
-
if (id === CLOCK.REALTIME) return BigInt(Date.now()) *
|
|
9097
|
+
if (id === CLOCK.REALTIME) return BigInt(Date.now()) * NS_PER_MS4;
|
|
8951
9098
|
if (id === CLOCK.MONOTONIC) {
|
|
8952
9099
|
return MONOTONIC_BASE + BigInt(Math.round(performance.now() * 1e6));
|
|
8953
9100
|
}
|
|
@@ -9488,7 +9635,7 @@ var init_wasi_host = __esm({
|
|
|
9488
9635
|
current ??= statOf(path);
|
|
9489
9636
|
return current[field2] ?? current.mtimeMs ?? now;
|
|
9490
9637
|
};
|
|
9491
|
-
const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 /
|
|
9638
|
+
const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 / NS_PER_MS4) : kept(field2);
|
|
9492
9639
|
(follow2 ? this.o.fs.utimes : this.o.fs.lutimes).call(
|
|
9493
9640
|
this.o.fs,
|
|
9494
9641
|
path,
|
|
@@ -9893,13 +10040,15 @@ function importsContext({
|
|
|
9893
10040
|
const fds = {
|
|
9894
10041
|
open(path, o = {}) {
|
|
9895
10042
|
const abs = host.fds.resolve(3, path);
|
|
9896
|
-
|
|
10043
|
+
const fresh = o.create === true && o.exclusive === true && owners && fs.create !== void 0;
|
|
10044
|
+
if (!fresh && o.nofollow && fs.exists(abs) && fs.lstat(abs).isSymbolicLink)
|
|
9897
10045
|
throw new WasiError("ELOOP");
|
|
9898
|
-
const existed = fs.exists(abs);
|
|
10046
|
+
const existed = !fresh && fs.exists(abs);
|
|
9899
10047
|
const oflags = (o.create ? OFLAGS.CREAT : 0) | (o.exclusive ? OFLAGS.EXCL : 0) | (o.truncate ? OFLAGS.TRUNC : 0) | (o.directory ? OFLAGS.DIRECTORY : 0);
|
|
9900
10048
|
const rights = (o.write ? RIGHTS.FD_WRITE : 0n) | (o.read || !o.write ? RIGHTS.FD_READ : 0n);
|
|
9901
|
-
const
|
|
9902
|
-
|
|
10049
|
+
const flags = o.append ? FDFLAGS.APPEND : 0;
|
|
10050
|
+
const fd = host.fds.open(abs, oflags, rights, flags, fresh ? o.mode : void 0);
|
|
10051
|
+
if (o.mode !== void 0 && !existed && !fresh) fs.chmod(abs, o.mode);
|
|
9903
10052
|
return fd;
|
|
9904
10053
|
},
|
|
9905
10054
|
close(fd) {
|
|
@@ -10488,138 +10637,8 @@ var init_wasi_procfs = __esm({
|
|
|
10488
10637
|
}
|
|
10489
10638
|
});
|
|
10490
10639
|
|
|
10491
|
-
// src/process/wasi/wasi-sigmask.ts
|
|
10492
|
-
var UNBLOCKABLE, LIBC_UNBLOCKABLE, FOREVER2, NS_PER_MS4, POLL_MS, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
|
|
10493
|
-
var init_wasi_sigmask = __esm({
|
|
10494
|
-
"src/process/wasi/wasi-sigmask.ts"() {
|
|
10495
|
-
"use strict";
|
|
10496
|
-
init_signals();
|
|
10497
|
-
init_sync_sab_wire();
|
|
10498
|
-
init_wasi_abi();
|
|
10499
|
-
UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
|
|
10500
|
-
LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
|
|
10501
|
-
FOREVER2 = 0xffffffffffffffffn;
|
|
10502
|
-
NS_PER_MS4 = 1000000n;
|
|
10503
|
-
POLL_MS = 50;
|
|
10504
|
-
SIG_BLOCK = 0;
|
|
10505
|
-
SIG_UNBLOCK = 1;
|
|
10506
|
-
SIG_SETMASK = 2;
|
|
10507
|
-
kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
|
|
10508
|
-
libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
|
|
10509
|
-
apply = (how, mask, set) => {
|
|
10510
|
-
if (how === SIG_BLOCK) return mask | set;
|
|
10511
|
-
if (how === SIG_UNBLOCK) return mask & ~set;
|
|
10512
|
-
return set;
|
|
10513
|
-
};
|
|
10514
|
-
WasiSigmask = class {
|
|
10515
|
-
lo;
|
|
10516
|
-
hi;
|
|
10517
|
-
header;
|
|
10518
|
-
deliver;
|
|
10519
|
-
process;
|
|
10520
|
-
tid;
|
|
10521
|
-
constructor(header, deliver, process, tid = 1) {
|
|
10522
|
-
this.header = header;
|
|
10523
|
-
this.deliver = deliver;
|
|
10524
|
-
this.process = process;
|
|
10525
|
-
this.tid = tid;
|
|
10526
|
-
this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
|
|
10527
|
-
this.hi = Atomics.load(header, SAB_I_BLOCKED_HI);
|
|
10528
|
-
}
|
|
10529
|
-
static unsupported(header) {
|
|
10530
|
-
storeBlocked(header, [0, 0]);
|
|
10531
|
-
}
|
|
10532
|
-
set(how, setLo, setHi, old) {
|
|
10533
|
-
if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
|
|
10534
|
-
old(this.lo >>> 0, this.hi >>> 0);
|
|
10535
|
-
this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
|
|
10536
|
-
this.hi = apply(how, this.hi, setHi | 0);
|
|
10537
|
-
const now = kernelBits(this.lo);
|
|
10538
|
-
storeBlocked(this.header, [now, this.hi]);
|
|
10539
|
-
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
|
|
10540
|
-
return E.SUCCESS;
|
|
10541
|
-
}
|
|
10542
|
-
swap(setLo, setHi) {
|
|
10543
|
-
const old = [this.lo, this.hi];
|
|
10544
|
-
this.lo = setLo & ~LIBC_UNBLOCKABLE;
|
|
10545
|
-
this.hi = setHi | 0;
|
|
10546
|
-
storeBlocked(this.header, [kernelBits(this.lo), this.hi]);
|
|
10547
|
-
return old;
|
|
10548
|
-
}
|
|
10549
|
-
deliverUnblocked() {
|
|
10550
|
-
const now = Atomics.load(this.header, SAB_I_BLOCKED);
|
|
10551
|
-
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) === 0) return false;
|
|
10552
|
-
this.deliver();
|
|
10553
|
-
return true;
|
|
10554
|
-
}
|
|
10555
|
-
restore([lo, hi]) {
|
|
10556
|
-
this.set(SIG_SETMASK, lo, hi, () => {
|
|
10557
|
-
});
|
|
10558
|
-
}
|
|
10559
|
-
blockedBits() {
|
|
10560
|
-
return Atomics.load(this.header, SAB_I_BLOCKED);
|
|
10561
|
-
}
|
|
10562
|
-
blocks(sig) {
|
|
10563
|
-
return (Atomics.load(this.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
|
|
10564
|
-
}
|
|
10565
|
-
inherited() {
|
|
10566
|
-
return [kernelBits(this.lo), this.hi];
|
|
10567
|
-
}
|
|
10568
|
-
discard(sig) {
|
|
10569
|
-
Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
|
|
10570
|
-
if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
|
|
10571
|
-
}
|
|
10572
|
-
sigwait(setLo, timeoutNs, publish, took, entered = false) {
|
|
10573
|
-
const set = kernelBits(setLo | 0);
|
|
10574
|
-
const value2 = BigInt.asUintN(64, timeoutNs);
|
|
10575
|
-
const deadline = value2 === FOREVER2 ? Number.POSITIVE_INFINITY : performance.now() + Number((value2 + NS_PER_MS4 - 1n) / NS_PER_MS4);
|
|
10576
|
-
publish(set);
|
|
10577
|
-
try {
|
|
10578
|
-
for (; ; ) {
|
|
10579
|
-
const seen = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
10580
|
-
const sig = this.take(set);
|
|
10581
|
-
if (sig !== 0) {
|
|
10582
|
-
took(sig);
|
|
10583
|
-
return E.SUCCESS;
|
|
10584
|
-
}
|
|
10585
|
-
if (entered || this.deliverUnblocked() || this.interrupted()) return E.INTR;
|
|
10586
|
-
const left = deadline - performance.now();
|
|
10587
|
-
if (left <= 0) return E.AGAIN;
|
|
10588
|
-
Atomics.wait(this.header, SAB_I_SIGNALS, seen, Math.min(left, POLL_MS));
|
|
10589
|
-
}
|
|
10590
|
-
} finally {
|
|
10591
|
-
publish(0);
|
|
10592
|
-
}
|
|
10593
|
-
}
|
|
10594
|
-
take(set) {
|
|
10595
|
-
for (const header of this.process ? [this.header, this.process] : [this.header]) {
|
|
10596
|
-
const ready = Atomics.load(header, SAB_I_SIGNALS) & set;
|
|
10597
|
-
if (ready === 0) continue;
|
|
10598
|
-
const bit = ready & -ready;
|
|
10599
|
-
if ((Atomics.and(header, SAB_I_SIGNALS, ~bit) & bit) !== 0) return 31 - Math.clz32(bit);
|
|
10600
|
-
}
|
|
10601
|
-
return 0;
|
|
10602
|
-
}
|
|
10603
|
-
interrupted() {
|
|
10604
|
-
const killed = this.process ?? this.header;
|
|
10605
|
-
if (Atomics.load(killed, SAB_I_KILLED) !== 0) {
|
|
10606
|
-
this.deliver();
|
|
10607
|
-
return true;
|
|
10608
|
-
}
|
|
10609
|
-
if (Atomics.load(killed, SAB_I_STOP) !== 1) return false;
|
|
10610
|
-
while (Atomics.load(killed, SAB_I_STOP) === 1) Atomics.wait(killed, SAB_I_STOP, 1);
|
|
10611
|
-
return true;
|
|
10612
|
-
}
|
|
10613
|
-
pending() {
|
|
10614
|
-
const own = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
10615
|
-
return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
|
|
10616
|
-
}
|
|
10617
|
-
};
|
|
10618
|
-
}
|
|
10619
|
-
});
|
|
10620
|
-
|
|
10621
10640
|
// src/process/wasi/wasi-signals.ts
|
|
10622
|
-
var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
|
|
10641
|
+
var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, SA_NOCLDWAIT, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
|
|
10623
10642
|
var init_wasi_signals = __esm({
|
|
10624
10643
|
"src/process/wasi/wasi-signals.ts"() {
|
|
10625
10644
|
"use strict";
|
|
@@ -10630,6 +10649,7 @@ var init_wasi_signals = __esm({
|
|
|
10630
10649
|
KERNEL_DEFAULTS = [SIG.TSTP, SIG.TTIN, SIG.TTOU, SIG.CHLD, SIG.CONT, SIG.URG, SIG.WINCH].map(sigbit).reduce((m, bit) => m | bit, 0);
|
|
10631
10650
|
LIBC_DEFAULT_EXIT = 127;
|
|
10632
10651
|
SA_RESTART = 268435456;
|
|
10652
|
+
SA_NOCLDWAIT = 2;
|
|
10633
10653
|
DISPOSITION_IGNORE = 1;
|
|
10634
10654
|
DISPOSITION_HANDLER = 2;
|
|
10635
10655
|
withBit = (mask, bit, on) => on ? mask | bit : mask & ~bit;
|
|
@@ -10646,6 +10666,7 @@ var init_wasi_signals = __esm({
|
|
|
10646
10666
|
ignoring = 0;
|
|
10647
10667
|
restarting = 0;
|
|
10648
10668
|
defaults = 0;
|
|
10669
|
+
nocldwait = false;
|
|
10649
10670
|
fallBack;
|
|
10650
10671
|
onKilled;
|
|
10651
10672
|
constructor(fallBack, onKilled) {
|
|
@@ -10671,6 +10692,7 @@ var init_wasi_signals = __esm({
|
|
|
10671
10692
|
this.ignoring = withBit(this.ignoring, bit, disposition === DISPOSITION_IGNORE);
|
|
10672
10693
|
this.restarting = withBit(this.restarting, bit, (flags & SA_RESTART) !== 0);
|
|
10673
10694
|
this.defaults = withBit(this.defaults, bit, disposition === 0);
|
|
10695
|
+
if (sig === SIG.CHLD) this.nocldwait = (flags & SA_NOCLDWAIT) !== 0;
|
|
10674
10696
|
return E.SUCCESS;
|
|
10675
10697
|
}
|
|
10676
10698
|
snapshot() {
|
|
@@ -10680,7 +10702,8 @@ var init_wasi_signals = __esm({
|
|
|
10680
10702
|
handlers: this.handlers,
|
|
10681
10703
|
ignoring: this.ignoring,
|
|
10682
10704
|
restarting: this.restarting,
|
|
10683
|
-
uncaught: this.uncaught
|
|
10705
|
+
uncaught: this.uncaught,
|
|
10706
|
+
...this.nocldwait ? { nocldwait: true } : {}
|
|
10684
10707
|
};
|
|
10685
10708
|
}
|
|
10686
10709
|
restore(state) {
|
|
@@ -10690,13 +10713,15 @@ var init_wasi_signals = __esm({
|
|
|
10690
10713
|
this.ignoring = state.ignoring;
|
|
10691
10714
|
this.restarting = state.restarting;
|
|
10692
10715
|
this.uncaught = state.uncaught;
|
|
10716
|
+
this.nocldwait = state.nocldwait === true;
|
|
10693
10717
|
}
|
|
10694
10718
|
masks() {
|
|
10695
10719
|
if (this.hooked) {
|
|
10696
10720
|
const caught = this.handler() ? this.handlers : 0;
|
|
10697
10721
|
const defaults = this.defaults;
|
|
10698
10722
|
this.defaults = 0;
|
|
10699
|
-
|
|
10723
|
+
const nocldwait = this.nocldwait ? { nocldwait: true } : {};
|
|
10724
|
+
return { caught, ignored: this.ignoring, restart: this.restarting, defaults, ...nocldwait };
|
|
10700
10725
|
}
|
|
10701
10726
|
if (!this.handler()) return null;
|
|
10702
10727
|
return { caught: DELIVERED_MASK & ~this.uncaught & ~KERNEL_DEFAULTS, ignored: 0, restart: 0 };
|