---
name: "ucontext"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
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 \**);

-

  *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

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

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