diff --git a/doc/langref.html.in b/doc/langref.html.in index 9fbdb08676..9cd1844e51 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -7754,7 +7754,7 @@ comptime { {#header_close#} {#header_open|@atomicLoad#} -
{#syntax#}@atomicLoad(comptime T: type, ptr: *const T, comptime ordering: builtin.AtomicOrder) T{#endsyntax#}
+ {#syntax#}@atomicLoad(comptime T: type, ptr: *const T, comptime ordering: AtomicOrder) T{#endsyntax#}
This builtin function atomically dereferences a pointer to a {#syntax#}T{#endsyntax#} and returns the value.
@@ -7762,11 +7762,12 @@ comptime { {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float, an integer or an enum. +{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.
{#see_also|@atomicStore|@atomicRmw|@fence|@cmpxchgWeak|@cmpxchgStrong#} {#header_close#} {#header_open|@atomicRmw#} -{#syntax#}@atomicRmw(comptime T: type, ptr: *T, comptime op: builtin.AtomicRmwOp, operand: T, comptime ordering: builtin.AtomicOrder) T{#endsyntax#}
+ {#syntax#}@atomicRmw(comptime T: type, ptr: *T, comptime op: AtomicRmwOp, operand: T, comptime ordering: AtomicOrder) T{#endsyntax#}
This builtin function dereferences a pointer to a {#syntax#}T{#endsyntax#} and atomically modifies the value and returns the previous value. @@ -7775,27 +7776,13 @@ comptime { {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float, an integer or an enum.
-- Supported values for the {#syntax#}op{#endsyntax#} parameter: -
-{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.
+{#syntax#}AtomicRmwOp{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicRmwOp{#endsyntax#}.
{#see_also|@atomicStore|@atomicLoad|@fence|@cmpxchgWeak|@cmpxchgStrong#} {#header_close#} {#header_open|@atomicStore#} -{#syntax#}@atomicStore(comptime T: type, ptr: *T, value: T, comptime ordering: builtin.AtomicOrder) void{#endsyntax#}
+ {#syntax#}@atomicStore(comptime T: type, ptr: *T, value: T, comptime ordering: AtomicOrder) void{#endsyntax#}
This builtin function dereferences a pointer to a {#syntax#}T{#endsyntax#} and atomically stores the given value.
@@ -7803,6 +7790,7 @@ comptime { {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float, an integer or an enum. +{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.
{#see_also|@atomicLoad|@atomicRmw|@fence|@cmpxchgWeak|@cmpxchgStrong#} {#header_close#} @@ -8079,6 +8067,7 @@ fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_v an integer or an enum.{#syntax#}@typeInfo(@TypeOf(ptr)).Pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}
+{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.
{#see_also|@atomicStore|@atomicLoad|@atomicRmw|@fence|@cmpxchgWeak#} {#header_close#} @@ -8110,6 +8099,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val an integer or an enum.{#syntax#}@typeInfo(@TypeOf(ptr)).Pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}
+{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.
{#see_also|@atomicStore|@atomicLoad|@atomicRmw|@fence|@cmpxchgStrong#} {#header_close#} @@ -8400,9 +8390,7 @@ export fn @"A function name that is a complete sentence."() void {}The {#syntax#}fence{#endsyntax#} function is used to introduce happens-before edges between operations.
-- {#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}. -
+{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.
{#see_also|@atomicStore|@atomicLoad|@atomicRmw|@cmpxchgWeak|@cmpxchgStrong#} {#header_close#} @@ -8810,7 +8798,7 @@ test "@wasmMemoryGrow" { {#header_close#} {#header_open|@prefetch#} -{#syntax#}@prefetch(ptr: anytype, comptime options: std.builtin.PrefetchOptions) void{#endsyntax#}
+ {#syntax#}@prefetch(ptr: anytype, comptime options: PrefetchOptions) void{#endsyntax#}
This builtin tells the compiler to emit a prefetch instruction if supported by the target CPU. If the target CPU does not support the requested prefetch instruction, @@ -8822,37 +8810,7 @@ test "@wasmMemoryGrow" { address to prefetch. This function does not dereference the pointer, it is perfectly legal to pass a pointer to invalid memory to this function and no illegal behavior will result.
-- The {#syntax#}options{#endsyntax#} argument is the following struct: -
- {#code_begin|syntax|builtin#} -/// This data structure is used by the Zig language code generation and -/// therefore must be kept in sync with the compiler implementation. -pub const PrefetchOptions = struct { - /// Whether the prefetch should prepare for a read or a write. - rw: Rw = .read, - /// The data's locality in an inclusive range from 0 to 3. - /// - /// 0 means no temporal locality. That is, the data can be immediately - /// dropped from the cache after it is accessed. - /// - /// 3 means high temporal locality. That is, the data should be kept in - /// the cache as it is likely to be accessed again soon. - locality: u2 = 3, - /// The cache that the prefetch should be preformed on. - cache: Cache = .data, - - pub const Rw = enum(u1) { - read, - write, - }; - - pub const Cache = enum(u1) { - instruction, - data, - }; -}; - {#code_end#} +{#syntax#}PrefetchOptions{#endsyntax#} can be found with {#syntax#}@import("std").builtin.PrefetchOptions{#endsyntax#}.
{#header_close#} {#header_open|@ptrCast#} @@ -8981,16 +8939,8 @@ test "foo" { {#header_close#} {#header_open|@setFloatMode#} -{#syntax#}@setFloatMode(comptime mode: @import("std").builtin.FloatMode) void{#endsyntax#}
- - Sets the floating point mode of the current scope. Possible values are: -
- {#code_begin|syntax|FloatMode#} -pub const FloatMode = enum { - Strict, - Optimized, -}; - {#code_end#} +{#syntax#}@setFloatMode(comptime mode: FloatMode) void{#endsyntax#}
+ Changes the current scope's rules about how floating point operations are defined.
{#syntax#}FloatMode{#endsyntax#} can be found with {#syntax#}@import("std").builtin.FloatMode{#endsyntax#}.
{#see_also|Floating Point Operations#} {#header_close#} diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 24c6036d60..56ee990c5f 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -102,14 +102,34 @@ pub const ReduceOp = enum { /// This data structure is used by the Zig language code generation and /// therefore must be kept in sync with the compiler implementation. pub const AtomicRmwOp = enum { + /// Exchange - store the operand unmodified. + /// Supports enums, integers, and floats. Xchg, + /// Add operand to existing value. + /// Supports integers and floats. + /// For integers, two's complement wraparound applies. Add, + /// Subtract operand from existing value. + /// Supports integers and floats. + /// For integers, two's complement wraparound applies. Sub, + /// Perform bitwise AND on existing value with operand. + /// Supports integers. And, + /// Perform bitwise NAND on existing value with operand. + /// Supports integers. Nand, + /// Perform bitwise OR on existing value with operand. + /// Supports integers. Or, + /// Perform bitwise XOR on existing value with operand. + /// Supports integers. Xor, + /// Store operand if it is larger than the existing value. + /// Supports integers and floats. Max, + /// Store operand if it is smaller than the existing value. + /// Supports integers and floats. Min, };