wasm-utils/samples/contract3.rs

16 lines
388 B
Rust
Raw Normal View History

2017-04-20 17:00:52 +03:00
#![feature(link_args)]
#![feature(drop_types_in_const)]
#![no_main]
use std::slice;
2017-04-20 19:37:08 +03:00
#[link_args = "-s WASM=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s EXPORTED_FUNCTIONS=['_call']"]
2017-04-20 17:00:52 +03:00
extern {}
#[no_mangle]
pub fn call(input: *mut u8) {
2017-04-20 19:37:08 +03:00
let slice = unsafe { slice::from_raw_parts_mut(input, 8192) }; // 8kb input data
for i in 0..8192 {
2017-04-20 17:00:52 +03:00
slice[i] = slice[i] + 2;
}
}