ucontext.ha (628B)
1 // SPDX-License-Identifier: MPL-2.0 2 // (c) Hare authors <https://harelang.org> 3 4 use rt; 5 6 // Returns the stack pointer from a ucontext. 7 fn uctx_sp(uctx: *opaque) uintptr = { 8 const uctx = uctx: *rt::ucontext; 9 return uctx.uc_mcontext.sc_regs.sp: uintptr; 10 }; 11 12 // Returns the instruction pointer from a ucontext. 13 fn uctx_ip(uctx: *opaque) uintptr = { 14 const uctx = uctx: *rt::ucontext; 15 return uctx.uc_mcontext.sc_regs.pc: uintptr; 16 }; 17 18 // Returns the current call frame from a ucontext. 19 fn uctx_frame(uctx: *opaque) stackframe = { 20 const uctx = uctx: *rt::ucontext; 21 return *(uctx.uc_mcontext.sc_regs.s0: uintptr: *stackframe); 22 };