| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | #include <stdio.h> |
| 10 | 10 | #include <stdlib.h> |
| 11 | 11 | #include <string.h> |
| 12 | #include <inttypes.h> |
| 12 | 13 | |
| 13 | 14 | #include <fcntl.h> |
| 14 | 15 | #include <sys/mman.h> |
| ... | ... | @@ -859,9 +860,16 @@ static enum wasi_errno_t finish_wasi_stat(struct VirtualMachine *vm, |
| 859 | 860 | write_u64_le(vm->memory + buf + 0x10, to_wasi_filetype(st.st_mode)); |
| 860 | 861 | write_u64_le(vm->memory + buf + 0x18, 1); // nlink |
| 861 | 862 | write_u64_le(vm->memory + buf + 0x20, st.st_size); |
| 863 | #if defined(__APPLE__) |
| 864 | write_u64_le(vm->memory + buf + 0x28, to_wasi_timestamp(st.st_atimespec)); |
| 865 | write_u64_le(vm->memory + buf + 0x30, to_wasi_timestamp(st.st_mtimespec)); |
| 866 | write_u64_le(vm->memory + buf + 0x38, to_wasi_timestamp(st.st_ctimespec)); |
| 867 | #else |
| 862 | 868 | write_u64_le(vm->memory + buf + 0x28, to_wasi_timestamp(st.st_atim)); |
| 863 | 869 | write_u64_le(vm->memory + buf + 0x30, to_wasi_timestamp(st.st_mtim)); |
| 864 | 870 | write_u64_le(vm->memory + buf + 0x38, to_wasi_timestamp(st.st_ctim)); |
| 871 | #endif |
| 872 | |
| 865 | 873 | return WASI_ESUCCESS; |
| 866 | 874 | } |
| 867 | 875 | |
| ... | ... | @@ -1173,7 +1181,7 @@ static enum wasi_errno_t wasi_clock_time_get(struct VirtualMachine *vm, |
| 1173 | 1181 | |
| 1174 | 1182 | ///pub extern "wasi_snapshot_preview1" fn debug(string: [*:0]const u8, x: u64) void; |
| 1175 | 1183 | void wasi_debug(struct VirtualMachine *vm, uint32_t text, uint64_t n) { |
| 1176 | | fprintf(stderr, "wasi_debug: '%s' number=%lu %lx\n", vm->memory + text, n, n); |
| 1184 | fprintf(stderr, "wasi_debug: '%s' number=%" PRIu64" %" PRIx64 "\n", vm->memory + text, n, n); |
| 1177 | 1185 | } |
| 1178 | 1186 | |
| 1179 | 1187 | /// pub extern "wasi_snapshot_preview1" fn debug_slice(ptr: [*]const u8, len: usize) void; |
| ... | ... | @@ -4082,7 +4090,7 @@ int main(int argc, char **argv) { |
| 4082 | 4090 | |
| 4083 | 4091 | mkdir(cache_dir_buf, 0777); |
| 4084 | 4092 | cache_dir = err_wrap("opening cache dir", |
| 4085 | | open(cache_dir_buf, O_DIRECTORY|O_RDONLY|O_CLOEXEC|O_PATH)); |
| 4093 | open(cache_dir_buf, O_DIRECTORY|O_RDONLY|O_CLOEXEC)); |
| 4086 | 4094 | } |
| 4087 | 4095 | |
| 4088 | 4096 | // Construct a new argv for the WASI code which has absolute paths |
| ... | ... | @@ -4171,8 +4179,8 @@ int main(int argc, char **argv) { |
| 4171 | 4179 | size_t mod_len = ZSTD_decompress(mod_ptr, max_uncompressed_size, |
| 4172 | 4180 | compressed_bytes.ptr, compressed_bytes.len); |
| 4173 | 4181 | |
| 4174 | | int cwd = err_wrap("opening cwd", open(".", O_DIRECTORY|O_RDONLY|O_CLOEXEC|O_PATH)); |
| 4175 | | int zig_lib_dir = err_wrap("opening zig lib dir", open(zig_lib_dir_path, O_DIRECTORY|O_RDONLY|O_CLOEXEC|O_PATH)); |
| 4182 | int cwd = err_wrap("opening cwd", open(".", O_DIRECTORY|O_RDONLY|O_CLOEXEC)); |
| 4183 | int zig_lib_dir = err_wrap("opening zig lib dir", open(zig_lib_dir_path, O_DIRECTORY|O_RDONLY|O_CLOEXEC)); |
| 4176 | 4184 | |
| 4177 | 4185 | add_preopen(0, "stdin", STDIN_FILENO); |
| 4178 | 4186 | add_preopen(1, "stdout", STDOUT_FILENO); |