aboutsummaryrefslogtreecommitdiff
path: root/lib/std/posix.zig
AgeCommit message (Collapse)Author
2025-11-20system specific errnorpkak
2025-11-15Merge pull request #25539 from squeek502/windows-readlinkwRyan Liptak
windows: Make readLinkW APIs output WTF-16, reduce stack usage of callers
2025-11-15windows: Make readLinkW APIs output WTF-16, reduce stack usage of callersRyan Liptak
- Affects the following functions: + `std.fs.Dir.readLinkW` + `std.os.windows.ReadLink` + `std.os.windows.ntToWin32Namespace` + `std.posix.readlinkW` + `std.posix.readlinkatW` Each of these functions (except `ntToWin32Namespace`) took WTF-16 as input and would output WTF-8, which makes optimal buffer re-use difficult at callsites and could force unnecessary WTF-16 <-> WTF-8 conversion during an intermediate step. The functions have been updated to output WTF-16, and also allow for the path and the output to re-use the same buffer (i.e. in-place modification), which can reduce the stack usage at callsites. For example, all of `std.fs.Dir.readLink`/`readLinkZ`/`std.posix.readlink`/`readlinkZ`/`readlinkat`/`readlinkatZ` have had their stack usage reduced by one PathSpace struct (64 KiB) when targeting Windows. The new `ntToWin32Namespace` takes an output buffer and returns a slice from that instead of returning a PathSpace, which is necessary to make the above possible.
2025-11-15windows.ReadLink: Use OpenFile now that `.filter = .any` existsRyan Liptak
The reasoning in the comment deleted by this commit no longer applies, since that same benefit can be obtained by using OpenFile with `.filter = .any`. Also removes a stray debug.print
2025-11-14represent Mac Catalyst as aarch64-maccatalyst-none rather than ↵Alex Rønne Petersen
aarch64-ios-macabi Apple's own headers and tbd files prefer to think of Mac Catalyst as a distinct OS target. Earlier, when DriverKit support was added to LLVM, it was represented a distinct OS. So why Apple decided to only represent Mac Catalyst as an ABI in the target triple is beyond me. But this isn't the first time they've ignored established target triple norms (see: armv7k and aarch64_32) and it probably won't be the last. While doing this, I also audited all Darwin OS prongs throughout the codebase and made sure they cover all the tags.
2025-11-09posix: reduce the number of assumptions made by `dl_iterate_phdr`Jacob Young
Not yet fully compatible with the new linker, but still progress. Closes #25786
2025-11-07std.posix: implemented getpid and getppidGiuseppe Cesarano
2025-11-02std: serenity has preadv nowLinus Groh
https://github.com/SerenityOS/serenity/commit/2a9154e77c61d79d4b96b5f957aca2d70325ac6d
2025-10-31std.os.windows: eliminate forwarder function in kernel32 (#25766)qilme
#1840 kernel32.AddVectoredExceptionHandler -> ntdll.RtlAddVectoredExceptionHandler kernel32.RemoveVectoredExceptionHandler -> ntdll.RtlRemoveVectoredExceptionHandler kernel32.ExitProcess -> ntdll.RtlExitUserProcess kernel32.InitializeCriticalSection -> ntdll.RtlInitializeCriticalSection kernel32.EnterCriticalSection -> ntdll.RtlEnterCriticalSection kernel32.LeaveCriticalSection -> ntdll.RtlLeaveCriticalSection kernel32.DeleteCriticalSection -> ntdll.RtlDeleteCriticalSection kernel32.TryAcquireSRWLockExclusive -> ntdll.RtlTryAcquireSRWLockExclusive kernel32.AcquireSRWLockExclusive -> ntdll.RtlAcquireSRWLockExclusive kernel32.ReleaseSRWLockExclusive -> ntdll.RtlReleaseSRWLockExclusive kernel32.WakeConditionVariable -> ntdll.RtlWakeConditionVariable kernel32.WakeAllConditionVariable -> ntdll.RtlWakeAllConditionVariable kernel32.HeapReAlloc -> ntdll.RtlReAllocateHeap kernel32.HeapAlloc -> ntdll.RtlAllocateHeap
2025-10-29std.Io.Threaded: install and cleanup signal handlersAndrew Kelley
rather than in start code. delete std.options.keep_sig_io and std.options.keep_sig_pipe
2025-10-29std.Io.Threaded: implement dirMakeOpenPath for WASIAndrew Kelley
and fix error code when file operation occurs on director handle
2025-10-29std: make signal numbers into an enumAndrew Kelley
fixes start logic for checking whether IO/POLL exist
2025-10-29std: fix build failure on wasm32-freestandingAndrew Kelley
2025-10-29std.process.Child: update for std.Io changesAndrew Kelley
2025-10-29std.Io.Threaded: implement netConnectIp for WindowsAndrew Kelley
2025-10-29std.Io.Threaded: implement netAccept for WindowsAndrew Kelley
2025-10-29std.Io.Threaded: implement netListen for WindowsAndrew Kelley
2025-10-29std.posix: fix compilation on wasm32-freestandingAndrew Kelley
2025-10-29std.posix: untangle getRandomBytesDevURandom from Io.ReaderAndrew Kelley
2025-10-29std.Io.Threaded: implement dirCreateFile for WindowsAndrew Kelley
2025-10-29std.Io.Threaded: implement dirAccess for WindowsAndrew Kelley
2025-10-29std.Io.Threaded: add dirMake for WindowsAndrew Kelley
2025-10-29std: fix compilation errors on WindowsAndrew Kelley
2025-10-29std: move some windows path checking logicAndrew Kelley
2025-10-29std.fs: use BadPathName rather than InvalidWtf8 on WindowsAndrew Kelley
2025-10-29std.Io.net.Server: refine AcceptError setAndrew Kelley
2025-10-29std.Io.Threaded: implement dirCreateFile for WASIAndrew Kelley
2025-10-29std.Io.Threaded: implement dirMake for WASIAndrew Kelley
2025-10-29std.Io: add dirAccessAndrew 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-29std: move DNS record enum to a better namespaceAndrew Kelley
2025-10-29std: fix macos compilation errorsAndrew Kelley
2025-10-29std.Io.net.HostName: move lookup to the interfaceAndrew Kelley
Unfortunately this can't be implemented "above the vtable" because various operating systems don't provide low level DNS resolution primitives such as just putting the list of nameservers in a file. Without libc on Linux it works great though! Anyway this also changes the API to be based on Io.Queue. By using a large enough buffer, reusable code can be written that does not require concurrent, yet takes advantage of responding to DNS queries as they come in. I sketched out a new implementation of `HostName.connect` to demonstrate this, but it will require an additional API (`Io.Select`) to be implemented in a future commit. This commit also introduces "uncancelable" variants for mutex locking, waiting on a condition, and putting items into a queue.
2025-10-29compiler: update for introduction of std.IoAndrew Kelley
only thing remaining is using libc dns resolution when linking libc
2025-10-29std.Io.Threaded.netReadPosix: support cancelationAndrew Kelley
2025-10-29std: fix seekBy unit testAndrew Kelley
2025-10-29std.Io: implement dirStatPathAndrew Kelley
2025-10-29std: fix some Io compilation errorsAndrew Kelley
2025-10-29std.Io: implement fileStatAndrew Kelley
2025-10-29std: updating to std.Io interfaceAndrew Kelley
got the build runner compiling
2025-10-29std.Io.net: implement receiving connectionless messagesAndrew Kelley
2025-10-29std.Io: extract Dir to separate fileAndrew Kelley
2025-10-29Io.net: partial implementation of dns lookupAndrew Kelley
2025-10-29std: start moving fs.File to IoAndrew Kelley
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-21std.{c,posix}: add getgid and getegidWim de With
2025-10-17windows: Always try using POSIX_SEMANTICS/etc for rename/deleteRyan Liptak
The compile-time check against the minimum version here wasn't appropriate, since it still makes sense to try using FILE_RENAME_INFORMATION_EX even if the minimum version is something like `xp`, since that doesn't rule out the possibility of the compiled code running on Windows 10/11. This compile-time check was doubly bad since the default minimum windows version (`.win10`) was below the `.win10_rs5` that was checked for, so when providing a target like `x86_64-windows-gnu` it'd always rule out using this syscall. After this commit, we always try using FILE_RENAME_INFORMATION_EX and then let the operating system tell us when some aspect of it is not supported. This allows us to get the benefits of these new syscalls/flags whenever it's actually possible. The possible error returns were validated experimentally: - INVALID_PARAMETER is returned when the underlying filesystem is FAT32 - INVALID_INFO_CLASS is returned on Windows 7 when trying to use FileRenameInformationEx/FileDispositionInformationEx - NOT_SUPPORTED is returned on Windows 10 >= .win10_rs5 when setting a bogus flag value (I used `0x1000`)
2025-10-11std.posix: panic on unexpected error in `munmap`mlugg
This is to help diagnose #25498. We can't use `unexpectedErrno` here, because `std.posix.munmap` is infallible. So, when the flag is set to report unexpected errnos, we just call `std.debug.panic` to provide details instead of doing `unreachable`. Pushing straight to master after running checks locally; there's no point waiting for CI on the PR just for this.
2025-10-10replaced https://simonsapin.github.io/wtf-8/ with https://wtf-8.codeberg.page/usebeforefree