]> git.saurik.com Git - apple/libplatform.git/blame - man/setjmp.3
libplatform-254.40.4.tar.gz
[apple/libplatform.git] / man / setjmp.3
CommitLineData
ada7c492
A
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.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" @(#)setjmp.3 8.1 (Berkeley) 6/4/93
37.\" $FreeBSD: src/lib/libc/gen/setjmp.3,v 1.9 2001/10/01 16:08:51 ru Exp $
38.\"
39.Dd June 4, 1993
40.Dt SETJMP 3
41.Os
42.Sh NAME
43.Nm _longjmp ,
44.Nm _setjmp ,
45.Nm longjmp ,
46.Nm longjmperror ,
47.Nm setjmp ,
48.Nm siglongjmp ,
49.Nm sigsetjmp
50.Nd non-local jumps
51.Sh LIBRARY
52.Lb libc
53.Sh SYNOPSIS
54.In setjmp.h
55.Ft void
56.Fo _longjmp
57.Fa "jmp_buf env"
58.Fa "int val"
59.Fc
60.Ft int
61.Fo _setjmp
62.Fa "jmp_buf env"
63.Fc
64.Ft void
65.Fo longjmp
66.Fa "jmp_buf env"
67.Fa "int val"
68.Fc
69.Ft void
70.Fo longjmperror
71.Fa void
72.Fc
73.Ft int
74.Fo setjmp
75.Fa "jmp_buf env"
76.Fc
77.Ft void
78.Fo siglongjmp
79.Fa "sigjmp_buf env"
80.Fa "int val"
81.Fc
82.Ft int
83.Fo sigsetjmp
84.Fa "sigjmp_buf env"
85.Fa "int savemask"
86.Fc
87.Sh DESCRIPTION
88The
89.Fn sigsetjmp ,
90.Fn setjmp ,
91and
92.Fn _setjmp
93functions save their calling environment in
94.Fa env .
95Each of these functions returns 0.
96.Pp
97The corresponding
98.Fn longjmp
99functions restore the environment saved by their most recent respective
100invocations
101of the
102.Fn setjmp
103function.
104They then return, so that program execution continues
105as if the corresponding invocation of the
106.Fn setjmp
107call had just returned the value specified by
108.Fa val ,
109instead of 0.
110.Pp
111Pairs of calls may be intermixed
112(i.e., both
113.Fn sigsetjmp
114and
115.Fn siglongjmp
116and
117.Fn setjmp
118and
119.Fn longjmp
120combinations may be used in the same program); however, individual
121calls may not (e.g. the
122.Fa env
123argument to
124.Fn setjmp
125may not be passed to
126.Fn siglongjmp ) .
127.Pp
128The
129.Fn longjmp
130routines may not be called after the routine which called the
131.Fn setjmp
132routines returns.
133.Pp
134All accessible objects have values as of the time
135.Fn longjmp
136routine was called, except that the values of objects of automatic storage
137invocation duration that do not have the
138.Em volatile
139type and have been changed between the
140.Fn setjmp
141invocation and
142.Fn longjmp
143call are indeterminate.
144.Pp
145The
146.Fn setjmp Ns / Ns Fn longjmp
147pairs save and restore the signal mask while
148.Fn _setjmp Ns / Ns Fn _longjmp
149pairs save and restore only the register set and the stack.
150(See
151.Fn sigprocmask 2 . )
152.Pp
153The
154.Fn sigsetjmp Ns / Ns Fn siglongjmp
155function
156pairs save and restore the signal mask if the argument
157.Fa savemask
158is non-zero; otherwise, only the register set and the stack are saved.
159.Sh ERRORS
160If the contents of the
161.Fa env
162are corrupted, or correspond to an environment that has already returned,
163the
164.Fn longjmp
165routine calls the routine
166.Fn longjmperror 3 .
167If
168.Fn longjmperror
169returns, the program is aborted (see
170.Xr abort 3 ) .
171The default version of
172.Fn longjmperror
173prints the message
174.Dq Li longjmp botch
175to standard error and returns.
176User programs wishing to exit more gracefully should write their own
177versions of
178.Fn longjmperror .
179.Sh SEE ALSO
180.Xr sigaction 2 ,
181.Xr sigaltstack 2 ,
182.Xr signal 3
183.Sh STANDARDS
184The
185.Fn setjmp
186and
187.Fn longjmp
188functions conform to
189.St -isoC .
190The
191.Fn sigsetjmp
192and
193.Fn siglongjmp
194functions conform to
195.St -p1003.1-88 .