aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2020-06-05 09:27:52 +0200
committerAndrew Kelley <andrew@ziglang.org>2020-06-09 00:22:34 -0400
commit660eef9a43dab695c4aa26330067ce72d375a1be (patch)
treed16237fc893e78339701335f68f4d82d3e894080 /doc
parent52b97eeef1fbb72f1b0bd5d466383cad13a67d54 (diff)
downloadzig-660eef9a43dab695c4aa26330067ce72d375a1be.tar.gz
zig-660eef9a43dab695c4aa26330067ce72d375a1be.zip
Document the builtins
Diffstat (limited to 'doc')
-rw-r--r--doc/langref.html.in40
1 files changed, 40 insertions, 0 deletions
diff --git a/doc/langref.html.in b/doc/langref.html.in
index ad5a688a04..6b14daad6e 100644
--- a/doc/langref.html.in
+++ b/doc/langref.html.in
@@ -7643,6 +7643,46 @@ mem.copy(u8, dest[0..byte_count], source[0..byte_count]);{#endsyntax#}</pre>
mem.set(u8, dest, c);{#endsyntax#}</pre>
{#header_close#}
+ {#header_open|@wasmMemorySize#}
+ <pre>{#syntax#}@wasmMemorySize(index: u32) u32{#endsyntax#}</pre>
+ <p>
+ This function returns the size of the Wasm memory identified by {#syntax#}index{#endsyntax#} as
+ an unsigned value in units of Wasm pages. Note that each Wasm page is 64KB in size.
+ </p>
+ <p>
+ This function is a low level intrinsic with no safety mechanisms usually useful for allocator
+ designers targeting Wasm. So unless you are writing a new allocator from scratch, you should use
+ something like {#syntax#}@import("std").heap.WasmAllocator{#endsyntax#}.
+ </p>
+ {#see_also|@wasmMemoryGrow#}
+ {#header_close#}
+
+ {#header_open|@wasmMemoryGrow#}
+ <pre>{#syntax#}@wasmMemoryGrow(index: u32, delta: u32) i32{#endsyntax#}</pre>
+ <p>
+ This function increases the size of the Wasm memory identified by {#syntax#}index{#endsyntax#} by
+ {#syntax#}delta{#endsyntax#} in units of unsigned number of Wasm pages. Note that each Wasm page
+ is 64KB in size. On success, returns previous memory size; on failure, if the allocation fails,
+ returns -1.
+ </p>
+ <p>
+ This function is a low level intrinsic with no safety mechanisms usually useful for allocator
+ designers targeting Wasm. So unless you are writing a new allocator from scratch, you should use
+ something like {#syntax#}@import("std").heap.WasmAllocator{#endsyntax#}.
+ </p>
+ {#code_begin|test#}
+const std = @import("std");
+const assert = std.debug.assert;
+
+test "@wasmMemoryGrow" {
+ var prev = @wasmMemorySize(0);
+ assert(prev == @wasmMemoryGrow(0, 1));
+ assert(prev + 1 == @wasmMemorySize(0));
+}
+ {#code_end#}
+ {#see_also|@wasmMemorySize#}
+ {#header_close#}
+
{#header_open|@mod#}
<pre>{#syntax#}@mod(numerator: T, denominator: T) T{#endsyntax#}</pre>
<p>