Add makecontext(3) from Klaus Klein.
This commit is contained in:
parent
95893ccc7b
commit
9b5abffe9d
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile.inc,v 1.117 2003/01/18 11:23:53 thorpej Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.118 2003/01/21 12:39:08 wiz Exp $
|
||||
# from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
|
||||
|
||||
# gen sources
|
||||
|
@ -49,7 +49,7 @@ MAN+= alarm.3 arc4random.3 basename.3 bswap.3 clock.3 confstr.3 \
|
|||
humanize_number.3 initgroups.3 isalnum.3 isalpha.3 isascii.3 \
|
||||
isblank.3 iscntrl.3 isdigit.3 isgraph.3 isinf.3 islower.3 isprint.3 \
|
||||
ispunct.3 isspace.3 isupper.3 isxdigit.3 ldexp.3 lockf.3 \
|
||||
_lwp_makecontext.3 \
|
||||
_lwp_makecontext.3 makecontext.3 \
|
||||
modf.3 nice.3 nlist.3 pause.3 popen.3 psignal.3 pwcache.3 \
|
||||
raise.3 realpath.3 scandir.3 setjmp.3 setmode.3 \
|
||||
setproctitle.3 shquote.3 sighold.3 sigignore.3 siginterrupt.3 \
|
||||
|
@ -96,6 +96,7 @@ MLINKS+=getttyent.3 endttyent.3 getttyent.3 getttynam.3 getttyent.3 setttyent.3
|
|||
MLINKS+=getusershell.3 endusershell.3 getusershell.3 setusershell.3
|
||||
MLINKS+=glob.3 globfree.3
|
||||
MLINKS+=isinf.3 isnan.3
|
||||
MLINKS+=makecontext.3 swapcontext.3
|
||||
MLINKS+=popen.3 pclose.3
|
||||
MLINKS+=psignal.3 sys_siglist.3 psignal.3 sys_signame.3
|
||||
MLINKS+=pwcache.3 user_from_uid.3 pwcache.3 group_from_gid.3
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
.\" $NetBSD: makecontext.3,v 1.1 2003/01/21 12:39:08 wiz 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
|
||||
.Fd #include \*[Lt]ucontext.h\*[Gt]
|
||||
.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 modified 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 5
|
||||
.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 .
|
Loading…
Reference in New Issue