authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-06-05 09:27:52+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-06-09 00:22:34-04:00
log660eef9a43dab695c4aa26330067ce72d375a1be
treed16237fc893e78339701335f68f4d82d3e894080
parent52b97eeef1fbb72f1b0bd5d466383cad13a67d54

Document the builtins


1 files changed, 40 insertions(+), 0 deletions(-)

doc/langref.html.in+40
......@@ -7643,6 +7643,46 @@ mem.copy(u8, dest[0..byte_count], source[0..byte_count]);{#endsyntax#}</pre>
76437643mem.set(u8, dest, c);{#endsyntax#}</pre>
76447644 {#header_close#}
76457645
7646 {#header_open|@wasmMemorySize#}
7647 <pre>{#syntax#}@wasmMemorySize(index: u32) u32{#endsyntax#}</pre>
7648 <p>
7649 This function returns the size of the Wasm memory identified by {#syntax#}index{#endsyntax#} as
7650 an unsigned value in units of Wasm pages. Note that each Wasm page is 64KB in size.
7651 </p>
7652 <p>
7653 This function is a low level intrinsic with no safety mechanisms usually useful for allocator
7654 designers targeting Wasm. So unless you are writing a new allocator from scratch, you should use
7655 something like {#syntax#}@import("std").heap.WasmAllocator{#endsyntax#}.
7656 </p>
7657 {#see_also|@wasmMemoryGrow#}
7658 {#header_close#}
7659
7660 {#header_open|@wasmMemoryGrow#}
7661 <pre>{#syntax#}@wasmMemoryGrow(index: u32, delta: u32) i32{#endsyntax#}</pre>
7662 <p>
7663 This function increases the size of the Wasm memory identified by {#syntax#}index{#endsyntax#} by
7664 {#syntax#}delta{#endsyntax#} in units of unsigned number of Wasm pages. Note that each Wasm page
7665 is 64KB in size. On success, returns previous memory size; on failure, if the allocation fails,
7666 returns -1.
7667 </p>
7668 <p>
7669 This function is a low level intrinsic with no safety mechanisms usually useful for allocator
7670 designers targeting Wasm. So unless you are writing a new allocator from scratch, you should use
7671 something like {#syntax#}@import("std").heap.WasmAllocator{#endsyntax#}.
7672 </p>
7673 {#code_begin|test#}
7674const std = @import("std");
7675const assert = std.debug.assert;
7676
7677test "@wasmMemoryGrow" {
7678 var prev = @wasmMemorySize(0);
7679 assert(prev == @wasmMemoryGrow(0, 1));
7680 assert(prev + 1 == @wasmMemorySize(0));
7681}
7682 {#code_end#}
7683 {#see_also|@wasmMemorySize#}
7684 {#header_close#}
7685
76467686 {#header_open|@mod#}
76477687 <pre>{#syntax#}@mod(numerator: T, denominator: T) T{#endsyntax#}</pre>
76487688 <p>