Sha256: 374a28881f5e5dbf9db9b9e34929fb7a7e6f3910d782a6718f53ac269807b990

Contents?: true

Size: 1022 Bytes

Versions: 38

Compression:

Stored size: 1022 Bytes

Contents

extern crate psm;

psm::psm_stack_manipulation! {
    yes {
        use std::alloc;

        const STACK_SIZE: usize = 4096 * 64;
        const STACK_ALIGN: usize = 4096;

        fn main() {
            println!("current stack pointer is {:p}", psm::stack_pointer());
            unsafe {
                let new_stack = alloc::alloc(alloc::Layout::from_size_align(STACK_SIZE, STACK_ALIGN).unwrap());
                println!("new stack is between {:p} and {:p}", new_stack, new_stack.offset(STACK_SIZE as isize));
                psm::replace_stack(new_stack, STACK_SIZE, || {
                    println!("after replacement stack pointer is {:p}", psm::stack_pointer());
                    ::std::process::exit(0);
                });
            }
        }
    }
    no {
        fn main() {
            eprintln!("Stack manipulation not supported by this target");
        }
    }
}

#[test]
fn run_example() {
    // NOTE: intentionally out-of-processes, as the example exits with `process::exit(0)`.
    main()
}

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/psm-0.1.24/examples/replace_stack_1.rs
wasmtime-28.0.0 ./ext/cargo-vendor/psm-0.1.24/examples/replace_stack_1.rs
wasmtime-27.0.0 ./ext/cargo-vendor/psm-0.1.24/examples/replace_stack_1.rs
wasmtime-26.0.0 ./ext/cargo-vendor/psm-0.1.23/examples/replace_stack_1.rs
wasmtime-25.0.2 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-25.0.1 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-25.0.0 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-24.0.0 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-23.0.2 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-22.0.0 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-21.0.1 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-20.0.2 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-20.0.0 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-18.0.3 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-17.0.1 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-17.0.0 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-16.0.0 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-15.0.1 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-15.0.0 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs
wasmtime-14.0.4 ./ext/cargo-vendor/psm-0.1.21/examples/replace_stack_1.rs