aboutsummaryrefslogtreecommitdiff
path: root/lib/std
AgeCommit message (Collapse)Author
2025-09-20std.json: delete test tightly coupled to ArrayList growthAndrew Kelley
This test works by assuming that std.ArrayList will grow with a specific capacity increasing pattern, which is an invalid assumption. Delete the offending test.
2025-09-20std: remove loop from growCapacityAndrew Kelley
I measured this against master branch and found no statistical difference. Since this code is simpler and logically superior due to always leaving sufficient unused capacity when growing, it is preferred over status quo.
2025-09-20Merge pull request #25298 from ziglang/SegmentedList-orphaned-againAndrew Kelley
std: delete SegmentedList again
2025-09-20std.c: add MSG support for dragonflyJohn Benediktsson
2025-09-20std.crypto.ascon: disable Ascon-AEAD128 test on RISC-V with V supportAlex Rønne Petersen
2025-09-20std.c: adjust shm_open to be variadic on darwinJohn Benediktsson
2025-09-19std.Build.Step.Run: Enable passing (generated) file content as argsJustus Klausecker
Adds `addFileContentArg` and `addPrefixedFileContentArg` to pass the content of a file with a lazy path as an argument to a `std.Build.Step.Run`. This enables replicating shell `$()` / cmake `execute_process` with `OUTPUT_VARIABLE` as an input to another `execute_process` in conjuction with `captureStdOut`/`captureStdErr`. To also be able to replicate `$()` automatically trimming trailing newlines and cmake `OUTPUT_STRIP_TRAILING_WHITESPACE`, this patch adds an `options` arg to those functions which allows specifying the desired handling of surrounding whitespace. The `options` arg also allows to specify a custom `basename` for the output. e.g. to add a file extension (concrete use case: Zig `@import()` requires files to have a `.zig`/`.zon` extension to recognize them as valid source files).
2025-09-19std: delete SegmentedList againAndrew Kelley
The data structure was originally added in 41e1cd185b82a518c58c92544c45f0348c03ef74 and then removed in 50a336fff899ebd8a687c453ec6beb18a5a9baf9, but brought back in 711bf55eaa643c3d05640bebbf3e4315477b8ed8 for Decl in the compiler frontend, and then the last reference to it was eliminated in 548a087fafeda5b07d2237d5137906b8d07da699 which removed Decl in favor of Nav and Cau.
2025-09-19Merge pull request #23416 from gooncreeper/improved-fuzzerAndrew Kelley
greatly improve capabilities of the fuzzer
2025-09-19Merge pull request #25268 from alexrp/loongarchAlex Rønne Petersen
Miscellaneous LoongArch work to prepare for CI
2025-09-18Remove usages of deprecatedWriterandrewkraevskii
2025-09-19std.fmt: migrate bufPrintZ to bufPrintSentinel (#25260)John Benediktsson
2025-09-19std.simd: suggest more sensible vector sizes across the boardAlex Rønne Petersen
2025-09-18add some new fuzz testsKendall Condon
2025-09-18greatly improve capabilities of the fuzzerKendall Condon
This PR significantly improves the capabilities of the fuzzer. The changes made to the fuzzer to accomplish this feat mostly include tracking memory reads from .rodata to determine fresh inputs, new mutations (especially the ones that insert const values from .rodata reads and __sanitizer_conv_const_cmp), and minimizing found inputs. Additionally, the runs per second has greatly been increased due to generating smaller inputs and avoiding clearing the 8-bit pc counters. An additional feature added is that the length of the input file is now stored and the old input file is rerun upon start. Other changes made to the fuzzer include more logical initialization, using one shared file `in` for inputs, creating corpus files with proper sizes, and using hexadecimal-numbered corpus files for simplicity. Furthermore, I added several new fuzz tests to gauge the fuzzer's efficiency. I also tried to add a test for zstandard decompression, which it crashed within 60,000 runs (less than a second.) Bug fixes include: * Fixed a race conditions when multiple fuzzer processes needed to use the same coverage file. * Web interface stats now update even when unique runs is not changing. * Fixed tokenizer.testPropertiesUpheld to allow stray carriage returns since they are valid whitespace.
2025-09-18std.Target: adjustments to LoongArch CPU modelsAlex Rønne Petersen
* Remove the generic model; we already have generic_la32 and generic_la64 and pick appropriately based on bitness. * Remove the loongarch64 model. We used this as our baseline for 64-bit, but it's actually pretty misleading and useless; it doesn't represent any real CPU and has less features than generic_la64. * Add la64v1_0 and la64v1_1 models. * Change our baseline CPU model for 64-bit to be la64v1_0, thus adding LSX to the baseline feature set.
2025-09-18std.zig.system: implement native CPU detection for LoongArchAlex Rønne Petersen
ref #4591
2025-09-18std.math.modf: disable vector test on LoongArch with LSXAlex Rønne Petersen
https://github.com/llvm/llvm-project/issues/159529
2025-09-18std.crypto.ml_kem: disable some Kyber tests on LoongArch with LSXAlex Rønne Petersen
LLVM miscompiles these.
2025-09-18std.mem: work around LoongArch inline asm bug in doNotOptimizeAway()Alex Rønne Petersen
https://github.com/llvm/llvm-project/issues/159200
2025-09-17Merge pull request #25195 from blblack/netdefsAndrew Kelley
std: Add several sockopt-related constants and structs
2025-09-17Merge pull request #25197 from rootbeer/24380-flaky-sigset-testAndrew Kelley
Re-enable std.posix "sigset_t bits" test
2025-09-17Merge pull request #25217 from blblack/setsiderrAndrew Kelley
std.os.linux.setsid(): return raw syscall0 result
2025-09-17Merge pull request #25225 from Justus2308/darwin-fixesAndrew Kelley
std.*.ptrace: support more platforms and features more correctly
2025-09-17mem.replace: Document that input/output cannot overlapRyan Liptak
2025-09-17Merge pull request #25249 from jedisct1/sivAndrew Kelley
std.crypto: add AES-SIV and AES-GCM-SIV
2025-09-17std.crypto: add Ascon-AEAD, Ascon-Hash, Ascon-CHash (#25239)Frank Denis
Ascon is the family of cryptographic constructions standardized by NIST for lightweight cryptography. The Zig standard library already included the Ascon permutation itself, but higher-level constructions built on top of it were intentionally postponed until NIST released the final specification. That specification has now been published as NIST SP 800-232: https://csrc.nist.gov/pubs/sp/800/232/final With this publication, we can now confidently include these constructions in the standard library.
2025-09-17std.sort.pdq: fix out-of-bounds access in partialInsertionSort (#25253)Frank Denis
* std.sort.pdq: fix out-of-bounds access in partialInsertionSort When sorting a sub-range that doesn't start at index 0, the partialInsertionSort function could access indices below the range start. The loop condition `while (j >= 1)` didn't respect the arbitrary range boundaries [a, b). This changes the condition to `while (j > a)` to ensure indices never go below the range start, fixing the issue where pdqContext would access out-of-bounds indices. Fixes #25250
2025-09-17use block break instead of returnmarko
2025-09-17Avoid logic where we return success in case of an error (#25251)Frank Denis
In ed25519.zig, we checked if a test succeeds, in which case we returned an error. This was confusing, and Andrew pointed out that Zig weights branches against errors by default.
2025-09-16Parallelize deriveKeysFrank Denis
2025-09-16Import crypto/aes_gcm_siv.zigFrank Denis
2025-09-16std.crypto: add AES-SIV and AES-GCM-SIVFrank Denis
The Zig standard library lacked schemes that resist nonce reuse. AES-SIV and AES-GCM-SIV are the standard options for this. AES-GCM-SIV can be very useful when Zig is used to target embedded systems, and AES-SIV is especially useful for key wrapping. Also take it as an opportunity to add a bunch of test vectors to modes.ctr and make sure it works with block ciphers whose size is not 16.
2025-09-15bpf: use bitCast instead of intCast in ld_imm_implGeorge Huebner
Any 32 bit immediate is allowed in a BPF instruction, including those greater than the largest positive i32 value.
2025-09-15std.net.Ip6Address: format numerical scope iddatabase64128
2025-09-13std.math.big.int: normalize zero result for small multiplicationsmlugg
Resolves: #25221
2025-09-13std.os.linux.ptrace: add PTRACE_EVENT_* and PTRACE_O_* valuesJustus Klausecker
2025-09-13std.posix.ptrace: support more platforms more correctlyJustus Klausecker
2025-09-12linux: Doc and check retval for no-fail pid callsBrandon Black
The switch from @bitCast() to @intCast() here safety-checks Linux's assertion that these 3 calls never return errors (negative values as pid_t). getppid() can legally return 0 if the parent is in a different pid namespace, but this is not an error.
2025-09-12std.os.linux.setsid(): return raw syscall0 resultBrandon Black
When not linking libc on 64-bit Linux and calling posix.setsid(), we get a type error at compile time inside of posix.errno(). This is because posix.errno()'s non-libc branch expects a usize-sized value, which is what all the error-returning os.linux syscalls return, and linux.setsid() instead returned a pid_t, which is only 32 bits wide. This and the other 3 pid-related calls just below it (getpid(), getppid(), and gettid()) are the only Linux syscall examples here that are casting their return values to pid_t. For the other 3 this makes sense: those calls are documented to have no possible errors and always return a valid pid_t value. However, setsid() actually can return the error EPERM, and therefore needs to return the raw value from syscall0 for posix.errno() to process like normal. Additionally, posix.setsid() needs an @intCast(rc) for the success case as a result, like most other such cases.
2025-09-12std.os.linux.socketpair(): switch to unsigned argsBrandon Black
We need std.os.linux and std.c to agree on the types here, or else we'd have to pointlessly cast across the difference up in the std.posix wrapper. I ran into this as a type error the first time I tried to compile my code that calls posix.socketpair() on Linux without libc. All of our existing socket calls with these kinds of arguments in std (including the existing c.socketpair as well as os.linux.socket in this same file) use unsigned for all of these parameters, and so this brings linux.socketpair() into alignment with everything else.
2025-09-11use pointer subtractionmarko
2025-09-10Merge pull request #24968 from ifreund/dequeAndrew Kelley
std: add a Deque data structure
2025-09-09standalone posix tests for sigactionPat Tullmann
Fixes #24380
2025-09-09standalone posix tests for relative path linkingPat Tullmann
2025-09-09standalone posix test for env varsPat Tullmann
2025-09-09standalone posix test for current working directoryPat Tullmann
2025-09-09posix/test.zig: "sigset_t bits" test fixesPat Tullmann
Re-enable the test. Will trigger #24380 as-is, but follow-on change moes this code over to test/standalone. Make the test a bit easier to debug by stashing the "seen" signal number in the shared `seen_sig` (instead of just incrementing a counter for each hit). And only doing so if the `seen_sig` is zero.
2025-09-09Move some Thread tests out of posix/test.zig into Thread.zigPat Tullmann
These tests aren't (directly) using Posix APIs, so they don't need to be in posix/test.zig. Put them over with the code and tests in Thread.zig. Since the spawn/join test in the posix code was redundant, just dropped that one.
2025-09-09std: add IP, IPV6, IPTOS sockopt constantsBrandon Black
Because these lists are very long in several cases and quite varied, I opted to place them in the existing c/foo.zig files. There are many other sets of network-related constants like this to add over time across all the OSes. For now I picked these because I needed a few constants from each of these namespaces for my own project, so I tried to flesh out these namespaces completely as best I could, at least for basic sockopt purposes. Note windows has some of these already defined in ws2_32 as individual constants rather than contained in a namespacing struct. I'm not sure what to do with that in the long run (break it and namespace them?), but this doesn't change the status quo for windows in any case.