@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.
@@ -2655,7 +2655,7 @@ var KERNEL_VERSION, OS_RELEASE;
2655
2655
  var init_version = __esm({
2656
2656
  "src/version.ts"() {
2657
2657
  "use strict";
2658
- KERNEL_VERSION = true ? "1.125.5" : "0.0.0-dev";
2658
+ KERNEL_VERSION = true ? "1.125.6" : "0.0.0-dev";
2659
2659
  OS_RELEASE = "6.0.0-slicc";
2660
2660
  }
2661
2661
  });
@@ -6860,7 +6860,7 @@ function pinnedIo2(bridge, handle, rewriting) {
6860
6860
  } : {}
6861
6861
  };
6862
6862
  }
6863
- var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING2, RING_SIZE2, SLOT2, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt, remember;
6863
+ var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, UMASK2, RING2, RING_SIZE2, SLOT2, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt, remember;
6864
6864
  var init_wasi_files = __esm({
6865
6865
  "src/process/wasi/wasi-files.ts"() {
6866
6866
  "use strict";
@@ -7090,6 +7090,7 @@ var init_wasi_files = __esm({
7090
7090
  CACHE_CAP = 8192;
7091
7091
  FS_GEN = 4;
7092
7092
  CRED_GEN = 5;
7093
+ UMASK2 = 6;
7093
7094
  RING2 = 8;
7094
7095
  RING_SIZE2 = 64;
7095
7096
  SLOT2 = 3;
@@ -8176,7 +8177,7 @@ var init_slicc_sem = __esm({
8176
8177
  });
8177
8178
 
8178
8179
  // src/process/wasi/wasi-cred.ts
8179
- var CredCache;
8180
+ var CredCache, KNOWN, LOCKED, UNGATED, UmaskCache;
8180
8181
  var init_wasi_cred = __esm({
8181
8182
  "src/process/wasi/wasi-cred.ts"() {
8182
8183
  "use strict";
@@ -8214,6 +8215,69 @@ var init_wasi_cred = __esm({
8214
8215
  return cred;
8215
8216
  }
8216
8217
  };
8218
+ KNOWN = 65536;
8219
+ LOCKED = 131072;
8220
+ UNGATED = { quiet: (fn) => fn(), deliver: () => {
8221
+ } };
8222
+ UmaskCache = class {
8223
+ mask;
8224
+ call;
8225
+ shared;
8226
+ signals;
8227
+ constructor(call2, shared, signals = UNGATED) {
8228
+ this.call = call2;
8229
+ this.shared = shared;
8230
+ this.signals = signals;
8231
+ }
8232
+ get() {
8233
+ const { shared } = this;
8234
+ if (!shared) {
8235
+ this.mask ??= this.call();
8236
+ return this.mask;
8237
+ }
8238
+ for (; ; ) {
8239
+ const seen = Atomics.load(shared, UMASK2);
8240
+ if (seen & LOCKED) Atomics.wait(shared, UMASK2, seen);
8241
+ else if (seen & KNOWN) return seen & 511;
8242
+ else {
8243
+ const mask = this.call();
8244
+ if (Atomics.compareExchange(shared, UMASK2, 0, mask | KNOWN) === 0) return mask;
8245
+ }
8246
+ }
8247
+ }
8248
+ set(mask) {
8249
+ try {
8250
+ return this.signals.quiet(() => this.change(mask));
8251
+ } finally {
8252
+ this.signals.deliver();
8253
+ }
8254
+ }
8255
+ change(mask) {
8256
+ const { shared } = this;
8257
+ if (!shared) {
8258
+ const old = this.call(mask);
8259
+ this.mask = mask & 511;
8260
+ return old;
8261
+ }
8262
+ const seen = this.lock(shared);
8263
+ let next2 = seen;
8264
+ try {
8265
+ const old = this.call(mask);
8266
+ next2 = mask & 511 | KNOWN;
8267
+ return old;
8268
+ } finally {
8269
+ Atomics.store(shared, UMASK2, next2);
8270
+ Atomics.notify(shared, UMASK2);
8271
+ }
8272
+ }
8273
+ lock(shared) {
8274
+ for (; ; ) {
8275
+ const seen = Atomics.load(shared, UMASK2);
8276
+ if (seen & LOCKED) Atomics.wait(shared, UMASK2, seen);
8277
+ else if (Atomics.compareExchange(shared, UMASK2, seen, seen | LOCKED) === seen) return seen;
8278
+ }
8279
+ }
8280
+ };
8217
8281
  }
8218
8282
  });
8219
8283
 
@@ -10129,6 +10193,7 @@ var init_wasi_host = __esm({
10129
10193
  mem = new WasiMemory();
10130
10194
  fds;
10131
10195
  creds;
10196
+ umasks;
10132
10197
  started = performance.now();
10133
10198
  cache;
10134
10199
  startCwd;
@@ -10146,7 +10211,8 @@ var init_wasi_host = __esm({
10146
10211
  threadEntry;
10147
10212
  linkedModules;
10148
10213
  interrupted;
10149
- quietly = (fn) => fn();
10214
+ quietly = UNGATED.quiet;
10215
+ deliverDue = UNGATED.deliver;
10150
10216
  listening;
10151
10217
  o;
10152
10218
  constructor(o) {
@@ -10172,6 +10238,13 @@ var init_wasi_host = __esm({
10172
10238
  () => this.o.kernel.call({ op: "proc-cred" }),
10173
10239
  o.credGen ?? o.shared
10174
10240
  );
10241
+ this.umasks = new UmaskCache(
10242
+ (mask) => this.o.kernel.call(
10243
+ mask === void 0 ? { op: "proc-umask" } : { op: "proc-umask", mask }
10244
+ ),
10245
+ o.credGen ?? o.shared,
10246
+ { quiet: (fn) => this.quietly(fn), deliver: () => this.deliverDue() }
10247
+ );
10175
10248
  if (o.shared) this.fds.share(o.shared, true);
10176
10249
  else if (o.forked) this.fds.restore(o.forked.fds, o.forked.cloexec);
10177
10250
  else this.fds.setup(o.cwd, o.inherited ?? [], o.preopenRoot === true);
@@ -10180,8 +10253,11 @@ var init_wasi_host = __esm({
10180
10253
  get cwd() {
10181
10254
  return this.fds.cwd() ?? this.startCwd;
10182
10255
  }
10256
+ umask(mask) {
10257
+ return mask === void 0 ? this.umasks.get() : this.umasks.set(mask);
10258
+ }
10183
10259
  created(path, mode) {
10184
- const umask = this.o.kernel.call({ op: "proc-umask" });
10260
+ const umask = this.umasks.get();
10185
10261
  if (umask !== DEFAULT_UMASK) this.o.fs.chmod(path, mode & ~umask);
10186
10262
  }
10187
10263
  sliccTtyImports() {
@@ -10311,7 +10387,7 @@ var init_wasi_host = __esm({
10311
10387
  const raw = mem.string(p, l);
10312
10388
  if (raw === "") throw new WasiError("ENOENT");
10313
10389
  const path = dirfd === AT_FDCWD2 && !raw.startsWith("/") ? fds.resolve(3, `${this.cwd}/${raw}`) : at(dirfd, p, l);
10314
- const umask = this.o.kernel.call({ op: "proc-umask" });
10390
+ const umask = this.umasks.get();
10315
10391
  const want = mode & 4095 & ~umask;
10316
10392
  mkfifo.call(this.o.fs, path, want);
10317
10393
  const made = (this.o.fs.lstat(path).mode ?? 0) & 4095;
@@ -10319,7 +10395,7 @@ var init_wasi_host = __esm({
10319
10395
  return E.SUCCESS;
10320
10396
  },
10321
10397
  umask: (mask, out) => {
10322
- const old = this.o.kernel.call({ op: "proc-umask", mask });
10398
+ const old = this.umasks.set(mask);
10323
10399
  mem.view().setUint32(out, old, true);
10324
10400
  },
10325
10401
  fd_mode: (fd, out) => void mem.view().setUint32(out, fdMode(fd), true),
@@ -11683,7 +11759,7 @@ function importsContext({
11683
11759
  cwd: () => host.cwd,
11684
11760
  fs,
11685
11761
  fds,
11686
- syscall: call2,
11762
+ syscall: (req) => req.op === "proc-umask" ? host.umask(req.mask) : call2(req),
11687
11763
  net: network(raw, call2),
11688
11764
  ...processes(host, call2, tid !== MAIN_TID),
11689
11765
  async: {
@@ -14098,6 +14174,7 @@ function wireSignals(host, gate) {
14098
14174
  host.interrupted = () => gate.interrupt();
14099
14175
  host.raisedOnEntry = () => gate.raisedOnEntry();
14100
14176
  host.quietly = (fn) => gate.quiet(fn);
14177
+ host.deliverDue = () => void gate.interrupt();
14101
14178
  host.fds.restartable = () => gate.restartable();
14102
14179
  }
14103
14180
  function catchUpFirst(host, sync) {