@ai-ecoverse/slicc-kernel 1.107.1 → 1.108.0
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 +7 -1
- package/dist/kernel-worker.js +27 -5
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +169 -149
- 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 +169 -149
- 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-host.d.ts +1 -1
- package/dist/types/process/wasi/wasi-signals.d.ts +4 -7
- package/package.json +1 -1
|
@@ -2856,6 +2856,136 @@ var init_wasi_poll = __esm({
|
|
|
2856
2856
|
}
|
|
2857
2857
|
});
|
|
2858
2858
|
|
|
2859
|
+
// src/process/wasi/wasi-sigmask.ts
|
|
2860
|
+
var UNBLOCKABLE, LIBC_UNBLOCKABLE, FOREVER, NS_PER_MS2, POLL_MS, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
|
|
2861
|
+
var init_wasi_sigmask = __esm({
|
|
2862
|
+
"src/process/wasi/wasi-sigmask.ts"() {
|
|
2863
|
+
"use strict";
|
|
2864
|
+
init_signals();
|
|
2865
|
+
init_sync_sab_wire();
|
|
2866
|
+
init_wasi_abi();
|
|
2867
|
+
UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
|
|
2868
|
+
LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
|
|
2869
|
+
FOREVER = 0xffffffffffffffffn;
|
|
2870
|
+
NS_PER_MS2 = 1000000n;
|
|
2871
|
+
POLL_MS = 50;
|
|
2872
|
+
SIG_BLOCK = 0;
|
|
2873
|
+
SIG_UNBLOCK = 1;
|
|
2874
|
+
SIG_SETMASK = 2;
|
|
2875
|
+
kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
|
|
2876
|
+
libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
|
|
2877
|
+
apply = (how, mask, set) => {
|
|
2878
|
+
if (how === SIG_BLOCK) return mask | set;
|
|
2879
|
+
if (how === SIG_UNBLOCK) return mask & ~set;
|
|
2880
|
+
return set;
|
|
2881
|
+
};
|
|
2882
|
+
WasiSigmask = class {
|
|
2883
|
+
lo;
|
|
2884
|
+
hi;
|
|
2885
|
+
header;
|
|
2886
|
+
deliver;
|
|
2887
|
+
process;
|
|
2888
|
+
tid;
|
|
2889
|
+
constructor(header, deliver, process, tid = 1) {
|
|
2890
|
+
this.header = header;
|
|
2891
|
+
this.deliver = deliver;
|
|
2892
|
+
this.process = process;
|
|
2893
|
+
this.tid = tid;
|
|
2894
|
+
this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
|
|
2895
|
+
this.hi = Atomics.load(header, SAB_I_BLOCKED_HI);
|
|
2896
|
+
}
|
|
2897
|
+
static unsupported(header) {
|
|
2898
|
+
storeBlocked(header, [0, 0]);
|
|
2899
|
+
}
|
|
2900
|
+
set(how, setLo, setHi, old) {
|
|
2901
|
+
if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
|
|
2902
|
+
old(this.lo >>> 0, this.hi >>> 0);
|
|
2903
|
+
this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
|
|
2904
|
+
this.hi = apply(how, this.hi, setHi | 0);
|
|
2905
|
+
const now = kernelBits(this.lo);
|
|
2906
|
+
storeBlocked(this.header, [now, this.hi]);
|
|
2907
|
+
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
|
|
2908
|
+
return E.SUCCESS;
|
|
2909
|
+
}
|
|
2910
|
+
swap(setLo, setHi) {
|
|
2911
|
+
const old = [this.lo, this.hi];
|
|
2912
|
+
this.lo = setLo & ~LIBC_UNBLOCKABLE;
|
|
2913
|
+
this.hi = setHi | 0;
|
|
2914
|
+
storeBlocked(this.header, [kernelBits(this.lo), this.hi]);
|
|
2915
|
+
return old;
|
|
2916
|
+
}
|
|
2917
|
+
deliverUnblocked() {
|
|
2918
|
+
const now = Atomics.load(this.header, SAB_I_BLOCKED);
|
|
2919
|
+
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) === 0) return false;
|
|
2920
|
+
this.deliver();
|
|
2921
|
+
return true;
|
|
2922
|
+
}
|
|
2923
|
+
restore([lo, hi]) {
|
|
2924
|
+
this.set(SIG_SETMASK, lo, hi, () => {
|
|
2925
|
+
});
|
|
2926
|
+
}
|
|
2927
|
+
blockedBits() {
|
|
2928
|
+
return Atomics.load(this.header, SAB_I_BLOCKED);
|
|
2929
|
+
}
|
|
2930
|
+
blocks(sig) {
|
|
2931
|
+
return (Atomics.load(this.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
|
|
2932
|
+
}
|
|
2933
|
+
inherited() {
|
|
2934
|
+
return [kernelBits(this.lo), this.hi];
|
|
2935
|
+
}
|
|
2936
|
+
discard(sig) {
|
|
2937
|
+
Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
|
|
2938
|
+
if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
|
|
2939
|
+
}
|
|
2940
|
+
sigwait(setLo, timeoutNs, publish, took, entered = false) {
|
|
2941
|
+
const set = kernelBits(setLo | 0);
|
|
2942
|
+
const value2 = BigInt.asUintN(64, timeoutNs);
|
|
2943
|
+
const deadline = value2 === FOREVER ? Number.POSITIVE_INFINITY : performance.now() + Number((value2 + NS_PER_MS2 - 1n) / NS_PER_MS2);
|
|
2944
|
+
publish(set);
|
|
2945
|
+
try {
|
|
2946
|
+
for (; ; ) {
|
|
2947
|
+
const seen = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
2948
|
+
const sig = this.take(set);
|
|
2949
|
+
if (sig !== 0) {
|
|
2950
|
+
took(sig);
|
|
2951
|
+
return E.SUCCESS;
|
|
2952
|
+
}
|
|
2953
|
+
if (entered || this.deliverUnblocked() || this.interrupted()) return E.INTR;
|
|
2954
|
+
const left = deadline - performance.now();
|
|
2955
|
+
if (left <= 0) return E.AGAIN;
|
|
2956
|
+
Atomics.wait(this.header, SAB_I_SIGNALS, seen, Math.min(left, POLL_MS));
|
|
2957
|
+
}
|
|
2958
|
+
} finally {
|
|
2959
|
+
publish(0);
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
take(set) {
|
|
2963
|
+
for (const header of this.process ? [this.header, this.process] : [this.header]) {
|
|
2964
|
+
const ready = Atomics.load(header, SAB_I_SIGNALS) & set;
|
|
2965
|
+
if (ready === 0) continue;
|
|
2966
|
+
const bit = ready & -ready;
|
|
2967
|
+
if ((Atomics.and(header, SAB_I_SIGNALS, ~bit) & bit) !== 0) return 31 - Math.clz32(bit);
|
|
2968
|
+
}
|
|
2969
|
+
return 0;
|
|
2970
|
+
}
|
|
2971
|
+
interrupted() {
|
|
2972
|
+
const killed = this.process ?? this.header;
|
|
2973
|
+
if (Atomics.load(killed, SAB_I_KILLED) !== 0) {
|
|
2974
|
+
this.deliver();
|
|
2975
|
+
return true;
|
|
2976
|
+
}
|
|
2977
|
+
if (Atomics.load(killed, SAB_I_STOP) !== 1) return false;
|
|
2978
|
+
while (Atomics.load(killed, SAB_I_STOP) === 1) Atomics.wait(killed, SAB_I_STOP, 1);
|
|
2979
|
+
return true;
|
|
2980
|
+
}
|
|
2981
|
+
pending() {
|
|
2982
|
+
const own = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
2983
|
+
return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
|
|
2984
|
+
}
|
|
2985
|
+
};
|
|
2986
|
+
}
|
|
2987
|
+
});
|
|
2988
|
+
|
|
2859
2989
|
// src/process/wasi/wasi-termios.ts
|
|
2860
2990
|
function writeTermios(mem, ptr, termios) {
|
|
2861
2991
|
mem.bytes(ptr, OSPEED + 4).fill(0);
|
|
@@ -2934,8 +3064,8 @@ var init_wasi_termios = __esm({
|
|
|
2934
3064
|
// src/process/wasi/wasix-epoll.ts
|
|
2935
3065
|
function timeoutMs(ns) {
|
|
2936
3066
|
const value2 = BigInt.asUintN(64, ns);
|
|
2937
|
-
if (value2 ===
|
|
2938
|
-
const ms = (value2 +
|
|
3067
|
+
if (value2 === FOREVER2) return -1;
|
|
3068
|
+
const ms = (value2 + NS_PER_MS3 - 1n) / NS_PER_MS3;
|
|
2939
3069
|
return ms > BigInt(MAX_TIMEOUT_MS) ? -1 : Number(ms);
|
|
2940
3070
|
}
|
|
2941
3071
|
function wasixEpollImports(host) {
|
|
@@ -2996,7 +3126,7 @@ function wasixEpollImports(host) {
|
|
|
2996
3126
|
}
|
|
2997
3127
|
};
|
|
2998
3128
|
}
|
|
2999
|
-
var EVENT_SIZE, DATA_OFFSET, DATA_SIZE, MAX_EVENTS,
|
|
3129
|
+
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;
|
|
3000
3130
|
var init_wasix_epoll = __esm({
|
|
3001
3131
|
"src/process/wasi/wasix-epoll.ts"() {
|
|
3002
3132
|
"use strict";
|
|
@@ -3006,9 +3136,9 @@ var init_wasix_epoll = __esm({
|
|
|
3006
3136
|
DATA_OFFSET = 8;
|
|
3007
3137
|
DATA_SIZE = 24;
|
|
3008
3138
|
MAX_EVENTS = 4096;
|
|
3009
|
-
|
|
3139
|
+
FOREVER2 = 0xffffffffffffffffn;
|
|
3010
3140
|
MAX_TIMEOUT_MS = 2147483647;
|
|
3011
|
-
|
|
3141
|
+
NS_PER_MS3 = 1000000n;
|
|
3012
3142
|
EVENTFD_SEMAPHORE = 1;
|
|
3013
3143
|
EVENTFD_NONBLOCK = 4;
|
|
3014
3144
|
EVENTFD_MAX = 0xfffffffffffffffen;
|
|
@@ -3449,7 +3579,7 @@ function filestatOf(path, s) {
|
|
|
3449
3579
|
size: BigInt(s.size),
|
|
3450
3580
|
ino: s.ino !== void 0 ? BigInt(s.ino) : pathInode(path),
|
|
3451
3581
|
...s.nlink !== void 0 ? { nlink: BigInt(s.nlink) } : {},
|
|
3452
|
-
mtimeNs: BigInt(Math.round(s.mtimeMs ?? 0)) *
|
|
3582
|
+
mtimeNs: BigInt(Math.round(s.mtimeMs ?? 0)) * NS_PER_MS4
|
|
3453
3583
|
};
|
|
3454
3584
|
}
|
|
3455
3585
|
function kernelFiletype(kind) {
|
|
@@ -3499,7 +3629,7 @@ function wrap(table) {
|
|
|
3499
3629
|
}
|
|
3500
3630
|
return out;
|
|
3501
3631
|
}
|
|
3502
|
-
var WasiExit, IDS,
|
|
3632
|
+
var WasiExit, IDS, NS_PER_MS4, AT_SYMLINK_NOFOLLOW, AT_EACCESS, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
|
|
3503
3633
|
var init_wasi_host = __esm({
|
|
3504
3634
|
"src/process/wasi/wasi-host.ts"() {
|
|
3505
3635
|
"use strict";
|
|
@@ -3516,6 +3646,7 @@ var init_wasi_host = __esm({
|
|
|
3516
3646
|
init_wasi_files();
|
|
3517
3647
|
init_wasi_memory();
|
|
3518
3648
|
init_wasi_poll();
|
|
3649
|
+
init_wasi_sigmask();
|
|
3519
3650
|
init_wasi_termios();
|
|
3520
3651
|
init_wasix_epoll();
|
|
3521
3652
|
init_wasix_sockets();
|
|
@@ -3527,14 +3658,14 @@ var init_wasi_host = __esm({
|
|
|
3527
3658
|
}
|
|
3528
3659
|
};
|
|
3529
3660
|
IDS = ["ruid", "euid", "suid", "rgid", "egid", "sgid"];
|
|
3530
|
-
|
|
3661
|
+
NS_PER_MS4 = 1000000n;
|
|
3531
3662
|
AT_SYMLINK_NOFOLLOW = 1;
|
|
3532
3663
|
AT_EACCESS = 2;
|
|
3533
3664
|
ROOT_IDS = Object.freeze({ uid: 0, gid: 0 });
|
|
3534
3665
|
GONE = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
|
|
3535
3666
|
S_IFIFO = 4096;
|
|
3536
3667
|
DEFAULT_UMASK = 18;
|
|
3537
|
-
MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) *
|
|
3668
|
+
MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS4;
|
|
3538
3669
|
MAX_READ = 1024 * 1024;
|
|
3539
3670
|
SIGPIPE_EXIT = 128 + SIG.PIPE;
|
|
3540
3671
|
SIG_IGN = 1;
|
|
@@ -3811,6 +3942,11 @@ var init_wasi_host = __esm({
|
|
|
3811
3942
|
this.entered
|
|
3812
3943
|
);
|
|
3813
3944
|
},
|
|
3945
|
+
sigaction_inherited: (out) => {
|
|
3946
|
+
const bits = this.o.kernel.call({ op: "sig-inherited" });
|
|
3947
|
+
mem.view().setBigUint64(out, BigInt(libcBits(bits) >>> 0), true);
|
|
3948
|
+
return E.SUCCESS;
|
|
3949
|
+
},
|
|
3814
3950
|
sigpending_get: (out) => {
|
|
3815
3951
|
if (!this.sigmask) return E.NOSYS;
|
|
3816
3952
|
mem.view().setBigUint64(out, BigInt(this.sigmask.pending()), true);
|
|
@@ -3890,7 +4026,7 @@ var init_wasi_host = __esm({
|
|
|
3890
4026
|
return this.cache;
|
|
3891
4027
|
}
|
|
3892
4028
|
now(id) {
|
|
3893
|
-
if (id === CLOCK.REALTIME) return BigInt(Date.now()) *
|
|
4029
|
+
if (id === CLOCK.REALTIME) return BigInt(Date.now()) * NS_PER_MS4;
|
|
3894
4030
|
if (id === CLOCK.MONOTONIC) {
|
|
3895
4031
|
return MONOTONIC_BASE + BigInt(Math.round(performance.now() * 1e6));
|
|
3896
4032
|
}
|
|
@@ -4431,7 +4567,7 @@ var init_wasi_host = __esm({
|
|
|
4431
4567
|
current ??= statOf(path);
|
|
4432
4568
|
return current[field2] ?? current.mtimeMs ?? now;
|
|
4433
4569
|
};
|
|
4434
|
-
const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 /
|
|
4570
|
+
const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 / NS_PER_MS4) : kept(field2);
|
|
4435
4571
|
(follow2 ? this.o.fs.utimes : this.o.fs.lutimes).call(
|
|
4436
4572
|
this.o.fs,
|
|
4437
4573
|
path,
|
|
@@ -5031,7 +5167,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
5031
5167
|
var init_version = __esm({
|
|
5032
5168
|
"src/version.ts"() {
|
|
5033
5169
|
"use strict";
|
|
5034
|
-
KERNEL_VERSION = true ? "1.
|
|
5170
|
+
KERNEL_VERSION = true ? "1.108.0" : "0.0.0-dev";
|
|
5035
5171
|
OS_RELEASE = "6.0.0-slicc";
|
|
5036
5172
|
}
|
|
5037
5173
|
});
|
|
@@ -12612,7 +12748,7 @@ var init_process_signals = __esm({
|
|
|
12612
12748
|
init_signals();
|
|
12613
12749
|
init_sync_sab_wire();
|
|
12614
12750
|
SignalGate = class {
|
|
12615
|
-
reported = { caught: 0, ignored: 0 };
|
|
12751
|
+
reported = { caught: 0, ignored: 0, nocldwait: false };
|
|
12616
12752
|
restart = 0;
|
|
12617
12753
|
lastDelivered = 0;
|
|
12618
12754
|
depth = 0;
|
|
@@ -12665,10 +12801,18 @@ var init_process_signals = __esm({
|
|
|
12665
12801
|
if (!masks) return;
|
|
12666
12802
|
this.restart = masks.restart;
|
|
12667
12803
|
const { caught, ignored, defaults = 0 } = masks;
|
|
12668
|
-
const
|
|
12804
|
+
const nocldwait = masks.nocldwait === true;
|
|
12805
|
+
const was = this.reported;
|
|
12806
|
+
const same = caught === was.caught && ignored === was.ignored && nocldwait === was.nocldwait;
|
|
12669
12807
|
if (same && defaults === 0) return;
|
|
12670
|
-
this.reported = { caught, ignored };
|
|
12671
|
-
const req = {
|
|
12808
|
+
this.reported = { caught, ignored, nocldwait };
|
|
12809
|
+
const req = {
|
|
12810
|
+
op: "sig-mask",
|
|
12811
|
+
caught,
|
|
12812
|
+
ignored,
|
|
12813
|
+
...defaults ? { defaults } : {},
|
|
12814
|
+
...nocldwait ? { nocldwait } : {}
|
|
12815
|
+
};
|
|
12672
12816
|
this.raw.call(req, Number.POSITIVE_INFINITY, "sig-mask");
|
|
12673
12817
|
}
|
|
12674
12818
|
quiet(fn) {
|
|
@@ -13619,138 +13763,8 @@ var init_wasi_module = __esm({
|
|
|
13619
13763
|
}
|
|
13620
13764
|
});
|
|
13621
13765
|
|
|
13622
|
-
// src/process/wasi/wasi-sigmask.ts
|
|
13623
|
-
var UNBLOCKABLE, LIBC_UNBLOCKABLE, FOREVER2, NS_PER_MS4, POLL_MS, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
|
|
13624
|
-
var init_wasi_sigmask = __esm({
|
|
13625
|
-
"src/process/wasi/wasi-sigmask.ts"() {
|
|
13626
|
-
"use strict";
|
|
13627
|
-
init_signals();
|
|
13628
|
-
init_sync_sab_wire();
|
|
13629
|
-
init_wasi_abi();
|
|
13630
|
-
UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
|
|
13631
|
-
LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
|
|
13632
|
-
FOREVER2 = 0xffffffffffffffffn;
|
|
13633
|
-
NS_PER_MS4 = 1000000n;
|
|
13634
|
-
POLL_MS = 50;
|
|
13635
|
-
SIG_BLOCK = 0;
|
|
13636
|
-
SIG_UNBLOCK = 1;
|
|
13637
|
-
SIG_SETMASK = 2;
|
|
13638
|
-
kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
|
|
13639
|
-
libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
|
|
13640
|
-
apply = (how, mask, set) => {
|
|
13641
|
-
if (how === SIG_BLOCK) return mask | set;
|
|
13642
|
-
if (how === SIG_UNBLOCK) return mask & ~set;
|
|
13643
|
-
return set;
|
|
13644
|
-
};
|
|
13645
|
-
WasiSigmask = class {
|
|
13646
|
-
lo;
|
|
13647
|
-
hi;
|
|
13648
|
-
header;
|
|
13649
|
-
deliver;
|
|
13650
|
-
process;
|
|
13651
|
-
tid;
|
|
13652
|
-
constructor(header, deliver, process, tid = 1) {
|
|
13653
|
-
this.header = header;
|
|
13654
|
-
this.deliver = deliver;
|
|
13655
|
-
this.process = process;
|
|
13656
|
-
this.tid = tid;
|
|
13657
|
-
this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
|
|
13658
|
-
this.hi = Atomics.load(header, SAB_I_BLOCKED_HI);
|
|
13659
|
-
}
|
|
13660
|
-
static unsupported(header) {
|
|
13661
|
-
storeBlocked(header, [0, 0]);
|
|
13662
|
-
}
|
|
13663
|
-
set(how, setLo, setHi, old) {
|
|
13664
|
-
if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
|
|
13665
|
-
old(this.lo >>> 0, this.hi >>> 0);
|
|
13666
|
-
this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
|
|
13667
|
-
this.hi = apply(how, this.hi, setHi | 0);
|
|
13668
|
-
const now = kernelBits(this.lo);
|
|
13669
|
-
storeBlocked(this.header, [now, this.hi]);
|
|
13670
|
-
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
|
|
13671
|
-
return E.SUCCESS;
|
|
13672
|
-
}
|
|
13673
|
-
swap(setLo, setHi) {
|
|
13674
|
-
const old = [this.lo, this.hi];
|
|
13675
|
-
this.lo = setLo & ~LIBC_UNBLOCKABLE;
|
|
13676
|
-
this.hi = setHi | 0;
|
|
13677
|
-
storeBlocked(this.header, [kernelBits(this.lo), this.hi]);
|
|
13678
|
-
return old;
|
|
13679
|
-
}
|
|
13680
|
-
deliverUnblocked() {
|
|
13681
|
-
const now = Atomics.load(this.header, SAB_I_BLOCKED);
|
|
13682
|
-
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) === 0) return false;
|
|
13683
|
-
this.deliver();
|
|
13684
|
-
return true;
|
|
13685
|
-
}
|
|
13686
|
-
restore([lo, hi]) {
|
|
13687
|
-
this.set(SIG_SETMASK, lo, hi, () => {
|
|
13688
|
-
});
|
|
13689
|
-
}
|
|
13690
|
-
blockedBits() {
|
|
13691
|
-
return Atomics.load(this.header, SAB_I_BLOCKED);
|
|
13692
|
-
}
|
|
13693
|
-
blocks(sig) {
|
|
13694
|
-
return (Atomics.load(this.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
|
|
13695
|
-
}
|
|
13696
|
-
inherited() {
|
|
13697
|
-
return [kernelBits(this.lo), this.hi];
|
|
13698
|
-
}
|
|
13699
|
-
discard(sig) {
|
|
13700
|
-
Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
|
|
13701
|
-
if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
|
|
13702
|
-
}
|
|
13703
|
-
sigwait(setLo, timeoutNs, publish, took, entered = false) {
|
|
13704
|
-
const set = kernelBits(setLo | 0);
|
|
13705
|
-
const value2 = BigInt.asUintN(64, timeoutNs);
|
|
13706
|
-
const deadline = value2 === FOREVER2 ? Number.POSITIVE_INFINITY : performance.now() + Number((value2 + NS_PER_MS4 - 1n) / NS_PER_MS4);
|
|
13707
|
-
publish(set);
|
|
13708
|
-
try {
|
|
13709
|
-
for (; ; ) {
|
|
13710
|
-
const seen = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
13711
|
-
const sig = this.take(set);
|
|
13712
|
-
if (sig !== 0) {
|
|
13713
|
-
took(sig);
|
|
13714
|
-
return E.SUCCESS;
|
|
13715
|
-
}
|
|
13716
|
-
if (entered || this.deliverUnblocked() || this.interrupted()) return E.INTR;
|
|
13717
|
-
const left = deadline - performance.now();
|
|
13718
|
-
if (left <= 0) return E.AGAIN;
|
|
13719
|
-
Atomics.wait(this.header, SAB_I_SIGNALS, seen, Math.min(left, POLL_MS));
|
|
13720
|
-
}
|
|
13721
|
-
} finally {
|
|
13722
|
-
publish(0);
|
|
13723
|
-
}
|
|
13724
|
-
}
|
|
13725
|
-
take(set) {
|
|
13726
|
-
for (const header of this.process ? [this.header, this.process] : [this.header]) {
|
|
13727
|
-
const ready = Atomics.load(header, SAB_I_SIGNALS) & set;
|
|
13728
|
-
if (ready === 0) continue;
|
|
13729
|
-
const bit = ready & -ready;
|
|
13730
|
-
if ((Atomics.and(header, SAB_I_SIGNALS, ~bit) & bit) !== 0) return 31 - Math.clz32(bit);
|
|
13731
|
-
}
|
|
13732
|
-
return 0;
|
|
13733
|
-
}
|
|
13734
|
-
interrupted() {
|
|
13735
|
-
const killed = this.process ?? this.header;
|
|
13736
|
-
if (Atomics.load(killed, SAB_I_KILLED) !== 0) {
|
|
13737
|
-
this.deliver();
|
|
13738
|
-
return true;
|
|
13739
|
-
}
|
|
13740
|
-
if (Atomics.load(killed, SAB_I_STOP) !== 1) return false;
|
|
13741
|
-
while (Atomics.load(killed, SAB_I_STOP) === 1) Atomics.wait(killed, SAB_I_STOP, 1);
|
|
13742
|
-
return true;
|
|
13743
|
-
}
|
|
13744
|
-
pending() {
|
|
13745
|
-
const own = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
13746
|
-
return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
|
|
13747
|
-
}
|
|
13748
|
-
};
|
|
13749
|
-
}
|
|
13750
|
-
});
|
|
13751
|
-
|
|
13752
13766
|
// src/process/wasi/wasi-signals.ts
|
|
13753
|
-
var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
|
|
13767
|
+
var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, SA_NOCLDWAIT, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
|
|
13754
13768
|
var init_wasi_signals = __esm({
|
|
13755
13769
|
"src/process/wasi/wasi-signals.ts"() {
|
|
13756
13770
|
"use strict";
|
|
@@ -13761,6 +13775,7 @@ var init_wasi_signals = __esm({
|
|
|
13761
13775
|
KERNEL_DEFAULTS = [SIG.TSTP, SIG.TTIN, SIG.TTOU, SIG.CHLD, SIG.CONT, SIG.URG, SIG.WINCH].map(sigbit).reduce((m, bit) => m | bit, 0);
|
|
13762
13776
|
LIBC_DEFAULT_EXIT = 127;
|
|
13763
13777
|
SA_RESTART = 268435456;
|
|
13778
|
+
SA_NOCLDWAIT = 2;
|
|
13764
13779
|
DISPOSITION_IGNORE = 1;
|
|
13765
13780
|
DISPOSITION_HANDLER = 2;
|
|
13766
13781
|
withBit = (mask, bit, on) => on ? mask | bit : mask & ~bit;
|
|
@@ -13777,6 +13792,7 @@ var init_wasi_signals = __esm({
|
|
|
13777
13792
|
ignoring = 0;
|
|
13778
13793
|
restarting = 0;
|
|
13779
13794
|
defaults = 0;
|
|
13795
|
+
nocldwait = false;
|
|
13780
13796
|
fallBack;
|
|
13781
13797
|
onKilled;
|
|
13782
13798
|
constructor(fallBack, onKilled) {
|
|
@@ -13802,6 +13818,7 @@ var init_wasi_signals = __esm({
|
|
|
13802
13818
|
this.ignoring = withBit(this.ignoring, bit, disposition === DISPOSITION_IGNORE);
|
|
13803
13819
|
this.restarting = withBit(this.restarting, bit, (flags & SA_RESTART) !== 0);
|
|
13804
13820
|
this.defaults = withBit(this.defaults, bit, disposition === 0);
|
|
13821
|
+
if (sig === SIG.CHLD) this.nocldwait = (flags & SA_NOCLDWAIT) !== 0;
|
|
13805
13822
|
return E.SUCCESS;
|
|
13806
13823
|
}
|
|
13807
13824
|
snapshot() {
|
|
@@ -13811,7 +13828,8 @@ var init_wasi_signals = __esm({
|
|
|
13811
13828
|
handlers: this.handlers,
|
|
13812
13829
|
ignoring: this.ignoring,
|
|
13813
13830
|
restarting: this.restarting,
|
|
13814
|
-
uncaught: this.uncaught
|
|
13831
|
+
uncaught: this.uncaught,
|
|
13832
|
+
...this.nocldwait ? { nocldwait: true } : {}
|
|
13815
13833
|
};
|
|
13816
13834
|
}
|
|
13817
13835
|
restore(state) {
|
|
@@ -13821,13 +13839,15 @@ var init_wasi_signals = __esm({
|
|
|
13821
13839
|
this.ignoring = state.ignoring;
|
|
13822
13840
|
this.restarting = state.restarting;
|
|
13823
13841
|
this.uncaught = state.uncaught;
|
|
13842
|
+
this.nocldwait = state.nocldwait === true;
|
|
13824
13843
|
}
|
|
13825
13844
|
masks() {
|
|
13826
13845
|
if (this.hooked) {
|
|
13827
13846
|
const caught = this.handler() ? this.handlers : 0;
|
|
13828
13847
|
const defaults = this.defaults;
|
|
13829
13848
|
this.defaults = 0;
|
|
13830
|
-
|
|
13849
|
+
const nocldwait = this.nocldwait ? { nocldwait: true } : {};
|
|
13850
|
+
return { caught, ignored: this.ignoring, restart: this.restarting, defaults, ...nocldwait };
|
|
13831
13851
|
}
|
|
13832
13852
|
if (!this.handler()) return null;
|
|
13833
13853
|
return { caught: DELIVERED_MASK & ~this.uncaught & ~KERNEL_DEFAULTS, ignored: 0, restart: 0 };
|