MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / os_stack_low

Function os_stack_low

codegraph-kernel/src/stack.rs:66–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64/// Low (deepest) address of the calling thread's stack, from the OS.
65#[cfg(target_os = "linux")]
66fn os_stack_low() -> Option<usize> {
67 // SAFETY: plain pthread queries on the calling thread; `attr` is
68 // initialised by pthread_getattr_np and destroyed before returning.
69 unsafe {
70 let mut attr: libc::pthread_attr_t = std::mem::zeroed();
71 if libc::pthread_getattr_np(libc::pthread_self(), &mut attr) != 0 {
72 return None;
73 }
74 let mut addr: *mut libc::c_void = std::ptr::null_mut();
75 let mut size: libc::size_t = 0;
76 let rc = libc::pthread_attr_getstack(&attr, &mut addr, &mut size);
77 libc::pthread_attr_destroy(&mut attr);
78 if rc != 0 || addr.is_null() || size == 0 {
79 return None;
80 }
81 Some(addr as usize)
82 }
83}
84
85#[cfg(target_os = "macos")]
86fn os_stack_low() -> Option<usize> {

Callers 3

beginFunction · 0.85

Calls

no outgoing calls