setcontext

setcontext is one of a family of C library functions (the others being getcontext, makecontext and swapcontext) used for context control.

The setcontext family allows the implementation in C of advanced control flow patterns such as iterators, fibers, and coroutines.

setcontext was specified in POSIX.1-2001 and the Single Unix Specification, version 2, but not all Unix-like operating systems provide them.

The function makecontext requires additional parameters to be type int, but the example passes pointers.

However, doing this is not guaranteed to be portable, is undefined according to the standards, and won't work on architectures where pointers are larger than ints.