'\"macro stdmacro
.if n .pH g3c.makecontext @(#)makecontext	40.19 of 10/27/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} makecontext 3C "" "\&"
.if \nX=1 .ds x} makecontext 3C ""
.if \nX=2 .ds x} makecontext 3C "" "\&"
.if \nX=3 .ds x} makecontext "" "" "\&"
.TH \*(x}
.SH NAME
\f4makecontext\f1, \f4swapcontext\f1 \- manipulate user contexts
.SH SYNOPSIS
\f4#include <ucontext.h>\f1
.PP
\f4void makecontext (ucontext_t \(**ucp, (void(\(**)())func, int argc,...);\f1
.PP
\f4int swapcontext (ucontext_t \(**oucp, ucontext_t \(**ucp);\f1
.SH DESCRIPTION
.PP
These functions are useful for implementing user-level context switching
between multiple threads of control within a process.
.PP
\f4makecontext\fP modifies the context specified by \f2ucp\fP,
which has been initialized using \f4getcontext\fP; when this 
context is resumed using \f4swapcontext\fP or \f4setcontext\fP 
[see \f4getcontext\fP(2)], program execution continues by 
calling the function \f2func\fP, passing it the arguments
that follow \f2argc\fP in the 
\f4makecontext\fP call.
The integer value of \f2argc\f1 must match
the number of arguments that follow \f2argc\f1.
\%Otherwise the behavior is undefined.
.PP
\f4swapcontext\fP
saves the current context in the context structure pointed to by
.IR oucp\^
and sets the context to the context structure pointed to by
.IR ucp .
.PP
These functions will fail if either of the following is true:
.TP 15
\f4ENOMEM\fP
\f2ucp\f1 does not have enough stack left to complete the operation.
.TP
\f4EFAULT\fP
\f2ucp\f1 or \f2oucp\f1 points to an invalid address.
.SH "SEE ALSO"
\f4exit\fP(2), \f4getcontext\fP(2), \f4sigaction\fP(2), \f4sigprocmask\fP(2), \f4ucontext\fP(5).
.SH "DIAGNOSTICS"
On successful completion, \f4swapcontext\f1 return a value of zero.
Otherwise, a value of \-1 is returned and \f4errno\f1 is set to
indicate the error.
.SH NOTES
The size of the 
\f4ucontext_t\fP
structure may change in future releases.  To remain binary compatible, 
users of these features must always use \f4makecontext\fP or \f4getcontext\fP to
create new instances of them.
.\"	@(#)makecontext.3c	40.6 of 9/27/88
.Ee
