Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

makecontext, swapcontext - set up user context

&pagelevel(4)&pagelevel

Syntax

#include <ucontext.h>

void makecontext (ucontext_t *ucp, (void *func) (), int argc,...);
int swapcontext (ucontext_t *oucp, const ucontext_t *ucp); 

Description

These functions serve to implement a change of context between several control flows
within a user process.

makecontext() changes the context specified by ucp which was initialized via
getcontext(). If this context is activated with swapcontext() or setcontext() (see
getcontext()), the program execution is continued with the call of the function func.
The arguments which follow argc are passed to makecontext(). The integer value of argc
must correspond to the number of arguments that follow argc. Otherwise, the behavior is
undefined.

Before makecontext() is called, the context to be modified should be assigned a stack.
The structure element uc_link defines the context that is activated when the context
modified by makecontext() returns.

swapcontext() saves the current context in the context structure pointed to by oucp, and
sets the context to the context structure pointed to by ucp.

Return val.

0

-1

after successful execution of swapcontext().

if an error occurs. errno is set to indicate the type of the error.

Errors

These functions will fail if:

ENOMEM      ucp no longer has enough space in the stack to perform the operation.

See also

exit(), getcontext(), sigaction(), sigprocmask(), ucontext.h.