aboutsummaryrefslogtreecommitdiff
path: root/lib/std/atomic.zig
AgeCommit message (Collapse)Author
2025-10-23std.atomic: define cache line size for alpha, hppa, microblaze, shAlex Rønne Petersen
2025-10-23std.Target: add arceb and xtensaeb Cpu.Arch tagsAlex Rønne Petersen
2025-10-18std.atomic: define cache line size for or1kAlex Rønne Petersen
2025-08-25start adding big endian RISC-V supportAlex Rønne Petersen
The big endian RISC-V effort is mostly driven by MIPS (the company) which is pivoting to RISC-V, and presumably needs a big endian variant to fill the niche that big endian MIPS (the ISA) did. GCC already supports these targets, but LLVM support will only appear in 22; this commit just adds the necessary target knowledge and checks on our end.
2025-07-11Remove numerous things deprecated during the 0.14 release cycleLinus Groh
Basically everything that has a direct replacement or no uses left. Notable omissions: - std.ArrayHashMap: Too much fallout, needs a separate cleanup. - std.debug.runtime_safety: Too much fallout. - std.heap.GeneralPurposeAllocator: Lots of references to it remain, not a simple find and replace as "debug allocator" is not equivalent to "general purpose allocator". - std.io.Reader: Is being reworked at the moment. - std.unicode.utf8Decode(): No replacement, needs a new API first. - Manifest backwards compat options: Removal would break test data used by TestFetchBuilder. - panic handler needs to be a namespace: Many tests still rely on it being a function, needs a separate cleanup.
2025-06-05std.Target: Introduce Cpu convenience functions for feature tests.Alex Rønne Petersen
Before: * std.Target.arm.featureSetHas(target.cpu.features, .has_v7) * std.Target.x86.featureSetHasAny(target.cpu.features, .{ .sse, .avx, .cmov }) * std.Target.wasm.featureSetHasAll(target.cpu.features, .{ .atomics, .bulk_memory }) After: * target.cpu.has(.arm, .has_v7) * target.cpu.hasAny(.x86, &.{ .sse, .avx, .cmov }) * target.cpu.hasAll(.wasm, &.{ .atomics, .bulk_memory })
2025-02-22std.atomic: make cache_line const a comptime_intKiëd Llaentenn
This fixes potential issues and unintended coercions in other areas, such as std.ArrayList.
2025-01-12std.atomic: fix cache line size for RISC-VBen Grant
2024-11-13std.atomic: add a function to get the cache line size for a particular cpu ↵cancername
(#21956)
2024-10-06Merge pull request #21587 from alexrp/hexagon-portingAlex Rønne Petersen
Some initial `hexagon-linux` port work
2024-10-04remove `@fence` (#21585)David Rubin
closes #11650
2024-10-03std.atomic: Provide a more accurate cache_line value for hexagon v73+.Alex Rønne Petersen
2024-08-01Merge pull request #20870 from alexrp/target-cleanup-3Andrew Kelley
`std.Target`: Remove more dead OS/architecture tags
2024-08-01std.atomic: Don't lie to the compiler about memory clobbers in spinLoopHint().Alex Rønne Petersen
2024-07-30std.Target: Remove `sparcel` architecture tag.Alex Rønne Petersen
What is `sparcel`, you might ask? Good question! If you take a peek in the SPARC v8 manual, §2.2, it is quite explicit that SPARC v8 is a big-endian architecture. No little-endian or mixed-endian support to be found here. On the other hand, the SPARC v9 manual, in §3.2.1.2, states that it has support for mixed-endian operation, with big-endian mode being the default. Ok, so `sparcel` must just be referring to SPARC v9 running in little-endian mode, surely? Nope: * https://github.com/llvm/llvm-project/blob/40b4fd7a3e81d32b29364a1b15337bcf817659c0/llvm/lib/Target/Sparc/SparcTargetMachine.cpp#L226 * https://github.com/llvm/llvm-project/blob/40b4fd7a3e81d32b29364a1b15337bcf817659c0/llvm/lib/Target/Sparc/SparcTargetMachine.cpp#L104 So, `sparcel` in LLVM is referring to some sort of fantastical little-endian SPARC v8 architecture. I've scoured the internet and I can find absolutely no evidence that such a thing exists or has ever existed. In fact, I can find no evidence that a little-endian implementation of SPARC v9 ever existed, either. Or any SPARC version, actually! The support was added here: https://reviews.llvm.org/D8741 Notably, there is no mention whatsoever of what CPU this might be referring to, and no justification given for the "but some are little" comment added in the patch. My best guess is that this might have been some private exercise in creating a little-endian version of SPARC that never saw the light of day. Given that SPARC v8 explicitly doesn't support little-endian operation (let alone little-endian instruction encoding!), and no CPU is known to be implemented as such, I think it's very reasonable for us to just remove this support.
2024-07-29std.atomic: Implement specialized spinLoopHint() for more architectures.Alex Rønne Petersen
2024-07-29std.atomic: Define specialized cache_line values for more architectures.Alex Rønne Petersen
2024-07-28std.Target.Cpu.Arch: Remove the `aarch64_32` tag.Alex Rønne Petersen
This is a misfeature that we inherited from LLVM: * https://reviews.llvm.org/D61259 * https://reviews.llvm.org/D61939 (`aarch64_32` and `arm64_32` are equivalent.) I truly have no idea why this triple passed review in LLVM. It is, to date, the *only* tag in the architecture component that is not, in fact, an architecture. In reality, it is just an ILP32 ABI for AArch64 (*not* AArch32). The triples that use `aarch64_32` look like `aarch64_32-apple-watchos`. Yes, that triple is exactly what you think; it has no ABI component. They really, seriously did this. Since only Apple could come up with silliness like this, it should come as no surprise that no one else uses `aarch64_32`. Later on, a GNU ILP32 ABI for AArch64 was developed, and support was added to LLVM: * https://reviews.llvm.org/D94143 * https://reviews.llvm.org/D104931 Here, sanity seems to have prevailed, and a triple using this ABI looks like `aarch64-linux-gnu_ilp32` as you would expect. As can be seen from the diffs in this commit, there was plenty of confusion throughout the Zig codebase about what exactly `aarch64_32` was. So let's just remove it. In its place, we'll use `aarch64-watchos-ilp32`, `aarch64-linux-gnuilp32`, and so on. We'll then translate these appropriately when talking to LLVM. Hence, this commit adds the `ilp32` ABI tag (we already have `gnuilp32`).
2024-03-15bsd: debitrot AtomicOrder renamesMichael Dusan
- complete std.builtin.AtomicOrder renames that were missed from 6067d39522f
2024-03-11std.builtin: make atomic order fields lowercaseTristan Ross
2023-11-22rework std.atomicAndrew Kelley
* move std.atomic.Atomic to std.atomic.Value * fix incorrect argument order passed to testing.expectEqual * make the functions be a thin wrapper over the atomic builtins and stick to the naming conventions. * remove pointless functions loadUnchecked and storeUnchecked. Instead, name the field `raw` instead of `value` (which is redundant with the type name). * simplify the tests by not passing every possible combination. Many cases were iterating over every possible combinations but then not even using the for loop element value! * remove the redundant compile errors which are already implemented by the language itself. * remove dead x86 inline assembly. this should be implemented in the language if at all.
2023-11-22std: remove atomic.QueueAndrew Kelley
This was originally supposed to be a lock-free queue, but I gave up on that and made it be a thread-safe queue instead. Putting the mutex directly inside the queue data structure makes it non-composeable. Instead, the recommendation is to use a normal queue protected by an external mutex.
2023-11-22std: remove atomic.StackAndrew Kelley
This was originally supposed to be a lock-free stack, but I gave up on that and made it be a thread-safe stack which is implemented poorly using spin locks. Nobody should use this data structure. The alternative is a normal stack protected by a mutex.
2023-11-22std.atomic: remove some APIsAndrew Kelley
* remove `std.atomic.Ordering` - it is provided by the language with `std.builtin.AtomicOrder`. * remove `std.atomic.fence` - it is provided by the language with `@fence`. * remove `std.atomic.compilerFence` - if this is desired, it should be a language feature, not a standard library function with inline asm.
2023-04-21std: remove names from incorrectly named testsJacob Young
Tests that only reference decls for the purpose of analyzing more tests should be unnamed, otherwise trying to filter for just a referenced test can become impossible depending on the names.
2022-11-04all: rename i386 to x86Ali Chraghi
2022-04-19std.Thread.Futex improvements (#11464)protty
* atomic: cache_line * Thread: Futex rewrite + more native platform support * Futex: tests compile * Futex: compiles and runs test * Futex: broadcast test * Futex: fix PosixImpl for tests * Futex: fix compile errors for bsd platforms * Futex: review changes + fix timeout=0 + more comments
2021-10-04migrate from `std.Target.current` to `@import("builtin").target`Andrew Kelley
closes #9388 closes #9321
2021-08-24remove redundant license headers from zig standard libraryAndrew Kelley
We already have a LICENSE file that covers the Zig Standard Library. We no longer need to remind everyone that the license is MIT in every single file. Previously this was introduced to clarify the situation for a fork of Zig that made Zig's LICENSE file harder to find, and replaced it with their own license that required annual payments to their company. However that fork now appears to be dead. So there is no need to reinforce the copyright notice in every single file.
2021-07-20stage2: miscellaneous fixes for the branchAndrew Kelley
* Breaking language change: inline assembly must use string literal syntax. This is in preparation for inline assembly improvements that involve more integration with the Zig language. This means we cannot rely on text substitution. * Liveness: properly handle inline assembly and function calls with more than 3 operands. - More than 35 operands is not yet supported. This is a low priority to implement. - This required implementation in codegen.zig as well. * Liveness: fix bug causing incorrect tomb bits. * Sema: enable switch expressions that are evaluated at compile-time. - Runtime switch instructions still need to be reworked in this branch. There was a TODO left here (by me) with a suggestion to do some bigger changes as part of the AIR memory reworking. Now that time has come and I plan to honor the suggestion in a future commit before merging this branch. * AIR printing: fix missing ')' on alive instructions. We're back to "hello world" working for the x86_64 backend.
2021-06-01os/bits: remove duplicate `sockaddr_storage` for dragonflyKenta Iwasaki
2021-05-31std.sync.atomic: extended atomic helper functions (#8866)protty
- deprecates `std.Thread.spinLoopHint` and moves it to `std.atomic.spinLoopHint` - added an Atomic(T) generic wrapper type which replaces atomic.Bool and atomic.Int - in Atomic(T), selectively expose member functions depending on T and include bitwise atomic methods when T is an Integer - added fence() and compilerFence() to std.atomic
2020-12-31Year++Frank Denis
2020-11-19std: add std.atomic.Booldaurnimator
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2019-09-25mv std/ lib/Andrew Kelley
that's all this commit does. further commits will fix cli flags and such. see #2221