@ai-ecoverse/slicc-kernel 1.113.0 → 1.114.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.
@@ -1640,7 +1640,7 @@ function signalsIn(mask) {
1640
1640
  for (let sig = 1; sig <= 31; sig++) if (mask & sigbit(sig)) out.push(sig);
1641
1641
  return out;
1642
1642
  }
1643
- var SIG, IGNORED_BY_DEFAULT, STOPPING, SIGNAL_BY_NAME;
1643
+ var SIG, IGNORED_BY_DEFAULT, STOPPING, SIGNAL_BY_NAME, SI, KERNEL_SIGINFO;
1644
1644
  var init_signals = __esm({
1645
1645
  "src/kernel/signals.ts"() {
1646
1646
  "use strict";
@@ -1686,6 +1686,13 @@ var init_signals = __esm({
1686
1686
  SIGSTOP: SIG.STOP,
1687
1687
  SIGCONT: SIG.CONT
1688
1688
  };
1689
+ SI = { USER: 0, QUEUE: -1, TIMER: -2, TKILL: -6, KERNEL: 128 };
1690
+ KERNEL_SIGINFO = Object.freeze({
1691
+ code: SI.KERNEL,
1692
+ pid: 0,
1693
+ uid: 0,
1694
+ status: 0
1695
+ });
1689
1696
  }
1690
1697
  });
1691
1698
 
@@ -3674,7 +3681,7 @@ function wrap(table) {
3674
3681
  }
3675
3682
  return out;
3676
3683
  }
3677
- var WasiExit, IDS, NS_PER_MS4, AT_SYMLINK_NOFOLLOW, AT_EACCESS, ROOT_IDS, GONE, S_IFIFO, S_IFLNK, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, FD_ALIAS, STDIO_FDS, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
3684
+ var WasiExit, IDS, NS_PER_MS4, AT_SYMLINK_NOFOLLOW, AT_EACCESS, ROOT_IDS, GONE, S_IFIFO, S_IFLNK, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGINFO_BYTES, FD_ALIAS, STDIO_FDS, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
3678
3685
  var init_wasi_host = __esm({
3679
3686
  "src/process/wasi/wasi-host.ts"() {
3680
3687
  "use strict";
@@ -3713,6 +3720,7 @@ var init_wasi_host = __esm({
3713
3720
  DEFAULT_UMASK = 18;
3714
3721
  MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS4;
3715
3722
  MAX_READ = 1024 * 1024;
3723
+ SIGINFO_BYTES = 24;
3716
3724
  FD_ALIAS = /^\/(?:dev\/(stdin|stdout|stderr)|dev\/fd\/(\d+)|proc\/(self|[1-9]\d*)\/fd\/(\d+))$/;
3717
3725
  STDIO_FDS = { stdin: 0, stdout: 1, stderr: 2 };
3718
3726
  SIGPIPE_EXIT = 128 + SIG.PIPE;
@@ -4008,6 +4016,23 @@ var init_wasi_host = __esm({
4008
4016
  this.entered
4009
4017
  );
4010
4018
  },
4019
+ sigwait_info: (lo, _hi, timeout, info) => {
4020
+ const mask = this.sigmask;
4021
+ if (!mask) return E.NOSYS;
4022
+ let took = 0;
4023
+ const r = mask.sigwait(
4024
+ lo,
4025
+ timeout,
4026
+ (set) => void this.o.kernel.call({ op: "sig-waiting", tid: mask.tid, set }),
4027
+ (sig) => {
4028
+ took = sig;
4029
+ },
4030
+ this.entered
4031
+ );
4032
+ if (r === E.SUCCESS) this.writeSiginfo(info, took, mask.tid);
4033
+ return r;
4034
+ },
4035
+ siginfo_take: (sig, info) => this.writeSiginfo(info, sig, this.sigmask?.tid ?? this.tid, false) ? E.SUCCESS : E.NOENT,
4011
4036
  sigaction_inherited: (out) => {
4012
4037
  const bits = this.o.kernel.call({ op: "sig-inherited" });
4013
4038
  mem.view().setBigUint64(out, BigInt(libcBits(bits) >>> 0), true);
@@ -4602,6 +4627,22 @@ var init_wasi_host = __esm({
4602
4627
  return void 0;
4603
4628
  }
4604
4629
  }
4630
+ writeSiginfo(at, sig, tid, waited = true) {
4631
+ const taken = this.o.kernel.call({ op: "sig-info", sig, tid });
4632
+ if (!taken && !waited) return false;
4633
+ const info = taken ?? KERNEL_SIGINFO;
4634
+ const view = this.mem.view();
4635
+ const size = Math.min(view.getUint32(at, true), SIGINFO_BYTES);
4636
+ const fields = [sig, info.code, info.pid, info.uid, info.status];
4637
+ let filled = 4;
4638
+ for (const [i, value2] of fields.entries()) {
4639
+ if (4 + (i + 1) * 4 > size) break;
4640
+ view.setInt32(4 + at + i * 4, value2, true);
4641
+ filled = 4 + (i + 1) * 4;
4642
+ }
4643
+ view.setUint32(at, filled, true);
4644
+ return true;
4645
+ }
4605
4646
  fdAlias(path) {
4606
4647
  const m = FD_ALIAS.exec(path);
4607
4648
  if (!m) return void 0;
@@ -5295,7 +5336,7 @@ var KERNEL_VERSION, OS_RELEASE;
5295
5336
  var init_version = __esm({
5296
5337
  "src/version.ts"() {
5297
5338
  "use strict";
5298
- KERNEL_VERSION = true ? "1.113.0" : "0.0.0-dev";
5339
+ KERNEL_VERSION = true ? "1.114.0" : "0.0.0-dev";
5299
5340
  OS_RELEASE = "6.0.0-slicc";
5300
5341
  }
5301
5342
  });
@@ -16319,7 +16360,7 @@ var init_wasi_runtime = __esm({
16319
16360
  UNDELIVERED = {
16320
16361
  [PREVIEW1]: ["proc_exit", "clock_time_get"],
16321
16362
  [WASIX]: ["proc_exit2", "thread_exit", "thread_spawn_v2", "callback_signal"],
16322
- [SLICC]: ["sigaction_set"],
16363
+ [SLICC]: ["sigaction_set", "siginfo_take"],
16323
16364
  wasi: ["thread-spawn"]
16324
16365
  };
16325
16366
  DELIVERED = [PREVIEW1, WASIX, SLICC, SLICC_FS, SLICC_TTY];