authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-12-27 10:23:46+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-12-27 10:23:46+00:00
log60a1ba0a8f3517356fa2941462f002a7f580545b
tree3a5eb3193d3d192c54ab0c2b7295a7f21861c27e
parentd8460910b47d175fc77ef6fe5e9f8e58e291e2fd
signaturelock-open Commit is signed but in an unrecognized format.

stage1: add more wasi.c stubs

Because `std.Io` forces analysis of unused functions in the vtable, there are now references to 4 more WASI functions, even though the compiler does not actually call them at runtime. Therefore, these new stubs fix the bootstrap process after a zig1.wasm update (though this branch does *not* update zig1.wasm).

1 files changed, 61 insertions(+), 0 deletions(-)

stage1/wasi.c+61
......@@ -939,6 +939,58 @@ uint32_t wasi_snapshot_preview1_path_remove_directory(uint32_t fd, uint32_t path
939939 return wasi_errno_success;
940940}
941941
942uint32_t wasi_snapshot_preview1_path_symlink(uint32_t old_path, uint32_t old_path_len, uint32_t fd, uint32_t new_path, uint32_t new_path_len) {
943 uint8_t *const m = *wasm_memory;
944 const char *old_path_ptr = (const char *)&m[old_path];
945 const char *new_path_ptr = (const char *)&m[new_path];
946#if LOG_TRACE
947 fprintf(stderr, "wasi_snapshot_preview1_path_symlink(\"%.*s\", %u, \"%.*s\")\n", (int)old_path_len, old_path_ptr, fd, (int)new_path_len, new_path_ptr);
948#endif
949 (void)old_path_ptr;
950 (void)old_path_len;
951 (void)fd;
952 (void)new_path_ptr;
953 (void)new_path_len;
954 panic("unimplemented: path_symlink");
955 return wasi_errno_success;
956}
957
958uint32_t wasi_snapshot_preview1_path_readlink(uint32_t fd, uint32_t path, uint32_t path_len, uint32_t buf, uint32_t buf_len, uint32_t out_len) {
959 uint8_t *const m = *wasm_memory;
960 const char *path_ptr = (const char *)&m[path];
961 char *buf_ptr = (char *)&m[buf];
962 uint32_t *out_len_ptr = (uint32_t *)&m[out_len];
963#if LOG_TRACE
964 fprintf(stderr, "wasi_snapshot_preview1_path_readlink(%u, \"%.*s\", 0x%X, %u, 0x%X)\n", fd, (int)path_len, path_ptr, buf, buf_len, out_len);
965#endif
966 (void)fd;
967 (void)path_ptr;
968 (void)path_len;
969 (void)buf_ptr;
970 (void)buf_len;
971 (void)out_len_ptr;
972 panic("unimplemented: path_readlink");
973 return wasi_errno_success;
974}
975
976uint32_t wasi_snapshot_preview1_path_link(uint32_t old_fd, uint32_t old_flags, uint32_t old_path, uint32_t old_path_len, uint32_t new_fd, uint32_t new_path, uint32_t new_path_len) {
977 uint8_t *const m = *wasm_memory;
978 const char *old_path_ptr = (const char *)&m[old_path];
979 const char *new_path_ptr = (const char *)&m[new_path];
980#if LOG_TRACE
981 fprintf(stderr, "wasi_snapshot_preview1_path_link(%u, 0x%X, \"%.*s\", %u, \"%.*s\")\n", old_fd, old_flags, (int)old_path_len, old_path_ptr, new_fd, (int)new_path_len, new_path_ptr);
982#endif
983 (void)old_fd;
984 (void)old_flags;
985 (void)old_path_ptr;
986 (void)old_path_len;
987 (void)new_fd;
988 (void)new_path_ptr;
989 (void)new_path_len;
990 panic("unimplemented: path_link");
991 return wasi_errno_success;
992}
993
942994uint32_t wasi_snapshot_preview1_path_unlink_file(uint32_t fd, uint32_t path, uint32_t path_len) {
943995 uint8_t *const m = *wasm_memory;
944996 const char *path_ptr = (const char *)&m[path];
......@@ -1038,6 +1090,15 @@ uint32_t wasi_snapshot_preview1_fd_seek(uint32_t fd, uint64_t in_offset, uint32_
10381090 return wasi_errno_success;
10391091}
10401092
1093uint32_t wasi_snapshot_preview1_fd_sync(uint32_t fd) {
1094#if LOG_TRACE
1095 fprintf(stderr, "wasi_snapshot_preview1_fd_sync(%u)\n", fd);
1096#endif
1097 (void)fd;
1098 panic("unimplemented: fd_sync");
1099 return wasi_errno_success;
1100}
1101
10411102uint32_t wasi_snapshot_preview1_poll_oneoff(uint32_t in, uint32_t out, uint32_t nsubscriptions, uint32_t res_nevents) {
10421103 (void)in;
10431104 (void)out;