@ai-ecoverse/slicc-kernel 1.54.1 → 1.54.2

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.
@@ -3289,6 +3289,7 @@ var init_process_signals = __esm({
3289
3289
  }
3290
3290
  }
3291
3291
  interrupt() {
3292
+ this.report();
3292
3293
  const header = this.header;
3293
3294
  const pending = Atomics.load(header, SAB_I_SIGNALS) | Atomics.load(header, SAB_I_TIMERS) | Atomics.load(header, SAB_I_KILLED);
3294
3295
  if (pending === 0) return false;
@@ -5550,7 +5551,7 @@ function readTermios(mem, ptr) {
5550
5551
  c_cc: Array.from({ length: NCCS }, (_, i) => v.getUint8(ptr + C_CC + i))
5551
5552
  };
5552
5553
  }
5553
- function sliccTty(mem, fds, kernel) {
5554
+ function sliccTty(mem, fds, kernel, interrupted = () => void 0) {
5554
5555
  const { sys } = kernel;
5555
5556
  const terminal = (fd) => {
5556
5557
  const e = fds.find(fd);
@@ -5562,13 +5563,19 @@ function sliccTty(mem, fds, kernel) {
5562
5563
  if (value2 === void 0) throw new WasiError("ENOTTY");
5563
5564
  return value2;
5564
5565
  };
5566
+ const getAttr = (fd, ptr) => {
5567
+ interrupted();
5568
+ writeTermios(mem, ptr, needs(sys.tcgets?.(terminal(fd))));
5569
+ };
5565
5570
  const setAttr = (fd, actions, ptr) => {
5571
+ interrupted();
5566
5572
  if (actions < 0 || actions > TCSAFLUSH) throw new WasiError("EINVAL");
5567
5573
  const at = terminal(fd);
5568
5574
  needs(sys.tcsets);
5569
5575
  sys.tcsets?.(at, readTermios(mem, ptr), actions === TCSAFLUSH);
5570
5576
  };
5571
5577
  const size = (fd, ptr) => {
5578
+ interrupted();
5572
5579
  const [rows, cols] = needs(sys.winsize?.(terminal(fd)));
5573
5580
  mem.bytes(ptr, 8).fill(0);
5574
5581
  const v = mem.view();
@@ -5576,7 +5583,7 @@ function sliccTty(mem, fds, kernel) {
5576
5583
  v.setUint16(ptr + 2, cols, true);
5577
5584
  };
5578
5585
  return {
5579
- tcgetattr: (fd, ptr) => void writeTermios(mem, ptr, needs(sys.tcgets?.(terminal(fd)))),
5586
+ tcgetattr: (fd, ptr) => void getAttr(fd, ptr),
5580
5587
  tcsetattr: (fd, actions, ptr) => void setAttr(fd, actions, ptr),
5581
5588
  winsize: (fd, ptr) => void size(fd, ptr)
5582
5589
  };
@@ -5725,7 +5732,7 @@ var init_wasi_host = __esm({
5725
5732
  if (umask !== DEFAULT_UMASK) this.o.fs.chmod(path, mode & ~umask);
5726
5733
  }
5727
5734
  sliccTtyImports() {
5728
- return wrap(sliccTty(this.mem, this.fds, this.o.kernel));
5735
+ return wrap(sliccTty(this.mem, this.fds, this.o.kernel, () => this.interrupted?.()));
5729
5736
  }
5730
5737
  sliccFsImports() {
5731
5738
  const { mem, fds } = this;
@@ -5946,6 +5953,7 @@ var init_wasi_host = __esm({
5946
5953
  return {
5947
5954
  path_open: (dirfd, _lookup, p, l, oflags, rights, _inheriting, fdflags, out) => {
5948
5955
  const path = at(dirfd, p, l);
5956
+ if (deviceOf(path)) this.interrupted?.();
5949
5957
  const fresh = (oflags & OFLAGS.CREAT) !== 0 && !o.fs.exists(path);
5950
5958
  mem.view().setUint32(out, fds.open(path, oflags, rights, fdflags), true);
5951
5959
  if (fresh) this.created(path, 438);
@@ -6061,7 +6069,9 @@ var init_wasi_host = __esm({
6061
6069
  }
6062
6070
  positional(fd, access) {
6063
6071
  const e = this.fds.get(fd);
6064
- if (e.type !== "kernel" || this.fds.kind(fd, e) !== "file") return this.file(fd, access);
6072
+ const kind = e.type === "kernel" ? this.fds.kind(fd, e) : e.type;
6073
+ if (kind === "device") this.interrupted?.();
6074
+ if (kind !== "file" || e.type !== "kernel") return this.file(fd, access);
6065
6075
  const kernel = this.o.kernel;
6066
6076
  return {
6067
6077
  pread: (max, at) => {
@@ -6089,6 +6099,7 @@ var init_wasi_host = __esm({
6089
6099
  }
6090
6100
  }
6091
6101
  if (e.type === "device") {
6102
+ this.interrupted?.();
6092
6103
  if (e.access === "read") throw new WasiError("EBADF");
6093
6104
  if (e.device === "full" && data.length > 0) throw new WasiError("ENOSPC");
6094
6105
  return data.length;
@@ -6101,6 +6112,7 @@ var init_wasi_host = __esm({
6101
6112
  return this.o.kernel.sys.read(fd, Math.min(max, MAX_READ), { nonblock: e.nonblock });
6102
6113
  }
6103
6114
  if (e.type === "device") {
6115
+ this.interrupted?.();
6104
6116
  if (e.access === "write") throw new WasiError("EBADF");
6105
6117
  if (e.device === "null") return new Uint8Array(0);
6106
6118
  const out = new Uint8Array(Math.min(max, 65536));
@@ -6108,15 +6120,19 @@ var init_wasi_host = __esm({
6108
6120
  }
6109
6121
  return this.file(fd, "read").read(max);
6110
6122
  }
6123
+ local(answer2) {
6124
+ this.interrupted?.();
6125
+ return answer2;
6126
+ }
6111
6127
  seek(fd, offset, whence) {
6112
6128
  const e = this.fds.get(fd);
6113
6129
  if (e.type === "kernel") {
6114
6130
  const kind = this.fds.kind(fd, e);
6115
- if (kind === "device") return 0;
6131
+ if (kind === "device") return this.local(0);
6116
6132
  if (kind !== "file") throw new WasiError("ESPIPE");
6117
6133
  return this.o.kernel.sys.seek(fd, offset, whence);
6118
6134
  }
6119
- if (e.type === "device") return 0;
6135
+ if (e.type === "device") return this.local(0);
6120
6136
  const file = this.file(fd);
6121
6137
  const base = whence === WHENCE.SET ? 0 : whence === WHENCE.CUR ? file.offset : file.size();
6122
6138
  if (whence > WHENCE.END || base + offset < 0) throw new WasiError("EINVAL");
@@ -6126,15 +6142,23 @@ var init_wasi_host = __esm({
6126
6142
  sync(fd) {
6127
6143
  const e = this.fds.get(fd);
6128
6144
  if (e.type === "file") e.file.flush();
6129
- else if (e.type === "kernel" && this.fds.kind(fd, e) === "file") this.o.kernel.sys.flush(fd);
6145
+ else if (e.type === "device") this.interrupted?.();
6146
+ else if (e.type === "kernel") {
6147
+ const kind = this.fds.kind(fd, e);
6148
+ if (kind === "file") this.o.kernel.sys.flush(fd);
6149
+ else if (kind === "device") this.interrupted?.();
6150
+ }
6130
6151
  }
6131
6152
  fdstat(fd, out) {
6132
6153
  const e = this.fds.get(fd);
6154
+ if (e.type === "device") this.interrupted?.();
6133
6155
  let filetype = FILETYPE.CHARACTER_DEVICE;
6134
6156
  let seeks = true;
6135
6157
  let flags = 0;
6136
6158
  if (e.type === "kernel") {
6137
- ({ filetype, seeks } = kernelFiletype(this.fds.kind(fd, e)));
6159
+ const kind = this.fds.kind(fd, e);
6160
+ if (kind === "device") this.interrupted?.();
6161
+ ({ filetype, seeks } = kernelFiletype(kind));
6138
6162
  if (e.nonblock) flags |= FDFLAGS.NONBLOCK;
6139
6163
  if (e.append) flags |= FDFLAGS.APPEND;
6140
6164
  } else if (e.type === "file") {
@@ -6169,7 +6193,7 @@ var init_wasi_host = __esm({
6169
6193
  if (vfs.path) return this.statOrphanable(vfs.path, vfs.size, vfs.orphan);
6170
6194
  }
6171
6195
  const filetype = kind ? kernelFiletype(kind).filetype : FILETYPE.CHARACTER_DEVICE;
6172
- return { filetype, size: 0n, ino: BigInt(fd + 1), mtimeNs: 0n };
6196
+ return this.local({ filetype, size: 0n, ino: BigInt(fd + 1), mtimeNs: 0n });
6173
6197
  }
6174
6198
  statOrphanable(path, size, orphan = false) {
6175
6199
  let s;
@@ -6186,7 +6210,12 @@ var init_wasi_host = __esm({
6186
6210
  }
6187
6211
  pathFilestat(path, lookup) {
6188
6212
  if (deviceOf(path)) {
6189
- return { filetype: FILETYPE.CHARACTER_DEVICE, size: 0n, ino: pathInode(path), mtimeNs: 0n };
6213
+ return this.local({
6214
+ filetype: FILETYPE.CHARACTER_DEVICE,
6215
+ size: 0n,
6216
+ ino: pathInode(path),
6217
+ mtimeNs: 0n
6218
+ });
6190
6219
  }
6191
6220
  this.fds.flushPath(path);
6192
6221
  const follow2 = (lookup & LOOKUP_SYMLINK_FOLLOW) !== 0;
@@ -8762,6 +8791,7 @@ var init_wasix_host = __esm({
8762
8791
  }
8763
8792
  ttyGet(ptr) {
8764
8793
  const { host, mem } = this;
8794
+ host.interrupted?.();
8765
8795
  const v = mem.view();
8766
8796
  mem.bytes(ptr, 24).fill(0);
8767
8797
  const fd = this.ttyFd();
@@ -8781,6 +8811,7 @@ var init_wasix_host = __esm({
8781
8811
  v.setUint8(ptr + 20, termios && termios.c_lflag & ICANON ? 1 : 0);
8782
8812
  }
8783
8813
  ttySet(ptr) {
8814
+ this.host.interrupted?.();
8784
8815
  const fd = this.ttyFd();
8785
8816
  if (fd === void 0) throw new WasiError("ENOTTY");
8786
8817
  const { sys } = this.host.o.kernel;