OSDN Git Service

(split) LDP: Update original to LDP v3.38.
[linuxjm/LDP_man-pages.git] / original / man3 / longjmp.3
1 .\" Written by Michael Haardt, Fri Nov 25 14:51:42 MET 1994
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
12 .\"
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 .\" GNU General Public License for more details.
17 .\"
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
21 .\" USA.
22 .\"
23 .\" Added siglongjmp, Sun Mar  2 22:03:05 EST 1997, jrv@vanzandt.mv.com
24 .\" Modifications, Sun Feb 26 14:39:45 1995, faith@cs.unc.edu
25 .\" "
26 .TH LONGJMP 3 2009-01-13 "" "Linux Programmer's Manual"
27 .SH NAME
28 longjmp, siglongjmp \- nonlocal jump to a saved stack context
29 .SH SYNOPSIS
30 .nf
31 .B #include <setjmp.h>
32
33 .BI "void longjmp(jmp_buf " env ", int " val );
34
35 .BI "void siglongjmp(sigjmp_buf " env ", int " val );
36 .fi
37 .sp
38 .in -4n
39 Feature Test Macro Requirements for glibc (see
40 .BR feature_test_macros (7)):
41 .in
42 .sp
43 .BR siglongjmp ():
44 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_C_SOURCE
45 .SH DESCRIPTION
46 .BR longjmp ()
47 and
48 .BR setjmp (3)
49 are useful for dealing with errors
50 and interrupts encountered in a low-level subroutine of a program.
51 .BR longjmp ()
52 restores the environment saved by the last call of
53 .BR setjmp (3)
54 with the corresponding \fIenv\fP argument.
55 After
56 .BR longjmp ()
57 is completed, program execution continues as if the
58 corresponding call of
59 .BR setjmp (3)
60 had just returned the value
61 \fIval\fP.
62 .BR longjmp ()
63 cannot cause 0 to be returned.
64 If
65 .BR longjmp ()
66 is invoked with a second argument of 0, 1 will be returned instead.
67 .P
68 .BR siglongjmp ()
69 is similar to
70 .BR longjmp ()
71 except for the type of
72 its \fIenv\fP argument.
73 If, and only if, the
74 .BR sigsetjmp (3)
75 call that set this
76 \fIenv\fP used a nonzero \fIsavesigs\fP flag,
77 .BR siglongjmp ()
78 also restores the signal mask that was saved by
79 .BR sigsetjmp (3).
80 .SH "RETURN VALUE"
81 These functions never return.
82 .SH "CONFORMING TO"
83 C89, C99, and POSIX.1-2001 specify
84 .BR longjmp ().
85 POSIX.1-2001 specifies
86 .BR siglongjmp ().
87 .SH NOTES
88 POSIX does not specify whether
89 .BR longjmp ()
90 will restore the signal context (see
91 .BR setjmp (3)
92 for some more details).
93 If you want to portably save and restore signal masks, use
94 .BR sigsetjmp (3)
95 and
96 .BR siglongjmp ().
97 .P
98 The values of automatic variables are unspecified after a call to
99 .BR longjmp ()
100 if they meet all the following criteria:
101 .IP \(bu 3
102 they are local to the function that made the corresponding
103 .BR setjmp (3)
104 call;
105 .IP \(bu
106 their values are changed between the calls to
107 .BR setjmp (3)
108 and
109 .BR longjmp ();
110 and
111 .IP \(bu
112 they are not declared as
113 .IR volatile .
114 .P
115 Analogous remarks apply for
116 .BR siglongjmp ().
117 .P
118 .BR longjmp ()
119 and
120 .BR siglongjmp ()
121 make programs hard to
122 understand and maintain.
123 If possible an alternative should be used.
124 .SH "SEE ALSO"
125 .BR setjmp (3),
126 .BR sigsetjmp (3)