@ai-ecoverse/slicc-kernel 1.121.1 → 1.122.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.
@@ -5431,7 +5431,7 @@ var KERNEL_VERSION, OS_RELEASE;
5431
5431
  var init_version = __esm({
5432
5432
  "src/version.ts"() {
5433
5433
  "use strict";
5434
- KERNEL_VERSION = true ? "1.121.1" : "0.0.0-dev";
5434
+ KERNEL_VERSION = true ? "1.122.0" : "0.0.0-dev";
5435
5435
  OS_RELEASE = "6.0.0-slicc";
5436
5436
  }
5437
5437
  });
@@ -8678,7 +8678,24 @@ function closeDropsLocks(Fs, kernel) {
8678
8678
  }
8679
8679
  };
8680
8680
  }
8681
- var F_GETLK2, F_SETLK2, F_SETLKW2, F_RDLCK2, F_WRLCK2, F_UNLCK2, SEEK_CUR3, SEEK_END3, O_ACCMODE2, O_RDONLY, O_WRONLY4, lockPromoters, held;
8681
+ function kernelFlock(deps) {
8682
+ return (fd, op) => {
8683
+ const kind = FLOCK_KINDS[op & ~LOCK_NB2];
8684
+ if (!kind) return -wasiErrno("EINVAL");
8685
+ const Fs = deps.fs();
8686
+ const stream = Fs?.getStream(fd);
8687
+ if (!Fs || !stream) return -wasiErrno("EBADF");
8688
+ if (stream.sliccKernelFd === void 0) lockPromoters.get(Fs)?.()(stream);
8689
+ if (stream.sliccKernelFd === void 0) return 0;
8690
+ try {
8691
+ deps.flock(stream.sliccKernelFd, kind, kind !== "unlock" && (op & LOCK_NB2) === 0);
8692
+ return 0;
8693
+ } catch (err) {
8694
+ return -errnoOf(err);
8695
+ }
8696
+ };
8697
+ }
8698
+ var F_GETLK2, F_SETLK2, F_SETLKW2, F_RDLCK2, F_WRLCK2, F_UNLCK2, SEEK_CUR3, SEEK_END3, O_ACCMODE2, O_RDONLY, O_WRONLY4, lockPromoters, held, LOCK_NB2, FLOCK_KINDS;
8682
8699
  var init_process_locks = __esm({
8683
8700
  "src/process/process-locks.ts"() {
8684
8701
  "use strict";
@@ -8697,6 +8714,12 @@ var init_process_locks = __esm({
8697
8714
  O_WRONLY4 = 1;
8698
8715
  lockPromoters = /* @__PURE__ */ new WeakMap();
8699
8716
  held = /* @__PURE__ */ new WeakMap();
8717
+ LOCK_NB2 = 4;
8718
+ FLOCK_KINDS = {
8719
+ 1: "shared",
8720
+ 2: "exclusive",
8721
+ 8: "unlock"
8722
+ };
8700
8723
  }
8701
8724
  });
8702
8725
 
@@ -9593,7 +9616,8 @@ var init_process_fds = __esm({
9593
9616
  resizeHeap: "emscripten_resize_heap",
9594
9617
  fdWrite: "fd_write",
9595
9618
  fdRead: "fd_read",
9596
- sleepMs: "slicc_sleep_ms"
9619
+ sleepMs: "slicc_sleep_ms",
9620
+ flock: "__syscall_flock"
9597
9621
  };
9598
9622
  UTIME_NOW = 1073741823;
9599
9623
  UTIME_OMIT = 1073741822;
@@ -13648,6 +13672,9 @@ function kernelSys(transport) {
13648
13672
  closeLocks(target) {
13649
13673
  call2({ op: "lk-close", ...target }, "lk-close");
13650
13674
  },
13675
+ flock(fd, kind, wait2) {
13676
+ call2({ op: "flock", fd, kind, ...wait2 ? { wait: wait2 } : {} }, `flock ${fd}`);
13677
+ },
13651
13678
  ptyNumber(fd) {
13652
13679
  return json2(call2({ op: "pty-number", fd }, `pty-number ${fd}`));
13653
13680
  },
@@ -13781,6 +13808,13 @@ function kernelWrappers(imports, module, deps) {
13781
13808
  kernelLink(imports, fsOf, memory, kernelGlue);
13782
13809
  devCreations(imports, fsOf, memory, kernelGlue);
13783
13810
  kernelUname(imports, hostnameOf(init.env), memory, kernelGlue);
13811
+ wrapImport(
13812
+ imports,
13813
+ "flock",
13814
+ kernelGlue,
13815
+ () => kernelFlock({ fs: fsOf, flock: (fd, kind, wait2) => sys.flock?.(fd, kind, wait2) }),
13816
+ true
13817
+ );
13784
13818
  const glue = ownValue(module, "sliccFdImports");
13785
13819
  syncFsync(imports, fsOf, glue);
13786
13820
  positionalIo(imports, { glue, fs: fsOf, sys, memory });
@@ -14114,6 +14148,7 @@ var init_process_runtime = __esm({
14114
14148
  " fdWrite: typeof _fd_write === 'function' ? _fd_write : undefined,",
14115
14149
  " fdRead: typeof _fd_read === 'function' ? _fd_read : undefined,",
14116
14150
  " sleepMs: typeof slicc_sleep_ms === 'function' ? slicc_sleep_ms : undefined,",
14151
+ " flock: typeof __syscall_flock === 'function' ? __syscall_flock : undefined,",
14117
14152
  "};",
14118
14153
  "Module.sliccFdImports ??= {",
14119
14154
  " fd_sync: typeof _fd_sync === 'function' ? _fd_sync : undefined,",