| ... | ... | @@ -7754,7 +7754,7 @@ comptime { |
| 7754 | 7754 | {#header_close#} |
| 7755 | 7755 | |
| 7756 | 7756 | {#header_open|@atomicLoad#} |
| 7757 | | <pre>{#syntax#}@atomicLoad(comptime T: type, ptr: *const T, comptime ordering: builtin.AtomicOrder) T{#endsyntax#}</pre> |
| 7757 | <pre>{#syntax#}@atomicLoad(comptime T: type, ptr: *const T, comptime ordering: AtomicOrder) T{#endsyntax#}</pre> |
| 7758 | 7758 | <p> |
| 7759 | 7759 | This builtin function atomically dereferences a pointer to a {#syntax#}T{#endsyntax#} and returns the value. |
| 7760 | 7760 | </p> |
| ... | ... | @@ -7762,11 +7762,12 @@ comptime { |
| 7762 | 7762 | {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float, |
| 7763 | 7763 | an integer or an enum. |
| 7764 | 7764 | </p> |
| 7765 | <p>{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.</p> |
| 7765 | 7766 | {#see_also|@atomicStore|@atomicRmw|@fence|@cmpxchgWeak|@cmpxchgStrong#} |
| 7766 | 7767 | {#header_close#} |
| 7767 | 7768 | |
| 7768 | 7769 | {#header_open|@atomicRmw#} |
| 7769 | | <pre>{#syntax#}@atomicRmw(comptime T: type, ptr: *T, comptime op: builtin.AtomicRmwOp, operand: T, comptime ordering: builtin.AtomicOrder) T{#endsyntax#}</pre> |
| 7770 | <pre>{#syntax#}@atomicRmw(comptime T: type, ptr: *T, comptime op: AtomicRmwOp, operand: T, comptime ordering: AtomicOrder) T{#endsyntax#}</pre> |
| 7770 | 7771 | <p> |
| 7771 | 7772 | This builtin function dereferences a pointer to a {#syntax#}T{#endsyntax#} and atomically |
| 7772 | 7773 | modifies the value and returns the previous value. |
| ... | ... | @@ -7775,27 +7776,13 @@ comptime { |
| 7775 | 7776 | {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float, |
| 7776 | 7777 | an integer or an enum. |
| 7777 | 7778 | </p> |
| 7778 | | <p> |
| 7779 | | Supported values for the {#syntax#}op{#endsyntax#} parameter: |
| 7780 | | </p> |
| 7781 | | <ul> |
| 7782 | | <li>{#syntax#}.Xchg{#endsyntax#} - stores the operand unmodified. Supports enums, integers and floats.</li> |
| 7783 | | <li>{#syntax#}.Add{#endsyntax#} - for integers, twos complement wraparound addition. |
| 7784 | | Also supports {#link|Floats#}.</li> |
| 7785 | | <li>{#syntax#}.Sub{#endsyntax#} - for integers, twos complement wraparound subtraction. |
| 7786 | | Also supports {#link|Floats#}.</li> |
| 7787 | | <li>{#syntax#}.And{#endsyntax#} - bitwise and</li> |
| 7788 | | <li>{#syntax#}.Nand{#endsyntax#} - bitwise nand</li> |
| 7789 | | <li>{#syntax#}.Or{#endsyntax#} - bitwise or</li> |
| 7790 | | <li>{#syntax#}.Xor{#endsyntax#} - bitwise xor</li> |
| 7791 | | <li>{#syntax#}.Max{#endsyntax#} - stores the operand if it is larger. Supports integers and floats.</li> |
| 7792 | | <li>{#syntax#}.Min{#endsyntax#} - stores the operand if it is smaller. Supports integers and floats.</li> |
| 7793 | | </ul> |
| 7779 | <p>{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.</p> |
| 7780 | <p>{#syntax#}AtomicRmwOp{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicRmwOp{#endsyntax#}.</p> |
| 7794 | 7781 | {#see_also|@atomicStore|@atomicLoad|@fence|@cmpxchgWeak|@cmpxchgStrong#} |
| 7795 | 7782 | {#header_close#} |
| 7796 | 7783 | |
| 7797 | 7784 | {#header_open|@atomicStore#} |
| 7798 | | <pre>{#syntax#}@atomicStore(comptime T: type, ptr: *T, value: T, comptime ordering: builtin.AtomicOrder) void{#endsyntax#}</pre> |
| 7785 | <pre>{#syntax#}@atomicStore(comptime T: type, ptr: *T, value: T, comptime ordering: AtomicOrder) void{#endsyntax#}</pre> |
| 7799 | 7786 | <p> |
| 7800 | 7787 | This builtin function dereferences a pointer to a {#syntax#}T{#endsyntax#} and atomically stores the given value. |
| 7801 | 7788 | </p> |
| ... | ... | @@ -7803,6 +7790,7 @@ comptime { |
| 7803 | 7790 | {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float, |
| 7804 | 7791 | an integer or an enum. |
| 7805 | 7792 | </p> |
| 7793 | <p>{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.</p> |
| 7806 | 7794 | {#see_also|@atomicLoad|@atomicRmw|@fence|@cmpxchgWeak|@cmpxchgStrong#} |
| 7807 | 7795 | {#header_close#} |
| 7808 | 7796 | |
| ... | ... | @@ -8079,6 +8067,7 @@ fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_v |
| 8079 | 8067 | an integer or an enum. |
| 8080 | 8068 | </p> |
| 8081 | 8069 | <p>{#syntax#}@typeInfo(@TypeOf(ptr)).Pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p> |
| 8070 | <p>{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.</p> |
| 8082 | 8071 | {#see_also|@atomicStore|@atomicLoad|@atomicRmw|@fence|@cmpxchgWeak#} |
| 8083 | 8072 | {#header_close#} |
| 8084 | 8073 | |
| ... | ... | @@ -8110,6 +8099,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 8110 | 8099 | an integer or an enum. |
| 8111 | 8100 | </p> |
| 8112 | 8101 | <p>{#syntax#}@typeInfo(@TypeOf(ptr)).Pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p> |
| 8102 | <p>{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.</p> |
| 8113 | 8103 | {#see_also|@atomicStore|@atomicLoad|@atomicRmw|@fence|@cmpxchgStrong#} |
| 8114 | 8104 | {#header_close#} |
| 8115 | 8105 | |
| ... | ... | @@ -8400,9 +8390,7 @@ export fn @"A function name that is a complete sentence."() void {} |
| 8400 | 8390 | <p> |
| 8401 | 8391 | The {#syntax#}fence{#endsyntax#} function is used to introduce happens-before edges between operations. |
| 8402 | 8392 | </p> |
| 8403 | | <p> |
| 8404 | | {#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}. |
| 8405 | | </p> |
| 8393 | <p>{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.</p> |
| 8406 | 8394 | {#see_also|@atomicStore|@atomicLoad|@atomicRmw|@cmpxchgWeak|@cmpxchgStrong#} |
| 8407 | 8395 | {#header_close#} |
| 8408 | 8396 | |
| ... | ... | @@ -8810,7 +8798,7 @@ test "@wasmMemoryGrow" { |
| 8810 | 8798 | {#header_close#} |
| 8811 | 8799 | |
| 8812 | 8800 | {#header_open|@prefetch#} |
| 8813 | | <pre>{#syntax#}@prefetch(ptr: anytype, comptime options: std.builtin.PrefetchOptions) void{#endsyntax#}</pre> |
| 8801 | <pre>{#syntax#}@prefetch(ptr: anytype, comptime options: PrefetchOptions) void{#endsyntax#}</pre> |
| 8814 | 8802 | <p> |
| 8815 | 8803 | This builtin tells the compiler to emit a prefetch instruction if supported by the |
| 8816 | 8804 | target CPU. If the target CPU does not support the requested prefetch instruction, |
| ... | ... | @@ -8822,37 +8810,7 @@ test "@wasmMemoryGrow" { |
| 8822 | 8810 | address to prefetch. This function does not dereference the pointer, it is perfectly legal |
| 8823 | 8811 | to pass a pointer to invalid memory to this function and no illegal behavior will result. |
| 8824 | 8812 | </p> |
| 8825 | | <p> |
| 8826 | | The {#syntax#}options{#endsyntax#} argument is the following struct: |
| 8827 | | </p> |
| 8828 | | {#code_begin|syntax|builtin#} |
| 8829 | | /// This data structure is used by the Zig language code generation and |
| 8830 | | /// therefore must be kept in sync with the compiler implementation. |
| 8831 | | pub const PrefetchOptions = struct { |
| 8832 | | /// Whether the prefetch should prepare for a read or a write. |
| 8833 | | rw: Rw = .read, |
| 8834 | | /// The data's locality in an inclusive range from 0 to 3. |
| 8835 | | /// |
| 8836 | | /// 0 means no temporal locality. That is, the data can be immediately |
| 8837 | | /// dropped from the cache after it is accessed. |
| 8838 | | /// |
| 8839 | | /// 3 means high temporal locality. That is, the data should be kept in |
| 8840 | | /// the cache as it is likely to be accessed again soon. |
| 8841 | | locality: u2 = 3, |
| 8842 | | /// The cache that the prefetch should be preformed on. |
| 8843 | | cache: Cache = .data, |
| 8844 | | |
| 8845 | | pub const Rw = enum(u1) { |
| 8846 | | read, |
| 8847 | | write, |
| 8848 | | }; |
| 8849 | | |
| 8850 | | pub const Cache = enum(u1) { |
| 8851 | | instruction, |
| 8852 | | data, |
| 8853 | | }; |
| 8854 | | }; |
| 8855 | | {#code_end#} |
| 8813 | <p>{#syntax#}PrefetchOptions{#endsyntax#} can be found with {#syntax#}@import("std").builtin.PrefetchOptions{#endsyntax#}.</p> |
| 8856 | 8814 | {#header_close#} |
| 8857 | 8815 | |
| 8858 | 8816 | {#header_open|@ptrCast#} |
| ... | ... | @@ -8981,16 +8939,8 @@ test "foo" { |
| 8981 | 8939 | {#header_close#} |
| 8982 | 8940 | |
| 8983 | 8941 | {#header_open|@setFloatMode#} |
| 8984 | | <pre>{#syntax#}@setFloatMode(comptime mode: @import("std").builtin.FloatMode) void{#endsyntax#}</pre> |
| 8985 | | <p> |
| 8986 | | Sets the floating point mode of the current scope. Possible values are: |
| 8987 | | </p> |
| 8988 | | {#code_begin|syntax|FloatMode#} |
| 8989 | | pub const FloatMode = enum { |
| 8990 | | Strict, |
| 8991 | | Optimized, |
| 8992 | | }; |
| 8993 | | {#code_end#} |
| 8942 | <pre>{#syntax#}@setFloatMode(comptime mode: FloatMode) void{#endsyntax#}</pre> |
| 8943 | <p>Changes the current scope's rules about how floating point operations are defined.</p> |
| 8994 | 8944 | <ul> |
| 8995 | 8945 | <li> |
| 8996 | 8946 | {#syntax#}Strict{#endsyntax#} (default) - Floating point operations follow strict IEEE compliance. |
| ... | ... | @@ -9012,6 +8962,7 @@ pub const FloatMode = enum { |
| 9012 | 8962 | The floating point mode is inherited by child scopes, and can be overridden in any scope. |
| 9013 | 8963 | You can set the floating point mode in a struct or module scope by using a comptime block. |
| 9014 | 8964 | </p> |
| 8965 | <p>{#syntax#}FloatMode{#endsyntax#} can be found with {#syntax#}@import("std").builtin.FloatMode{#endsyntax#}.</p> |
| 9015 | 8966 | {#see_also|Floating Point Operations#} |
| 9016 | 8967 | {#header_close#} |
| 9017 | 8968 | |