aboutsummaryrefslogtreecommitdiff
path: root/lib/std/std.zig
AgeCommit message (Collapse)Author
2025-09-10Merge pull request #24968 from ifreund/dequeAndrew Kelley
std: add a Deque data structure
2025-08-29std.Io: delete GenericReaderAndrew Kelley
and delete deprecated alias std.io
2025-08-25std: add a Deque data structureIsaac Freund
This is my penance for baiting andrew into deleting the existing generic queue data structures with my talk of "too many ring buffers". The new Reader and Writer interfaces are excellent ring buffers for many use cases, but a generic queue container type is now missing. This new double-ended queue, known more succinctly as a deque, is implemented from scratch based on the API design lessons learned from ArrayList over the years. The API is not yet as featureful as ArrayList, but the core functionality is in place and I will be using this in my personal projects shortly. I think it makes sense to add further functions as needed based on real-world use-cases.
2025-08-11std.ArrayList: make unmanaged the defaultAndrew Kelley
2025-08-07remove std.fifoAndrew Kelley
I never liked how this data structure took its API as a parameter. This use case is now served by std.Io buffering.
2025-08-05std: delete RingBufferAndrew Kelley
Progress towards #19231
2025-08-05std: remove BoundedArrayAndrew Kelley
This use case is handled by ArrayListUnmanaged via the "...Bounded" method variants, and it's more optimal to share machine code, versus generating multiple versions of each function for differing array lengths.
2025-07-11std: rename `io` to `Io` in preparationAndrew Kelley
This commit is non-breaking. std.io is deprecated in favor of std.Io, in preparation for that namespace becoming an interface.
2025-05-18start: Don't artificially limit some posixCallMainAndExit() logic to Linux.Alex Rønne Petersen
This code applies to ~any POSIX OS where we don't link libc. For example, it'll be useful for FreeBSD and NetBSD. As part of this, move std.os.linux.pie to std.pie since there's really nothing Linux-specific about what that file is doing.
2025-04-03de-genericify DoublyLinkedListAndrew Kelley
by making it always intrusive, we make it more broadly useful API, and avoid binary bloat.
2025-04-03de-genericify SinglyLinkedListAndrew Kelley
by making it always intrusive, we make it a more broadly useful API, and avoid binary bloat.
2025-02-06adjust runtime page size APIsAndrew Kelley
* fix merge conflicts * rename the declarations * reword documentation * extract FixedBufferAllocator to separate file * take advantage of locals * remove the assertion about max alignment in Allocator API, leaving it Allocator implementation defined * fix non-inline function call in start logic The GeneralPurposeAllocator implementation is totally broken because it uses global state but I didn't address that in this commit.
2025-02-06runtime page size detectionArchbirdplus
heap.zig: define new default page sizes heap.zig: add min/max_page_size and their options lib/std/c: add miscellaneous declarations heap.zig: add pageSize() and its options switch to new page sizes, especially in GPA/stdlib mem.zig: remove page_size
2025-02-03compiler,std: implement ZON supportMason Remaley
This commit allows using ZON (Zig Object Notation) in a few ways. * `@import` can be used to load ZON at comptime and convert it to a normal Zig value. In this case, `@import` must have a result type. * `std.zon.parse` can be used to parse ZON at runtime, akin to the parsing logic in `std.json`. * `std.zon.stringify` can be used to convert arbitrary data structures to ZON at runtime, again akin to `std.json`.
2024-11-07std.crypto.tls: improve debuggability of encrypted connectionsJacob Young
By default, programs built in debug mode that open a https connection will append secrets to the file specified in the SSLKEYLOGFILE environment variable to allow protocol debugging by external programs.
2024-10-12Remove packed_int_array.zig from stdKrzysztof Wolicki
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-06-02remove std.IniVeikka Tuominen
2024-05-26std: restructure child process namespaceAndrew Kelley
2024-05-03add std.zip and support zip files in build.zig.zonJonathan Marler
fixes #17408 Helpful reviewers/testers include Joshe Wolfe, Auguste Rame, Andrew Kelley and Jacob Young. Co-authored-by: Joel Gustafson <joelg@mit.edu>
2024-04-22ComptimeStringMap: return a regular struct and optimizeTravis Staloch
this patch renames ComptimeStringMap to StaticStringMap, makes it accept only a single type parameter, and return a known struct type instead of an anonymous struct. initial motivation for these changes was to reduce the 'very long type names' issue described here https://github.com/ziglang/zig/pull/19682. this breaks the previous API. users will now need to write: `const map = std.StaticStringMap(T).initComptime(kvs_list);` * move `kvs_list` param from type param to an `initComptime()` param * new public methods * `keys()`, `values()` helpers * `init(allocator)`, `deinit(allocator)` for runtime data * `getLongestPrefix(str)`, `getLongestPrefixIndex(str)` - i'm not sure these belong but have left in for now incase they are deemed useful * performance notes: * i posted some benchmarking results here: https://github.com/travisstaloch/comptime-string-map-revised/issues/1 * i noticed a speedup reducing the size of the struct from 48 to 32 bytes and thus use u32s instead of usize for all length fields * i noticed speedup storing KVs as a struct of arrays * latest benchmark shows these wall_time improvements for debug/safe/small/fast builds: -6.6% / -10.2% / -19.1% / -8.9%. full output in link above.
2024-03-19extract std.posix from std.osAndrew Kelley
closes #5019
2024-03-10improve documentation in stdAndrew Kelley
A lot of these "shorthand" doc comments were redundant, low quality filler content. Better to let the actual modules speak for themselves with top level doc comments rather than trying to document their aliases.
2024-02-26rearrange std.zigAndrew Kelley
This frees up std.zig.fmt to be used for the implementation of `zig fmt`.
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 #18867 from e4m2/randomAndrew Kelley
std.rand: Move to std.Random
2024-02-09Merge pull request #18712 from Vexu/std.optionsAndrew Kelley
std: make options a struct instance instead of a namespace
2024-02-08std.rand: Move to std.Randome4m2
2024-02-05std: add gpu namespaceAli Chraghi
2024-02-01remove std.eventVeikka Tuominen
2024-02-01std: change return type of `wasiCwd`Veikka Tuominen
`fd_t` is not declared on freestanding so returning a `Dir` causes an error.
2024-02-01std: make options a struct instance instead of a namespaceVeikka Tuominen
2024-01-27std: remove meta.globalOptionVeikka Tuominen
2024-01-01std.Target: flattenAndrew Kelley
2024-01-01zig build system: change target, compilation, and module APIsAndrew Kelley
Introduce the concept of "target query" and "resolved target". A target query is what the user specifies, with some things left to default. A resolved target has the default things discovered and populated. In the future, std.zig.CrossTarget will be rename to std.Target.Query. Introduces `std.Build.resolveTargetQuery` to get from one to the other. The concept of `main_mod_path` is gone, no longer supported. You have to put the root source file at the module root now. * remove deprecated API * update build.zig for the breaking API changes in this branch * move std.Build.Step.Compile.BuildId to std.zig.BuildId * add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions, std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and std.Build.TestOptions. * remove `std.Build.constructCMacro`. There is no use for this API. * deprecate `std.Build.Step.Compile.defineCMacro`. Instead, `std.Build.Module.addCMacro` is provided. - remove `std.Build.Step.Compile.defineCMacroRaw`. * deprecate `std.Build.Step.Compile.linkFrameworkNeeded` - use `std.Build.Module.linkFramework` * deprecate `std.Build.Step.Compile.linkFrameworkWeak` - use `std.Build.Module.linkFramework` * move more logic into `std.Build.Module` * allow `target` and `optimize` to be `null` when creating a Module. Along with other fields, those unspecified options will be inherited from parent `Module` when inserted into an import table. * the `target` field of `addExecutable` is now required. pass `b.host` to get the host target.
2023-10-21std.http: use loadDefaultProxies in compilerNameless
2023-10-21std.http.Client: add option to disable httpsNameless
std_options.http_connection_pool_size removed in favor of ``` client.connection_pool.resize(client.allocator, size); ``` std_options.http_disable_tls will remove all https capability from std.http when true. Any https request will error with `error.TlsInitializationFailed`. Solves #17051.
2023-10-10std.cstr: remove deprecated namespaceEric Joldasov
Followup to 0a868dacdd31b7d5c529a332da718683477a2505 . Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-09-14ComptimeStringMap: Add version that takes an equality functionRyan Liptak
This will allow users to construct e.g. a ComptimeStringMap that uses case-insensitive ASCII comparison. Note: the previous ComptimeStringMap API is unchanged (i.e. this does not break any existing code).
2023-09-08std: clean up top-level namespaces documentationWooster
This cleans up existing documentation, adds a bit more, and fixes some typos too.
2023-08-28std: Move `TailQueue` alias to correct namespaceJay Petacat
This fixes a mistake in PR #16996.
2023-08-27std: Rename `TailQueue` to `DoublyLinkedList`Jay Petacat
`TailQueue` was implemented as a doubly-linked list, but named after an abstract data type. This was inconsistent with `SinglyLinkedList`, which can be used to implement an abstract data type, but is still named after the implementation. Renaming `TailQueue` to `DoublyLinkedList` improves consistency between the two type names, and should help discoverability. `TailQueue` is now a deprecated alias of `DoublyLinkedList`. Related to issues #1629 and #8233.
2023-08-06autodoc: new layout (#16715)Loris Cro
* autodoc: init guide TOC work * autodoc: working guides toc navigation * autodoc: more improvements * autodoc: ui refinements * autodoc: new layout and init descriptions for namespaces in std.zig
2023-07-21std.json: Unify stringify and writeStream (#16405)Josh Wolfe
2023-03-17add BoundedArrayAligned (#14580)Motiejus Jakštys
This is useful for creating byte buffers of actually-different-things. Copied the argument order from `Allocator.alignedAlloc` I noted that `ArrayListAligned` is going out of it's way to not set the alignment at comptime when it is not specified. However, I was not able to do that the same way here, and good people on IRC, @ifreund in particular (thanks!) assured me that [N]T align(@alignOf(T)) is equivalent to [N]T
2023-03-14Move std.crypto.config options to std.options (#14906)Frank Denis
Options have been moved to a single namespace.
2023-03-09std.http: rework connection pool into its own typeNameless
2023-03-03std.process.Child: remove pid and handle, add idAndrew Kelley
Previously, this API had pid, to be used on POSIX systems, and handle, to be used on Windows. This commit unifies the API, defining an Id type that is either the pid or the HANDLE depending on the target OS. This commit also prepares for the future by allowing one to import via `std.process.Child` which is the fully qualified namespace that I intend to migrate to in the future.
2023-02-21std.RingBuffer: add (non-concurrent) RingBuffer implementationdweiller
2023-02-18use std_options for keep_sigpipe and existence of SIG.PIPE to check for supportJonathan Marler