hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

ucontext.ha (581B)


      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.sc_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.sc_sepc: 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.sc_s[0]: uintptr: *stackframe);
     22 };