mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-17 05:25:37 +03:00
Rewrite the exchange allocator to work without an active scheduler. #4457
This commit is contained in:
@@ -53,6 +53,8 @@ check_stack_canary(stk_seg *stk) {
|
||||
assert(stk->canary == canary_value && "Somebody killed the canary");
|
||||
}
|
||||
|
||||
// XXX: Duplication here between the local and exchange heap constructors
|
||||
|
||||
stk_seg *
|
||||
create_stack(memory_region *region, size_t sz) {
|
||||
size_t total_sz = sizeof(stk_seg) + sz;
|
||||
@@ -69,3 +71,20 @@ destroy_stack(memory_region *region, stk_seg *stk) {
|
||||
deregister_valgrind_stack(stk);
|
||||
region->free(stk);
|
||||
}
|
||||
|
||||
stk_seg *
|
||||
create_exchange_stack(rust_exchange_alloc *exchange, size_t sz) {
|
||||
size_t total_sz = sizeof(stk_seg) + sz;
|
||||
stk_seg *stk = (stk_seg *)exchange->malloc(total_sz, false);
|
||||
memset(stk, 0, sizeof(stk_seg));
|
||||
stk->end = (uintptr_t) &stk->data[sz];
|
||||
add_stack_canary(stk);
|
||||
register_valgrind_stack(stk);
|
||||
return stk;
|
||||
}
|
||||
|
||||
void
|
||||
destroy_exchange_stack(rust_exchange_alloc *exchange, stk_seg *stk) {
|
||||
deregister_valgrind_stack(stk);
|
||||
exchange->free(stk);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user