Skip to content

Commit

Permalink
further changes from feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Mar 8, 2024
1 parent 7ff3bad commit 18c7350
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion library/std/src/sys/pal/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,8 @@ pub mod guard {
#[cfg(target_os = "netbsd")]
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
let mut ret = None;
// We do not need pthread_attr_init/pthread_attr_destroy
// instead we use `pthread_getattr_np` to initialise the thread's attribute
let mut attr: libc::pthread_attr_t = crate::mem::zeroed();
let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr);
if e == 0 {
Expand All @@ -816,7 +818,9 @@ pub mod guard {
// on netbsd, we need to take in account the guard size to push up
// the stack's address from the bottom.
assert_eq!(libc::pthread_attr_getguardsize(&attr, &mut guardsize), 0);
stackaddr = stackaddr.add(guardsize);
// Only hppa arch seems to support stack growing up to higher address
// (__MACHINE_STACK_GROWS_UP)
stackaddr = stackaddr.sub(guardsize);
ret = Some(stackaddr);
}
ret
Expand Down

0 comments on commit 18c7350

Please sign in to comment.