Skip to content

Commit

Permalink
macOS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fasterthanlime committed Oct 20, 2024
1 parent 29ccf1e commit 4f8951d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions merde_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ impl StackInfo {

let thread = pthread_self();
let stack_addr = pthread_get_stackaddr_np(thread) as u64;
let stack_size = pthread_get_stacksize_np(thread) as u64;
let size = pthread_get_stacksize_np(thread) as u64;

Self {
stack_base: stack_addr - stack_size,
stack_size,
highest_address: stack_addr,
size,
}
}

Expand Down Expand Up @@ -169,9 +169,13 @@ impl StackInfo {
let stack_var: u64 = 0;
let stack_top = &stack_var as *const u64;

self.size.checked_sub(
self.highest_address.checked_sub(stack_top as u64).expect("we assume the stack grows down")
).expect("we assume we haven't exhausted the whole stack")
self.size
.checked_sub(
self.highest_address
.checked_sub(stack_top as u64)
.expect("we assume the stack grows down"),
)
.expect("we assume we haven't exhausted the whole stack")
}
}

Expand Down

0 comments on commit 4f8951d

Please sign in to comment.