1.\" $NetBSD: ucontext.2,v 1.10 2018/02/27 10:09:42 uwe Exp $ 2.\" 3.\" Copyright (c) 2001 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Klaus Klein. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 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. 17.\" 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. 29.\" 30.Dd February 25, 2018 31.Dt UCONTEXT 2 32.Os 33.Sh NAME 34.Nm ucontext 35.Nd user context 36.Sh SYNOPSIS 37.In ucontext.h 38.Fn _UC_MACHINE_SP "&uc" 39.Fn _UC_MACHINE_FP "&uc" 40.Fn _UC_MACHINE_PC "&uc" 41.Fn _UC_MACHINE_INTRV "&uc" 42.Fn _UC_MACHINE_SET_PC "&uc" 43.Sh DESCRIPTION 44The 45.Vt ucontext_t 46is a structure type which is used to describe the context of a 47thread of control within the execution of a process. 48A thread's context includes its stack, saved registers, and list of 49blocked signals. 50.Pp 51The 52.Vt ucontext_t 53structure includes the following members: 54.Bd -literal -offset indent 55ucontext_t *uc_link 56sigset_t uc_sigmask 57stack_t uc_stack 58mcontext_t uc_mcontext 59.Ed 60.Pp 61The 62.Fa uc_link 63member points to the context that will be resumed after the function 64specified when modifying a context using 65.Xr makecontext 3 66has returned. 67If 68.Fa uc_link 69is a 70.Dv NULL 71pointer, then the context is the main context, 72and the process will exit with an exit status of 0 upon return. 73.Pp 74The 75.Fa uc_sigmask 76member is the set of signals that are blocked when the context is 77activated. 78Further information can be found in 79.Xr sigprocmask 2 . 80.Pp 81The 82.Fa uc_stack 83member defines the stack used by the context. 84Further information can be found in 85.Xr sigaltstack 2 . 86.Pp 87The 88.Fa uc_mcontext 89member defines the machine state associated with the context; 90it may consist of general registers, floating point registers 91and other machine-specific information. 92Its description is beyond the scope of this manual page; 93portable applications should not access this structure member. 94.Pp 95The following auxiliary macros are available to access some of that 96machine-specific information: 97.Bl -tag -width ".Fn _UC_MACHINE_SET_PC" -offset indent 98.It Fn _UC_MACHINE_SP 99\(em read stack pointer, 100.It Fn _UC_MACHINE_FP 101\(em read frame pointer (base pointer), 102.It Fn _UC_MACHINE_PC 103\(em read program counter, 104.It Fn _UC_MACHINE_INTRV 105\(em read integer return value, 106.It Fn _UC_MACHINE_SET_PC 107\(em write program counter. 108.El 109.Pp 110The frame pointer macro does not guarantee to retrieve a reliable value 111and should not be used in a code unless no other debugging format is 112easily accessible. 113A compiler might optimize the frame pointer register in a function, 114reusing it as a general purpose register storage 115.Fl ( fomit-frame-pointer ) 116or emit function prologues only before parts that need them 117.Fl ( fshrink-wrap ) . 118.Sh SEE ALSO 119.Xr _exit 2 , 120.Xr getcontext 2 , 121.Xr setcontext 2 , 122.Xr sigaltstack 2 , 123.Xr sigprocmask 2 , 124.Xr makecontext 3 , 125.Xr swapcontext 3 126.Sh STANDARDS 127The 128.Vt ucontext_t 129type conforms to 130.St -xsh5 131and 132.St -p1003.1-2001 . 133The 134.St -p1003.1-2008 135revision removed the 136.Vt ucontext_t 137from the specification. 138