1 .\" $NetBSD: makecontext.3,v 1.9 2010/04/29 06:07:35 jruoho Exp $
3 .\" Copyright (c) 2001, 2009 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
36 .Nd manipulate user contexts
42 .Fn makecontext "ucontext_t *ucp" "void (*func)()" "int argc" ...
44 .Fn swapcontext "ucontext_t * restrict oucp" "ucontext_t * restrict ucp"
48 function modifies the object pointed to by
50 which has been initialized using
52 When this context is resumed using
56 program execution continues as if
58 had been called with the arguments specified after
64 must be equal to the number of integer arguments following it,
65 and must be equal to the number of integer arguments expected by
67 otherwise, the behavior is undefined.
69 Before being modified using
71 a stack must be allocated for the context (in the
73 member), and a context to resume after
75 has returned must be determined (pointed to by the
78 otherwise, the behavior is undefined.
81 is a null pointer, then the context is the main context,
82 and the process will exit with an exit status of 0 upon return.
86 function saves the current context in the object pointed to by
88 sets the current context to that specified in the object pointed to by
90 and resumes execution.
91 When a context saved by
95 execution will resume as if the corresponding invocation of
97 had just returned (successfully).
101 function returns no value.
105 returns a value of 0,
106 Otherwise, \-1 is returned and
108 is set to indicate the error.
112 function will fail if:
119 argument points to an invalid address.
121 The contents of the datum pointed to by
142 revision marked the functions
146 as obsolete, citing portability issues and recommending the use of
151 revision removed the functions from the specification.
154 The standard does not clearly define the type of integer arguments
159 portable applications should not rely on the implementation detail that
160 it may be possible to pass pointer arguments to functions.
162 This may be clarified in a future revision of the standard.
168 functions first appeared in
171 Due to limitations in the current pthread implementation,
173 should not be used in programs which link against the
175 library (whether threads are used or not).