UCONTEXT(2)

πŸ“¦ version 11.0, in nixpkgs unstable

πŸ¦‹ ucontext(2) β€” user context πŸ¦‹

okay so bestie, this is the ucontext page from the System Calls Manual, section 2, and it is literally all about a thread’s user context ✨

πŸ’– NAME πŸ’–

ucontext β€” user context. concise, iconic, periodt πŸ’…

πŸŽ€ SYNOPSIS πŸŽ€

#include <ucontext.h>

_UC_MACHINE_SP(&uc);

_UC_MACHINE_FP(&uc);

_UC_MACHINE_PC(&uc);

_UC_MACHINE_INTRV(&uc);

_UC_MACHINE_SET_PC(&uc);

🌸 DESCRIPTION 🌸

The ucontext_t is a structure type, and it is used to describe the context of a thread of control within the execution of a process. A thread’s context includes its stack, saved registers, and list of blocked signals. no cap, that is the whole vibe 🫢

The ucontext_t structure includes the following members:

ucontext_t *uc_link
sigset_t    uc_sigmask
stack_t     uc_stack
mcontext_t  uc_mcontext
  • uc_link β€” points to the context that will be resumed after the function specified when modifying a context using makecontext(3) has returned. If uc_link is a NULL pointer, then the context is the main context, and the process will exit with an exit status of 0 upon return. main character energy, honestly πŸ‘‘
  • uc_sigmask β€” this is the set of signals that are blocked when the context is activated. further information can be found in sigprocmask(2). signal blocking, but make it fashion πŸ’…
  • uc_stack β€” defines the stack used by the context. further information can be found in sigaltstack(2). stack behavior, very demure, very mindful πŸŽ€
  • uc_mcontext β€” defines the machine state associated with the context; it may consist of general registers, floating point registers and other machine-specific information. its description is beyond the scope of this manual page; portable applications should not access this structure member. like, do not touch, bestie πŸ™ˆ
The following auxiliary macros are available to access some of that machine-specific information:
  • _UC_MACHINE_SP() β€” read stack pointer,
  • _UC_MACHINE_FP() β€” read frame pointer (base pointer),
  • _UC_MACHINE_PC() β€” read program counter,
  • _UC_MACHINE_INTRV() β€” read integer return value,
  • _UC_MACHINE_SET_PC() β€” write program counter.

The frame pointer macro does not guarantee to retrieve a reliable value and should not be used in a code unless no other debugging format is easily accessible. a compiler might optimize the frame pointer register in a function, reusing it as a general purpose register storage (-fomit-frame-pointer) or emit function prologues only before parts that need them (-fshrink-wrap). so like, it’s giving β€œuse at your own risk,” and the risk is real πŸ’€


πŸ”₯ SEE ALSO πŸ”₯

_exit(2), getcontext(2), setcontext(2), sigaltstack(2), sigprocmask(2), makecontext(3), swapcontext(3)

πŸ‘‘ STANDARDS πŸ‘‘

The ucontext_t type conforms to X/Open System Interfaces and Headers Issue 5 (β€œXSH5”) and IEEE Std 1003.1-2001 (β€œPOSIX.1”). The IEEE Std 1003.1-2008 (β€œPOSIX.1”) revision removed the ucontext_t from the specification. so yes, it was iconic, then it got removed from the spec β€” we love a complicated legacy 😭


this page is from Debian, dated February 25, 2018 β€” mwah, slay πŸ’‹βœ¨

πŸ“¦ where this page comes from