mirror of
https://github.com/bdwgc/bdwgc-rust.git
synced 2026-06-17 02:50:13 -06:00
27 lines
602 B
Rust
27 lines
602 B
Rust
extern crate bdwgc_alloc;
|
|
extern crate coroutine;
|
|
|
|
use bdwgc_alloc::Allocator;
|
|
use coroutine::asymmetric::Coroutine;
|
|
use std::alloc::Layout;
|
|
|
|
#[global_allocator]
|
|
static GLOBAL_ALLOCATOR: Allocator = Allocator;
|
|
|
|
fn main() {
|
|
unsafe { Allocator::initialize() }
|
|
Allocator::disable_gc();
|
|
|
|
let handle = Coroutine::spawn(move |_, _| {
|
|
let bottom: u8 = 0;
|
|
unsafe { Allocator::set_stack_bottom(&bottom) }
|
|
Allocator::enable_gc();
|
|
|
|
loop {
|
|
unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
|
|
}
|
|
});
|
|
|
|
for _ in handle {}
|
|
}
|