|Return to makecontext.3 CVS log||Up to [cvs.NetBSD.org] / src / lib / libc / gen|
|File: [cvs.NetBSD.org] / src / lib / libc / gen / makecontext.3 (download)
Revision 1.4, Tue Nov 18 23:03:26 2003 UTC (16 years ago) by uwe
s/modified/modifies/ in the description of makecontext().
.\" $NetBSD: makecontext.3,v 1.4 2003/11/18 23:03:26 uwe Exp $ .\" .\" Copyright (c) 2001 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation .\" by Klaus Klein. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the NetBSD .\" Foundation, Inc. and its contributors. .\" 4. Neither the name of The NetBSD Foundation nor the names of its .\" contributors may be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" .Dd June 13, 2001 .Dt MAKECONTEXT 3 .Os .Sh NAME .Nm makecontext , .Nm swapcontext .Nd manipulate user contexts .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In ucontext.h .Ft void .Fn makecontext "ucontext_t *ucp" "void (*func)()" "int argc" ... .Ft int .Fn swapcontext "ucontext_t * restrict oucp" "ucontext_t * restrict ucp" .Sh DESCRIPTION The .Fn makecontext function modifies the object pointed to by .Fa ucp , which has been initialized using .Xr getcontext 2 . When this context is resumed using .Fn swapcontext or .Xr setcontext 2 , program execution continues as if .Fa func had been called with the arguments specified after .Fa argc in the call of .Fn makecontext . The value of .Fa argc must be equal to the number of integer arguments following it, and must be equal to the number of integer arguments expected by .Fa func ; otherwise, the behavior is undefined. .Pp Before being modified using .Fn makecontext , a stack must be allocated for the context (in the .Fa uc_stack member), and a context to resume after .Fa func has returned must be determined (pointed to by the .Fa uc_link member); otherwise, the behavior is undefined. If .Fa uc_link is a null pointer, then the context is the main context, and the process will exit with an exit status of 0 upon return. .Pp The .Fn swapcontext function saves the current context in the object pointed to by .Fa oucp , sets the current context to that specified in the object pointed to by .Fa ucp , and resumes execution. When a context saved by .Fn swapcontext is restored using .Xr setcontext 2 , execution will resume as if the corresponding invocation of .Fn swapcontext had just returned (successfully). .Sh RETURN VALUES The .Fn makecontext function returns no value. .Pp On success, .Fn swapcontext returns a value of 0, Otherwise, \-1 is returned and .Va errno is set to indicate the error. .Sh ERRORS The .Fn swapcontext function will fail if: .Bl -tag -width Er .It Bq Er EFAULT The .Fa oucp argument points to an invalid address. .It Bq Er EFAULT The .Fa ucp argument points to an invalid address. .It Bq Er EINVAL The contents of the datum pointed to by .Fa ucp are invalid. .El .Sh SEE ALSO .Xr _exit 2 , .Xr getcontext 2 , .Xr setcontext 2 , .Xr ucontext 2 .Sh STANDARDS The .Fn makecontext and .Fn swapcontext functions conform to .St -xsh5 . .Pp .Bf -symbolic The standard does not clearly define the type of integer arguments passed to .Fa func via .Fn makecontext ; portable applications should not rely on the implementation detail that it may be possible to pass pointer arguments to functions. .Ef This may be clarified in a future revision of the standard. .Sh HISTORY The .Fn makecontext and .Fn swapcontext functions first appeared in .At V.4 .