]> git.proxmox.com Git - rustc.git/blob - src/stdsimd/coresimd/wasm32.rs
New upstream version 1.26.0+dfsg1
[rustc.git] / src / stdsimd / coresimd / wasm32.rs
1 extern "C" {
2 #[link_name = "llvm.wasm.grow.memory.i32"]
3 fn llvm_grow_memory(pages: i32) -> i32;
4 #[link_name = "llvm.wasm.current.memory.i32"]
5 fn llvm_current_memory() -> i32;
6 }
7
8 /// Corresponding intrinsic to wasm's [`current_memory` instruction][instr]
9 ///
10 /// This function, when called, will return the current memory size in units of
11 /// pages.
12 ///
13 /// [instr]: https://github.com/WebAssembly/design/blob/master/Semantics.md#resizing
14 #[inline]
15 pub unsafe fn current_memory() -> i32 {
16 llvm_current_memory()
17 }
18
19 /// Corresponding intrinsic to wasm's [`grow_memory` instruction][instr]
20 ///
21 /// This function, when called, will attempt to grow the default linear memory
22 /// by the specified number of pages. If memory is successfully grown then the
23 /// previous size of memory, in pages, is returned. If memory cannot be grown
24 /// then -1 is returned.
25 ///
26 /// [instr]: https://github.com/WebAssembly/design/blob/master/Semantics.md#resizing
27 #[inline]
28 pub unsafe fn grow_memory(delta: i32) -> i32 {
29 llvm_grow_memory(delta)
30 }