aboutsummaryrefslogtreecommitdiff
path: root/lib/std/heap.zig
AgeCommit message (Collapse)Author
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-23std.heap: define page size for alpha-netbsdAlex Rønne Petersen
2025-10-23std.heap: define page size for hppa, sh on NetBSDAlex Rønne Petersen
2025-10-23std.heap: define page size for alpha, hppa, sh on OpenBSDAlex Rønne Petersen
2025-10-23std.heap: define page size for alpha, hppa, microblaze, sh on LinuxAlex Rønne Petersen
2025-10-23std.Target: add arceb and xtensaeb Cpu.Arch tagsAlex Rønne Petersen
2025-10-18std.heap: define min/max page size for or1k-linuxAlex Rønne Petersen
2025-10-02Coff2: create a new linker from scratchJacob Young
2025-08-20std.c.darwin: cleanup, expose everything in std.cJustus Klausecker
This mainly just moves stuff around. Justifications for other changes: * `KEVENT.FLAGS` is backed by `c_uint` because that's what the `kevent64` flags param takes (according to the 'latest' manpage from 2008) * `MACH_RCV_NOTIFY` is a legacy name and `MACH_RCV_OVERWRITE` is deprecated (xnu/osfmk/mach/message.h), so I removed them. They were 0 anyway and thus couldn't be represented as a packed struct field. * `MACH.RCV` and `MACH.SEND` are technically the same 'type' because they can both be supplied at the same time to `mach_msg`. I decided to still keep them separate because naming works out better that way and all flags except for `MACH_MSG_STRICT_REPLY` aren't shared anyway. Both are part of a packed union `mach_msg_option_t` which supplies a helper function to combine the two types. * `PT` is backed by `c_int` because that's what `ptrace` takes as a request arg (according to the latest manpage from 2015)
2025-08-11std.ArrayList: make unmanaged the defaultAndrew Kelley
2025-08-03zig fmt: apply new cast builtin orderJustus Klausecker
2025-07-30std: Add serenity to more OS checksLinus Groh
2025-07-09std: refactor to use Alignment.ofAndrew Kelley
2025-04-13std: eradicate u29 and embrace std.mem.AlignmentAndrew Kelley
2025-03-26Allocator.create: properly handle alignment for zero-sized types (#21864)Kendall Condon
2025-03-02add parentheses in std.heap.page_size_minrpkak
2025-02-25std.heap.page_size_min: relax freestanding restrictionAndrew Kelley
x86_64 and aarch64 have safe values for page_size_min
2025-02-17std.Target: Remove functions that just wrap component functions.Alex Rønne Petersen
Functions like isMinGW() and isGnuLibC() have a good reason to exist: They look at multiple components of the target. But functions like isWasm(), isDarwin(), isGnu(), etc only exist to save 4-8 characters. I don't think this is a good enough reason to keep them, especially given that: * It's not immediately obvious to a reader whether target.isDarwin() means the same thing as target.os.tag.isDarwin() precisely because isMinGW() and similar functions *do* look at multiple components. * It's not clear where we would draw the line. The logical conclusion before this commit would be to also wrap Arch.isX86(), Os.Tag.isSolarish(), Abi.isOpenHarmony(), etc... this obviously quickly gets out of hand. * It's nice to just have a single correct way of doing something.
2025-02-17Fix build failure in sbrk allocator, caused by #20511schtvn
2025-02-10std.ArrayList: popOrNull() -> pop() [v2] (#22720)Meghan Denny
2025-02-07don't try to test SmpAllocator in single threaded modeAndrew Kelley
2025-02-07std.heap: test smp_allocatorAndrew Kelley
2025-02-07add std.heap.SmpAllocatorAndrew Kelley
An allocator intended to be used in -OReleaseFast mode when multi-threading is enabled.
2025-02-06std.heap: fix wrong deprecation dateAndrew Kelley
2025-02-06std.heap: rename GeneralPurposeAllocator to DebugAllocatorAndrew Kelley
2025-02-06std.heap: remove HeapAllocatorAndrew Kelley
Windows-only, depends on kernel32 in violation of zig std lib policy, and redundant with other cross-platform APIs that perform the same functionality.
2025-02-06std.heap: update Windows HeapAllocatorAndrew Kelley
2025-02-06std: fix compilation under -lcAndrew Kelley
2025-02-06std.heap.ThreadSafeAllocator: update to new Allocator APIAndrew Kelley
2025-02-06std.heap: delete LoggingAllocator and friendsAndrew Kelley
I don't think these belong in std, at least not in their current form. If someone wants to add these back I'd like to review the patch before it lands. Reverts 629e2e784495dd8ac91493fa7bb11e1772698e42
2025-02-06std: update to new Allocator APIAndrew Kelley
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-01-29delete std.heap.WasmPageAllocatorAndrew Kelley
This allocator has no purpose since it cannot truly fulfill the role of page allocation, and std.heap.wasm_allocator is better both in terms of performance and code size. This commit redefines `std.heap.page_allocator` to be less strict: "On operating systems that support memory mapping, this allocator makes a syscall directly for every allocation and free. Otherwise, it falls back to the preferred singleton for the target. Thread-safe." This now matches how it was actually being implemented, and matches its use sites - which are mainly as the backing allocator for `std.heap.ArenaAllocator`.
2025-01-16x86_64: implement switch jump tablesJacob Young
2024-10-04Remove old deprecated symbols in std (#21584)PauloCampana
Also, actually run tests inside std/tar/writer.zig
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-03-19extract std.posix from std.osAndrew Kelley
closes #5019
2024-03-11std.builtin: make atomic order fields lowercaseTristan Ross
2024-03-10std: expose Config struct of GeneralPurposeAllocatorTechatrix
2024-02-25std.heap.raw_c_allocator: use malloc_size for resizeAndrew Kelley
std.heap.c_allocator was already doing this, however, std.heap.raw_c_allocator, which asserts no allocations more than 16 bytes aligned, was not. The zig compiler uses std.heap.raw_c_allocator, so it is affected by this.
2024-02-01std: eliminate some uses of `usingnamespace`mlugg
This eliminates some simple usages of `usingnamespace` in the standard library. This construct may in future be removed from the language, and is generally an inappropriate way to formulate code. It is also problematic for incremental compilation, which may not initially support projects using it. I wasn't entirely sure what the appropriate namespacing for the types in `std.os.uefi.tables` would be, so I ofted to preserve the current namespacing, meaning this is not a breaking change. It's possible some of the moved types should instead be namespaced under `BootServices` etc, but this can be a future enhancement.
2024-01-16byos: Ease `GeneralPurposeAllocator` integrationJay Petacat
These changes enable me to use `GeneralPurposeAllocator` with my "Bring Your Own OS" package. The previous checks for a freestanding target have been expanded to `@hasDecl` checks. - `root.os.heap.page_allocator` is used if it exists. - `debug.isValidMemory` only calls `os.msync` if it's supported.
2024-01-09std.heap: add runtime safety for calling `stackFallback(N).get` multiple timesVeikka Tuominen
Closes #16344
2023-11-19lib: correct unnecessary uses of 'var'mlugg
2023-08-06std: remove some unused imports (#16710)Zachary Raineri
2023-08-02std: add SbrkAllocator and use it for Plan 9Jacob G-W
Implements issue #6451. This was needed to support allocation on Plan 9 and now other operating systems like DOS can also use it. It is a modified version of the WasmAllocator since wasm also uses a sbrk-esque allocation system. This commit also adds the necessary system bits for sbrk to work on plan 9.
2023-07-22std.json: support parsing json at comptime using FixedBufferAllocator (#16488)Josh Wolfe
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
2023-06-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>