aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os.zig
AgeCommit message (Collapse)Author
2025-10-29std.fs: use BadPathName rather than InvalidWtf8 on WindowsAndrew Kelley
2025-10-29std: accessZ -> accessAndrew Kelley
2025-10-29std.Io.Threaded: implement dirMake for WASIAndrew Kelley
2025-10-29fix miscellaneous compilation errorsAndrew Kelley
- ILSEQ -> error.BadPathName - implement dirStatPath for WASI
2025-10-29std: make IPv6 address parsing system-independentAndrew Kelley
before, the max length of the host name depended on the target.
2025-10-27remove all Oracle Solaris supportAlex Rønne Petersen
There is no straightforward way for the Zig team to access the Solaris system headers; to do this, one has to create an Oracle account, accept their EULA to download the installer ISO, and finally install it on a machine or VM. We do not have to jump through hoops like this for any other OS that we support, and no one on the team has expressed willingness to do it. As a result, we cannot audit any Solaris contributions to std.c or other similarly sensitive parts of the standard library. The best we would be able to do is assume that Solaris and illumos are 100% compatible with no way to verify that assumption. But at that point, the solaris and illumos OS tags would be functionally identical anyway. For Solaris especially, any contributions that involve APIs introduced after the OS was made closed-source would also be inherently more risky than equivalent contributions for other proprietary OSs due to the case of Google LLC v. Oracle America, Inc., wherein Oracle clearly demonstrated its willingness to pursue legal action against entities that merely copy API declarations. Finally, Oracle laid off most of the Solaris team in 2017; the OS has been in maintenance mode since, presumably to be retired completely sometime in the 2030s. For these reasons, this commit removes all Oracle Solaris support. Anyone who still wishes to use Zig on Solaris can try their luck by simply using illumos instead of solaris in target triples - chances are it'll work. But there will be no effort from the Zig team to support this use case; we recommend that people move to illumos instead.
2025-10-10replaced https://simonsapin.github.io/wtf-8/ with https://wtf-8.codeberg.page/usebeforefree
2025-09-19std.fmt: migrate bufPrintZ to bufPrintSentinel (#25260)John Benediktsson
2025-07-07std.fmt: breaking API changesAndrew Kelley
added adapter to AnyWriter and GenericWriter to help bridge the gap between old and new API make std.testing.expectFmt work at compile-time std.fmt no longer has a dependency on std.unicode. Formatted printing was never properly unicode-aware. Now it no longer pretends to be. Breakage/deprecations: * std.fs.File.reader -> std.fs.File.deprecatedReader * std.fs.File.writer -> std.fs.File.deprecatedWriter * std.io.GenericReader -> std.io.Reader * std.io.GenericWriter -> std.io.Writer * std.io.AnyReader -> std.io.Reader * std.io.AnyWriter -> std.io.Writer * std.fmt.format -> std.fmt.deprecatedFormat * std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape * std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape * std.fmt.fmtSliceHexLower -> {x} * std.fmt.fmtSliceHexUpper -> {X} * std.fmt.fmtIntSizeDec -> {B} * std.fmt.fmtIntSizeBin -> {Bi} * std.fmt.fmtDuration -> {D} * std.fmt.fmtDurationSigned -> {D} * {} -> {f} when there is a format method * format method signature - anytype -> *std.io.Writer - inferred error set -> error{WriteFailed} - options -> (deleted) * std.fmt.Formatted - now takes context type explicitly - no fmt string
2025-05-09std.os: handle ENOENT for fnctl on macosMeghan Denny
2025-04-06std: Remove some FreeBSD version checks and resulting dead code.Alex Rønne Petersen
We now require FreeBSD 13.4+.
2025-03-24lib/std: PermissionDenied/AccessDenied cleanup and falloutPat Tullmann
This PR consistently maps .ACCES into AccessDenied and .PERM into PermissionDenied. AccessDenied is returned if the file mode bit (user/group/other rwx bits) disallow access (errno was `EACCES`). PermissionDenied is returned if something else denies access (errno was `EPERM`) (immutable bit, SELinux, capabilities, etc). This somewhat subtle distinction is a POSIX thing. Most of the change is updating std.posix Error Sets to contain both errors, and then propagating the pair up through caller Error Sets. Fixes #16782
2025-03-11std: Add support for SerenityOS in various placesLinus Groh
Not nearly the entire downstream patchset but these are completely uncontroversial and known to work.
2025-01-16x86_64: implement switch jump tablesJacob Young
2024-07-19std.c reorganizationAndrew Kelley
It is now composed of these main sections: * Declarations that are shared among all operating systems. * Declarations that have the same name, but different type signatures depending on the operating system. Often multiple operating systems share the same type signatures however. * Declarations that are specific to a single operating system. - These are imported one per line so you can see where they come from, protected by a comptime block to prevent accessing the wrong one. Closes #19352 by changing the convention to making types `void` and functions `{}`, so that it becomes possible to update `@hasDecl` sites to use `@TypeOf(f) != void` or `T != void`. Happily, this ended up removing some duplicate logic and update some bitrotted feature detection checks. A handful of types have been modified to gain namespacing and type safety. This is a breaking change. Oh, and the last usage of `usingnamespace` site is eliminated.
2024-07-15Better implementation of GetLastError. (#20623)Lucas Santos
Instead of calling the dynamically loaded kernel32.GetLastError, we can extract it from the TEB. As shown by [Wine](https://github.com/wine-mirror/wine/blob/34b1606019982b71818780bc84b76460f650af31/include/winternl.h#L439), the last error lives at offset 0x34 of the TEB in 32-bit Windows and at offset 0x68 in 64-bit Windows.
2024-06-13std: Convert deprecated aliases to compile errors and fix usagesRyan Liptak
Deprecated aliases that are now compile errors: - `std.fs.MAX_PATH_BYTES` (renamed to `std.fs.max_path_bytes`) - `std.mem.tokenize` (split into `tokenizeAny`, `tokenizeSequence`, `tokenizeScalar`) - `std.mem.split` (split into `splitSequence`, `splitAny`, `splitScalar`) - `std.mem.splitBackwards` (split into `splitBackwardsSequence`, `splitBackwardsAny`, `splitBackwardsScalar`) - `std.unicode` + `utf16leToUtf8Alloc`, `utf16leToUtf8AllocZ`, `utf16leToUtf8`, `fmtUtf16le` (all renamed to have capitalized `Le`) + `utf8ToUtf16LeWithNull` (renamed to `utf8ToUtf16LeAllocZ`) - `std.zig.CrossTarget` (moved to `std.Target.Query`) Deprecated `lib/std/std.zig` decls were deleted instead of made a `@compileError` because the `refAllDecls` in the test block would trigger the `@compileError`. The deleted top-level `std` namespaces are: - `std.rand` (renamed to `std.Random`) - `std.TailQueue` (renamed to `std.DoublyLinkedList`) - `std.ChildProcess` (renamed/moved to `std.process.Child`) This is not exhaustive. Deprecated aliases that I didn't touch: + `std.io.*` + `std.Build.*` + `std.builtin.Mode` + `std.zig.c_translation.CIntLiteralRadix` + anything in `src/`
2024-05-09handle visionos target OS tag in the compilerJakub Konka
* rename .xros to .visionos as agreed in the tracking issue * add support for VisionOS platform in the MachO linker
2024-03-19fix compilation failures found by CIAndrew Kelley
2024-03-19extract std.posix from std.osAndrew Kelley
closes #5019
2024-03-17std: define error set of `toPosixPath`Veikka Tuominen
2024-03-11std.builtin: make atomic order fields lowercaseTristan Ross
2024-02-28posix: `@as` and other general cleanupJacob Young
2024-02-28posix: fix socket fd leaksJacob Young
2024-02-27Eliminate `error.InvalidHandle` from OpenError and RealPathErrorRyan Liptak
InvalidHandle in OpenError is no longer a possible error on any platform. In the past it was able to be returned in `openOptionsFromFlagsWasi`, but the implementation was changed in 7680c5330cbc9141b9a5444e30c512b6068ab50d to make it no longer possible. InvalidHandle in RealPathError was a holdover from before d5312d53a066092ba9efd687e25b29a87eb6290c, which made realpath a compile error on WASI. However, InvalidHandle was also a possible error in the FreeBSD fallback implementation added in 537624734c4db9e0cdbdc0ebce57375d17172a70. This commit changes the FreeBSD fallback implementation to return FileNotFound instead of InvalidHandle which matches how EBADF is handled in all the other `realpath` implementations (including the FreeBSD non-fallback implementation). Closes #19084
2024-02-24Fix handling of Windows (WTF-16) and WASI (UTF-8) pathsRyan Liptak
Windows paths now use WTF-16 <-> WTF-8 conversion everywhere, which is lossless. Previously, conversion of ill-formed UTF-16 paths would either fail or invoke illegal behavior. WASI paths must be valid UTF-8, and the relevant function calls have been updated to handle the possibility of failure due to paths not being encoded/encodable as valid UTF-8. Closes #18694 Closes #1774 Closes #2565
2024-02-24Merge pull request #19064 from ziglang/fix-netname-deletedAndrew Kelley
std: map NETNAME_DELETED to error.ConnectionResetByPeer
2024-02-24std: map NETNAME_DELETED to error.ConnectionResetByPeerAndrew Kelley
This was observed in writing to a network stream that was closed on the read end.
2024-02-23use @trap instead of system.abort for emscriptenJae B
2024-02-23std.net, std.http: simplifyAndrew Kelley
2024-02-22update root.os.system override to require "system" field, this allows easier ↵Jae B
overriding of os.heap.page_allocator
2024-02-16std.os.windows: add error.UnrecognizedVolumeAndrew Kelley
Thanks to @matklad for finding this additional NTSTATUS possibility when calling GetFinalPathNameByHandle.
2024-02-14std.os: export T struct and winsize structTim Culverhouse
Export the T struct and winsize struct for targets which have it defined in std.c. This struct defines libc constants for ioctl syscalls.
2024-02-14std.os.windows.OpenFile: add missing errorAndrew Kelley
Encountered in a recent CI run on an aarch64-windows dev kit. Pretty sure I disabled the virus scanner but it looks like it turned itself back on with a Windows Update. Rather than marking the new error code as unreachable in the places where it is unexpected, this commit makes it return `error.Unexpected`.
2024-02-13std.posix.termios: bring V backAndrew Kelley
In d7563a7753393d7f0d1af445276a64b8a55cb857, I misunderstood what `cc_t` was supposed to do. Those V enum values are indices into the array.
2024-02-12std.os.termios: move it to be with the groupAndrew Kelley
2024-02-12std.os.termios: add type safety to lflag fieldAndrew Kelley
This creates `tc_cflag_t` even though such a type is not defined by libc. I also collected the missing flag bits from all the operating systems.
2024-02-12std.os.termios: add type safety to cflag fieldAndrew Kelley
This creates `tc_cflag_t` even though such a type is not defined by libc. I also collected the missing flag bits from all the operating systems.
2024-02-12std.os.termios: add type safety to oflag fieldAndrew Kelley
This creates `tc_oflag_t` even though such a type is not defined by libc. I also collected the missing flag bits from all the operating systems.
2024-02-12std.os.termios: add type safety to iflag fieldAndrew Kelley
This creates `tc_iflag_t` even though such a type is not defined by libc. I also collected the missing flag bits from all the operating systems.
2024-02-12std.os.termios: consolidate and correctAndrew Kelley
2024-02-12std: add type safety to cc_tAndrew Kelley
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-02-09Merge pull request #18712 from Vexu/std.optionsAndrew Kelley
std: make options a struct instance instead of a namespace
2024-02-06std.c.MAP: use a packed structAndrew Kelley
Same as previous commit, but for the libc interface.
2024-02-06std.os.linux.MAP: use a packed structAndrew Kelley
Introduces type safety to this constant. Eliminates one use of `usingnamespace`.
2024-02-01remove std.io.ModeVeikka Tuominen
2024-01-29std.os: fix chdirZ to compile on Windows (#18695)Krzysztof Wolicki
2024-01-13std.os: proper use of inlineAndrew Kelley
Uses `inline` only to forward the comptime-ness of the flags parameter to function selection. Also fixes doc comments in std.c.versionCheck.
2024-01-13Linux: Add fchmodat fallback when `flags` is nonzeroStephen Gregoratto
The check for determining whether to use the fallback code has been moved into an inline function as per Andrew's comments in #17954.