aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/wasi.zig
AgeCommit message (Collapse)Author
2025-02-09wasi: fix wasm-wasi-musl constantsPat Tullmann
Zig's copy of the `SYMLINK_{NO,}FOLLOW` constants from wasi-musl was wrong, as were the `IFIFO` and `IFSOCK` file type flags. Fix these up, and add comments pointing to exactly where they come from (as the wasi-musl source has lots of unused, different definitions of these constants). Add tests for the Zig convention that WASM preopen 3 is the current working directory. This is true for WASM with or without libc. Enable several fs and posix tests that are now passing (not necessarily because of this change) on wasm targets. Fixes #20890.
2024-10-06Copy in WASI rights_t documentationachan1989
2024-05-11Do not run asserts for WASI alignment when not targeting WASI190n
2024-03-19extract std.posix from std.osAndrew Kelley
closes #5019
2024-02-11some API work on std.c, std.os, std.os.wasiAndrew Kelley
* std.c: consolidate some definitions, making them share code. For example, freebsd, dragonfly, and openbsd can all share the same `pthread_mutex_t` definition. * add type safety to std.c.O - this caught a bug where mode flags were incorrectly passed as the open flags. * 3 fewer uses of usingnamespace keyword * as per convention, remove purposeless field prefixes from struct field names even if they have those prefixes in the corresponding C code. * fix incorrect wasi libc Stat definition * remove C definitions from incorrectly being in std.os.wasi * make std.os.wasi definitions type safe * go through wasi native APIs even when linking libc because the libc APIs are problematic and wasteful * don't expose WASI definitions in std.posix * remove std.os.wasi.rights_t.ALL: this is a footgun. should it be all future rights too? or only all current rights known? both are the wrong answer.
2024-01-26std.os.wasi | Fix comment linksZachary Raineri
Branch was renamed: master -> main Preview 1 was moved to legacy
2023-09-18wasi: update `sock_recv` and `sock_send` according to preview1nikneym
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2022-12-06std: fix WASI regressionsAndrew Kelley
This branch largely reverts 58f961f4cb9875bbce3070969438ecf08f392c9f. I would like to revisit the proposal to modify the standard library in this way and think more carefully about it before adding isAbsolute() checks everywhere.
2022-11-18run zig fmt on everything checked by CIStevie Hryciw
2022-10-03std: WASI - update to latest snapshot preview 1Luuk de Gram
This implements the new addition to the API: `sock_accept`. Reference commit of WASI spec: 0ba0c5e2e37625ca5a6d3e4255a998dfaa3efc52 For full details: https://github.com/WebAssembly/WASI/commit/0ba0c5e2e37625ca5a6d3e4255a998dfaa3efc52 For entire spec at this commit: https://github.com/WebAssembly/WASI/blob/0ba0c5e2e37625ca5a6d3e4255a998dfaa3efc52/phases/snapshot/docs.md
2022-03-03stdlib: Add emulated CWD to std.os for WASI targetsCody Tapscott
This adds a special CWD file descriptor, AT.FDCWD (-2), to refer to the current working directory. The `*at(...)` functions look for this and resolve relative paths against the stored CWD. Absolute paths are dynamically matched against the stored Preopens. "os.initPreopensWasi()" must be called before std.os functions will resolve relative or absolute paths correctly. This is asserted at runtime. Support has been added for: `open`, `rename`, `mkdir`, `rmdir`, `chdir`, `fchdir`, `link`, `symlink`, `unlink`, `readlink`, `fstatat`, `access`, and `faccessat`. This also includes limited support for `getcwd()` and `realpath()`. These return an error if the CWD does not correspond to a Preopen with an absolute path. They also do not currently expand symlinks.
2022-02-13std.c.Wasi.Stat: use timespecominitay
2021-09-01std.os fixes to get the test suite passing againAndrew Kelley
2021-09-01std: fix regressions from this branchAndrew Kelley
Also move some usingnamespace test cases from compare_output to behavior.
2021-09-01std: reorganization that allows new usingnamespace semanticsAndrew Kelley
The proposal #9629 is now accepted, usingnamespace stays but no longer puts identifiers in scope.
2021-09-01std.os: more reorganization effortsAndrew Kelley
* std lib tests are passing on x86_64-linux with and without -lc * stage2 is building from source on x86_64-linux * down to 38 remaining uses of `usingnamespace`
2021-09-01std: reorganize std.c to eliminate `usingnamespace`Andrew Kelley
Behavior tests pass on x86_64-linux with -lc
2021-09-01std.os reorganization, avoiding `usingnamespace`Andrew Kelley
The main purpose of this branch is to explore avoiding the `usingnamespace` feature of the zig language, specifically with regards to `std.os` and related functionality. If this experiment is successful, it will provide a data point on whether or not it would be practical to entirely remove `usingnamespace` from the language. In this commit, `usingnamespace` has been completely eliminated from the Linux x86_64 compilation path, aside from io_uring. The behavior tests pass, however that's as far as this branch goes. It is very breaking, and a lot more work is needed before it could be considered mergeable. I wanted to put a pull requset up early so that zig programmers have time to provide feedback. This is progress towards closing #6600 since it clarifies where the actual "owner" of each declaration is, and reduces the number of different ways to import the same declarations. One of the main organizational strategies used here is to do namespacing with real namespaces (e.g. structs) rather than by having declarations share a common prefix (the C strategy). It's no coincidence that `usingnamespace` has similar semantics to `#include` and becomes much less necessary when using proper namespaces.
2021-08-24remove redundant license headers from zig standard libraryAndrew Kelley
We already have a LICENSE file that covers the Zig Standard Library. We no longer need to remind everyone that the license is MIT in every single file. Previously this was introduced to clarify the situation for a fork of Zig that made Zig's LICENSE file harder to find, and replaced it with their own license that required annual payments to their company. However that fork now appears to be dead. So there is no need to reinforce the copyright notice in every single file.
2021-08-24std: [breaking] move errno to become an nonexhaustive enumAndrew Kelley
The primary purpose of this change is to eliminate one usage of `usingnamespace` in the standard library - specifically the usage for errno values in `std.os.linux`. This is accomplished by truncating the `E` prefix from error values, and making errno a proper enum. A similar strategy can be used to eliminate some other `usingnamespace` sites in the std lib.
2020-12-31Year++Frank Denis
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2020-04-30Update WASI snapshot to preview1Jakub Konka
This commit updates the WASI imports to use `wasi_snapshot_preview1` instead of the old `wasi_unstable`. There are some minor ABI differences between the two, however, the main motivator for using the latest "stable" snapshot (aka preview1) is that, at least in Wasmtime, there has been a lot of improvement work put into preview1 and unfortunately I might add, the improvements were not (in full) backported to `wasi_unstable` snapshot. Also, this commit removes the optional bound on the pointer to `environ_get` syscall.
2020-01-06Removes proc_raise from WASI implementationColin Svingen
2019-11-30linux-i386 supportLemonBoy
2019-11-25move logic to the appropriate layers; add new compile errorAndrew Kelley
2019-11-25Merge branch 'wasi-run-tests' of https://github.com/fengb/zig into ↵Andrew Kelley
fengb-wasi-run-tests
2019-11-25more sentinel-terminated pointers std lib integrationAndrew Kelley
See #3767
2019-11-21Replace magic numbers with named constantsBenjamin Feng
2019-11-19WASI isattyBenjamin Feng
2019-11-19WASI clock functionsBenjamin Feng
2019-10-24get rid of std.os.foo.is_the_targetAndrew Kelley
It had the downside of running all the comptime blocks and resolving all the usingnamespaces of each system, when just trying to discover if the current system is a particular one. For Darwin, where it's nice to use `std.Target.current.isDarwin()`, this demonstrates the utility that #425 would provide.
2019-09-25mv std/ lib/Andrew Kelley
that's all this commit does. further commits will fix cli flags and such. see #2221