@ai-ecoverse/slicc-kernel 1.125.5 → 1.125.6

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.
@@ -932,7 +932,7 @@ function pinnedIo(bridge, handle, rewriting) {
932
932
  } : {}
933
933
  };
934
934
  }
935
- var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING, RING_SIZE, SLOT, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt, remember;
935
+ var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, UMASK, RING, RING_SIZE, SLOT, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt, remember;
936
936
  var init_wasi_files = __esm({
937
937
  "src/process/wasi/wasi-files.ts"() {
938
938
  "use strict";
@@ -1162,6 +1162,7 @@ var init_wasi_files = __esm({
1162
1162
  CACHE_CAP = 8192;
1163
1163
  FS_GEN = 4;
1164
1164
  CRED_GEN = 5;
1165
+ UMASK = 6;
1165
1166
  RING = 8;
1166
1167
  RING_SIZE = 64;
1167
1168
  SLOT = 3;
@@ -2703,7 +2704,7 @@ var init_slicc_sem = __esm({
2703
2704
  });
2704
2705
 
2705
2706
  // src/process/wasi/wasi-cred.ts
2706
- var CredCache;
2707
+ var CredCache, KNOWN, LOCKED, UNGATED, UmaskCache;
2707
2708
  var init_wasi_cred = __esm({
2708
2709
  "src/process/wasi/wasi-cred.ts"() {
2709
2710
  "use strict";
@@ -2741,6 +2742,69 @@ var init_wasi_cred = __esm({
2741
2742
  return cred;
2742
2743
  }
2743
2744
  };
2745
+ KNOWN = 65536;
2746
+ LOCKED = 131072;
2747
+ UNGATED = { quiet: (fn) => fn(), deliver: () => {
2748
+ } };
2749
+ UmaskCache = class {
2750
+ mask;
2751
+ call;
2752
+ shared;
2753
+ signals;
2754
+ constructor(call2, shared, signals = UNGATED) {
2755
+ this.call = call2;
2756
+ this.shared = shared;
2757
+ this.signals = signals;
2758
+ }
2759
+ get() {
2760
+ const { shared } = this;
2761
+ if (!shared) {
2762
+ this.mask ??= this.call();
2763
+ return this.mask;
2764
+ }
2765
+ for (; ; ) {
2766
+ const seen = Atomics.load(shared, UMASK);
2767
+ if (seen & LOCKED) Atomics.wait(shared, UMASK, seen);
2768
+ else if (seen & KNOWN) return seen & 511;
2769
+ else {
2770
+ const mask = this.call();
2771
+ if (Atomics.compareExchange(shared, UMASK, 0, mask | KNOWN) === 0) return mask;
2772
+ }
2773
+ }
2774
+ }
2775
+ set(mask) {
2776
+ try {
2777
+ return this.signals.quiet(() => this.change(mask));
2778
+ } finally {
2779
+ this.signals.deliver();
2780
+ }
2781
+ }
2782
+ change(mask) {
2783
+ const { shared } = this;
2784
+ if (!shared) {
2785
+ const old = this.call(mask);
2786
+ this.mask = mask & 511;
2787
+ return old;
2788
+ }
2789
+ const seen = this.lock(shared);
2790
+ let next2 = seen;
2791
+ try {
2792
+ const old = this.call(mask);
2793
+ next2 = mask & 511 | KNOWN;
2794
+ return old;
2795
+ } finally {
2796
+ Atomics.store(shared, UMASK, next2);
2797
+ Atomics.notify(shared, UMASK);
2798
+ }
2799
+ }
2800
+ lock(shared) {
2801
+ for (; ; ) {
2802
+ const seen = Atomics.load(shared, UMASK);
2803
+ if (seen & LOCKED) Atomics.wait(shared, UMASK, seen);
2804
+ else if (Atomics.compareExchange(shared, UMASK, seen, seen | LOCKED) === seen) return seen;
2805
+ }
2806
+ }
2807
+ };
2744
2808
  }
2745
2809
  });
2746
2810
 
@@ -4702,6 +4766,7 @@ var init_wasi_host = __esm({
4702
4766
  mem = new WasiMemory();
4703
4767
  fds;
4704
4768
  creds;
4769
+ umasks;
4705
4770
  started = performance.now();
4706
4771
  cache;
4707
4772
  startCwd;
@@ -4719,7 +4784,8 @@ var init_wasi_host = __esm({
4719
4784
  threadEntry;
4720
4785
  linkedModules;
4721
4786
  interrupted;
4722
- quietly = (fn) => fn();
4787
+ quietly = UNGATED.quiet;
4788
+ deliverDue = UNGATED.deliver;
4723
4789
  listening;
4724
4790
  o;
4725
4791
  constructor(o) {
@@ -4745,6 +4811,13 @@ var init_wasi_host = __esm({
4745
4811
  () => this.o.kernel.call({ op: "proc-cred" }),
4746
4812
  o.credGen ?? o.shared
4747
4813
  );
4814
+ this.umasks = new UmaskCache(
4815
+ (mask) => this.o.kernel.call(
4816
+ mask === void 0 ? { op: "proc-umask" } : { op: "proc-umask", mask }
4817
+ ),
4818
+ o.credGen ?? o.shared,
4819
+ { quiet: (fn) => this.quietly(fn), deliver: () => this.deliverDue() }
4820
+ );
4748
4821
  if (o.shared) this.fds.share(o.shared, true);
4749
4822
  else if (o.forked) this.fds.restore(o.forked.fds, o.forked.cloexec);
4750
4823
  else this.fds.setup(o.cwd, o.inherited ?? [], o.preopenRoot === true);
@@ -4753,8 +4826,11 @@ var init_wasi_host = __esm({
4753
4826
  get cwd() {
4754
4827
  return this.fds.cwd() ?? this.startCwd;
4755
4828
  }
4829
+ umask(mask) {
4830
+ return mask === void 0 ? this.umasks.get() : this.umasks.set(mask);
4831
+ }
4756
4832
  created(path, mode) {
4757
- const umask = this.o.kernel.call({ op: "proc-umask" });
4833
+ const umask = this.umasks.get();
4758
4834
  if (umask !== DEFAULT_UMASK) this.o.fs.chmod(path, mode & ~umask);
4759
4835
  }
4760
4836
  sliccTtyImports() {
@@ -4884,7 +4960,7 @@ var init_wasi_host = __esm({
4884
4960
  const raw = mem.string(p, l);
4885
4961
  if (raw === "") throw new WasiError("ENOENT");
4886
4962
  const path = dirfd === AT_FDCWD && !raw.startsWith("/") ? fds.resolve(3, `${this.cwd}/${raw}`) : at(dirfd, p, l);
4887
- const umask = this.o.kernel.call({ op: "proc-umask" });
4963
+ const umask = this.umasks.get();
4888
4964
  const want = mode & 4095 & ~umask;
4889
4965
  mkfifo.call(this.o.fs, path, want);
4890
4966
  const made = (this.o.fs.lstat(path).mode ?? 0) & 4095;
@@ -4892,7 +4968,7 @@ var init_wasi_host = __esm({
4892
4968
  return E.SUCCESS;
4893
4969
  },
4894
4970
  umask: (mask, out) => {
4895
- const old = this.o.kernel.call({ op: "proc-umask", mask });
4971
+ const old = this.umasks.set(mask);
4896
4972
  mem.view().setUint32(out, old, true);
4897
4973
  },
4898
4974
  fd_mode: (fd, out) => void mem.view().setUint32(out, fdMode(fd), true),
@@ -6181,7 +6257,7 @@ function importsContext({
6181
6257
  cwd: () => host.cwd,
6182
6258
  fs,
6183
6259
  fds,
6184
- syscall: call2,
6260
+ syscall: (req) => req.op === "proc-umask" ? host.umask(req.mask) : call2(req),
6185
6261
  net: network(raw, call2),
6186
6262
  ...processes(host, call2, tid !== MAIN_TID),
6187
6263
  async: {
@@ -6325,7 +6401,7 @@ var KERNEL_VERSION, OS_RELEASE;
6325
6401
  var init_version = __esm({
6326
6402
  "src/version.ts"() {
6327
6403
  "use strict";
6328
- KERNEL_VERSION = true ? "1.125.5" : "0.0.0-dev";
6404
+ KERNEL_VERSION = true ? "1.125.6" : "0.0.0-dev";
6329
6405
  OS_RELEASE = "6.0.0-slicc";
6330
6406
  }
6331
6407
  });
@@ -8227,7 +8303,7 @@ function createNodeOps(h) {
8227
8303
  call2(() => bridge.mkdir(path, perm));
8228
8304
  } else if (Fs.isDir(mode)) {
8229
8305
  call2(() => bridge.mkdir(path));
8230
- const masked = mode & PERM_MASK & ~UMASK;
8306
+ const masked = mode & PERM_MASK & ~UMASK2;
8231
8307
  if (masked !== DEFAULT_DIR_PERM) metadataCall(() => bridge.chmod(path, masked));
8232
8308
  } else if (Fs.isFile(mode)) {
8233
8309
  call2(
@@ -8917,7 +8993,7 @@ function readingLinks(Fs) {
8917
8993
  }
8918
8994
  };
8919
8995
  }
8920
- var S_IFDIR, S_IFREG, S_IFLNK2, S_IFSOCK, S_IFIFO2, S_IFMT2, PERM_MASK, DEFAULT_DIR_PERM, UMASK, SEEK_CUR2, SEEK_END2, EARLY_WHOLE_FILE, O_APPEND4, O_ACCMODE, O_TRUNC, O_PATH, stale, opening, O_NOFOLLOW, RESOLVING;
8996
+ var S_IFDIR, S_IFREG, S_IFLNK2, S_IFSOCK, S_IFIFO2, S_IFMT2, PERM_MASK, DEFAULT_DIR_PERM, UMASK2, SEEK_CUR2, SEEK_END2, EARLY_WHOLE_FILE, O_APPEND4, O_ACCMODE, O_TRUNC, O_PATH, stale, opening, O_NOFOLLOW, RESOLVING;
8921
8997
  var init_live_vfs_fs = __esm({
8922
8998
  "src/realm/live-vfs-fs.ts"() {
8923
8999
  "use strict";
@@ -8935,7 +9011,7 @@ var init_live_vfs_fs = __esm({
8935
9011
  S_IFMT2 = 61440;
8936
9012
  PERM_MASK = 4095;
8937
9013
  DEFAULT_DIR_PERM = 493;
8938
- UMASK = 18;
9014
+ UMASK2 = 18;
8939
9015
  SEEK_CUR2 = 1;
8940
9016
  SEEK_END2 = 2;
8941
9017
  EARLY_WHOLE_FILE = 64 * 1024;
@@ -16716,6 +16792,7 @@ function wireSignals(host, gate) {
16716
16792
  host.interrupted = () => gate.interrupt();
16717
16793
  host.raisedOnEntry = () => gate.raisedOnEntry();
16718
16794
  host.quietly = (fn) => gate.quiet(fn);
16795
+ host.deliverDue = () => void gate.interrupt();
16719
16796
  host.fds.restartable = () => gate.restartable();
16720
16797
  }
16721
16798
  function catchUpFirst(host, sync) {