---
name: "ucontext"
section: "3"
platform: "macos"
package: "libplatform"
version: "375.120.2"
release: "macOS 26.5"
platforms: ["freebsd", "macos"]
url: "https://new.carta.tech/ucontext"
---

# ucontext(3)

user thread context

## NAME

**ucontext** – user thread context

## LIBRARY

Standard C Library (libc, -lc)

## 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.

The *ucontext\_t* structure contains at least these fields:

- *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. If *uc\_link* is equal to NULL, then the process exits when this context returns.

The *uc\_mcontext* field is machine-dependent and should be treated as opaque by portable applications.

The following functions are defined to manipulate *ucontext\_t* structures:

-

  *int* **getcontext**(*ucontext\_t \**);

-

  *int* **setcontext**(*const ucontext\_t \**);

-

  *void* **makecontext**(*ucontext\_t \**, *void \*void*, *int*, *...*);

-

  *int* **swapcontext**(*ucontext\_t \**, *const ucontext\_t \**);

## SEE ALSO

[sigaltstack(2)](/sigaltstack/2.md), [getcontext(3)](/getcontext/3.md), [makecontext(3)](/makecontext/3.md)
