NetBSD/share/man/man2/ucontext.2

138 lines
4.2 KiB
Groff
Raw Normal View History

.\" $NetBSD: ucontext.2,v 1.10 2018/02/27 10:09:42 uwe Exp $
2003-01-21 15:43:13 +03:00
.\"
.\" 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.
.\"
.\" 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 February 25, 2018
.Dt UCONTEXT 2
2003-01-21 15:43:13 +03:00
.Os
.Sh NAME
.Nm ucontext
.Nd user context
.Sh SYNOPSIS
.In ucontext.h
.Fn _UC_MACHINE_SP "&uc"
.Fn _UC_MACHINE_FP "&uc"
.Fn _UC_MACHINE_PC "&uc"
.Fn _UC_MACHINE_INTRV "&uc"
.Fn _UC_MACHINE_SET_PC "&uc"
2003-01-21 15:43:13 +03:00
.Sh DESCRIPTION
2010-04-28 17:23:02 +04:00
The
.Vt ucontext_t
2003-01-21 15:43:13 +03:00
is a structure type which is used to describe the context of a
thread of control within the execution of a process.
2010-04-28 17:23:02 +04:00
A thread's context includes its stack, saved registers, and list of
blocked signals.
2003-01-21 15:43:13 +03:00
.Pp
2010-04-28 17:23:02 +04:00
The
.Vt ucontext_t
structure includes the following members:
.Bd -literal -offset indent
2010-04-28 17:23:02 +04:00
ucontext_t *uc_link
sigset_t uc_sigmask
stack_t uc_stack
mcontext_t uc_mcontext
2003-01-21 15:43:13 +03:00
.Ed
.Pp
The
.Fa uc_link
member points to the context that will be resumed after the function
specified when modifying a context using
.Xr makecontext 3
has returned.
If
.Fa uc_link
2010-04-28 17:23:02 +04:00
is a
.Dv NULL
pointer, then the context is the main context,
2003-01-21 15:43:13 +03:00
and the process will exit with an exit status of 0 upon return.
.Pp
The
.Fa uc_sigmask
member is the set of signals that are blocked when the context is
activated.
Further information can be found in
.Xr sigprocmask 2 .
.Pp
The
.Fa uc_stack
member defines the stack used by the context.
Further information can be found in
.Xr sigaltstack 2 .
.Pp
The
.Fa uc_mcontext
member defines the machine state associated with the context;
it may consist of general registers, floating point registers
2006-02-25 05:28:55 +03:00
and other machine-specific information.
2003-01-21 15:43:13 +03:00
Its description is beyond the scope of this manual page;
portable applications should not access this structure member.
.Pp
2018-02-25 20:45:40 +03:00
The following auxiliary macros are available to access some of that
machine-specific information:
.Bl -tag -width ".Fn _UC_MACHINE_SET_PC" -offset indent
.It Fn _UC_MACHINE_SP
\(em read stack pointer,
.It Fn _UC_MACHINE_FP
\(em read frame pointer (base pointer),
.It Fn _UC_MACHINE_PC
\(em read program counter,
.It Fn _UC_MACHINE_INTRV
\(em read integer return value,
2018-02-25 20:45:40 +03:00
.It Fn _UC_MACHINE_SET_PC
\(em write program counter.
.El
.Pp
The frame pointer macro does not guarantee to retrieve a reliable value
and should not be used in a code unless no other debugging format is
easily accessible.
A compiler might optimize the frame pointer register in a function,
2018-02-25 20:37:05 +03:00
reusing it as a general purpose register storage
.Fl ( fomit-frame-pointer )
or emit function prologues only before parts that need them
2018-02-25 20:37:05 +03:00
.Fl ( fshrink-wrap ) .
2003-01-21 15:43:13 +03:00
.Sh SEE ALSO
.Xr _exit 2 ,
.Xr getcontext 2 ,
.Xr setcontext 2 ,
.Xr sigaltstack 2 ,
.Xr sigprocmask 2 ,
2003-01-21 15:43:13 +03:00
.Xr makecontext 3 ,
.Xr swapcontext 3
.Sh STANDARDS
The
.Vt ucontext_t
2003-01-21 15:43:13 +03:00
type conforms to
.St -xsh5
2003-01-21 15:43:13 +03:00
and
.St -p1003.1-2001 .
The
.St -p1003.1-2008
revision removed the
.Vt ucontext_t
from the specification.