UCONTEXT(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

UCONTEXT(3) β€” user thread context πŸ’…

okay so this is the Library Functions Manual page for UCONTEXT(3), aka ucontext β€” user thread context. yes bestie, we’re talking about the little struct that holds a whole user thread’s vibe. slay.


🌸 NAME 🌸

ucontext β€” user thread context. that’s the whole name section, periodt.

πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc). it’s giving β€œlink me and let’s go.” 🫢

✨ SYNOPSIS ✨

#include <ucontext.h>

πŸ¦‹ DESCRIPTION πŸ¦‹

The ucontext_t type is a structure type suitable for holding the context for a user thread of execution. A thread’s context includes its stack, saved registers, and list of blocked signals. literally the whole little survival kit for a thread. πŸ’–

The ucontext_t structure contains at least these fields β€” yes, at least, don’t come for me:

  • ucontext_t *uc_link β€” context to assume when this one returns
  • sigset_t uc_sigmask β€” signals being blocked
  • stack_t uc_stack β€” stack area
  • mcontext_t uc_mcontext β€” saved registers

The uc_link field points to the context to resume when this context’s entry point function returns. so if your main character entry point function dips, uc_link is the next context waiting to take over. If uc_link is equal to NULL, then the process exits when this context returns. no next context, no party, process says bye. 😭

The uc_mcontext field is machine-dependent and should be treated as opaque by portable applications. translation: do not peer into it like it’s a group chat screenshot; portable apps treat it as opaque. respect the mystery. πŸ™ˆ

The following functions are defined to manipulate ucontext_t structures β€” these are the little icons that actually do the work:

int getcontext(ucontext_t *);
ucontext_t * getcontextx(void);
int setcontext(const ucontext_t *);
void makecontext(ucontext_t *, void (*)(void), int, ...);
int swapcontext(ucontext_t *, const ucontext_t *);

πŸ‘€ SEE ALSO πŸ‘€

go read these next, bestie β€” they’re literally right there:

⭐ STANDARDS ⭐

The ucontext_t type conforms to X/Open System Interfaces and Headers Issue 5 (β€œXSH5”) and IEEE Std 1003.1-2001 (β€œPOSIX.1”). so yes, it has receipts. ✨

The IEEE Std 1003.1-2008 (β€œPOSIX.1”) revision removed the ucontext_t from the specification. that’s the spec revision tea, periodt.


xoxo, Debian β€” March 23, 2020 πŸ’–

πŸ“¦ where this page comes from