]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - lib/libc/gen/setjmp.3
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / lib / libc / gen / setjmp.3
1 .\" Copyright (c) 1990, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to Berkeley by
5 .\" the American National Standards Committee X3, on Information
6 .\" Processing Systems.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)setjmp.3    8.1 (Berkeley) 6/4/93
33 .\" $FreeBSD$
34 .\"
35 .Dd June 4, 1993
36 .Dt SETJMP 3
37 .Os
38 .Sh NAME
39 .Nm sigsetjmp ,
40 .Nm siglongjmp ,
41 .Nm setjmp ,
42 .Nm longjmp ,
43 .Nm _setjmp ,
44 .Nm _longjmp ,
45 .Nm longjmperror
46 .Nd non-local jumps
47 .Sh LIBRARY
48 .Lb libc
49 .Sh SYNOPSIS
50 .In setjmp.h
51 .Ft int
52 .Fn sigsetjmp "sigjmp_buf env" "int savemask"
53 .Ft void
54 .Fn siglongjmp "sigjmp_buf env" "int val"
55 .Ft int
56 .Fn setjmp "jmp_buf env"
57 .Ft void
58 .Fn longjmp "jmp_buf env" "int val"
59 .Ft int
60 .Fn _setjmp "jmp_buf env"
61 .Ft void
62 .Fn _longjmp "jmp_buf env" "int val"
63 .Ft void
64 .Fn longjmperror void
65 .Sh DESCRIPTION
66 The
67 .Fn sigsetjmp ,
68 .Fn setjmp ,
69 and
70 .Fn _setjmp
71 functions save their calling environment in
72 .Fa env .
73 Each of these functions returns 0.
74 .Pp
75 The corresponding
76 .Fn longjmp
77 functions restore the environment saved by their most recent respective
78 invocations
79 of the
80 .Fn setjmp
81 function.
82 They then return so that program execution continues as if the corresponding
83 invocation of the
84 .Fn setjmp
85 call had just returned the value specified by
86 .Fa val ,
87 instead of 0.
88 .Pp
89 Pairs of calls may be intermixed, i.e., both
90 .Fn sigsetjmp
91 and
92 .Fn siglongjmp
93 and
94 .Fn setjmp
95 and
96 .Fn longjmp
97 combinations may be used in the same program, however, individual
98 calls may not, e.g.\& the
99 .Fa env
100 argument to
101 .Fn setjmp
102 may not be passed to
103 .Fn siglongjmp .
104 .Pp
105 The
106 .Fn longjmp
107 routines may not be called after the routine which called the
108 .Fn setjmp
109 routines returns.
110 .Pp
111 All accessible objects have values as of the time
112 .Fn longjmp
113 routine was called, except that the values of objects of automatic storage
114 invocation duration that do not have the
115 .Vt volatile
116 type and have been changed between the
117 .Fn setjmp
118 invocation and
119 .Fn longjmp
120 call are indeterminate.
121 .Pp
122 The
123 .Fn setjmp Ns / Ns Fn longjmp
124 pairs save and restore the signal mask while
125 .Fn _setjmp Ns / Ns Fn _longjmp
126 pairs save and restore only the register set and the stack.
127 (See
128 .Fn sigprocmask 2 . )
129 .Pp
130 The
131 .Fn sigsetjmp Ns / Ns Fn siglongjmp
132 function
133 pairs save and restore the signal mask if the argument
134 .Fa savemask
135 is non-zero, otherwise only the register set and the stack are saved.
136 .Sh ERRORS
137 If the contents of the
138 .Fa env
139 are corrupted, or correspond to an environment that has already returned,
140 the
141 .Fn longjmp
142 routine calls the routine
143 .Fn longjmperror 3 .
144 If
145 .Fn longjmperror
146 returns the program is aborted (see
147 .Xr abort 3 ) .
148 The default version of
149 .Fn longjmperror
150 prints the message
151 .Dq Li longjmp botch
152 to standard error and returns.
153 User programs wishing to exit more gracefully should write their own
154 versions of
155 .Fn longjmperror .
156 .Sh SEE ALSO
157 .Xr sigaction 2 ,
158 .Xr sigaltstack 2 ,
159 .Xr signal 3
160 .Sh STANDARDS
161 The
162 .Fn setjmp
163 and
164 .Fn longjmp
165 functions conform to
166 .St -isoC .
167 The
168 .Fn sigsetjmp
169 and
170 .Fn siglongjmp
171 functions conform to
172 .St -p1003.1-88 .