OSDN Git Service

cf1c20cf7106f50246ed7e0c8ebbfb610fa46c0b
[linuxjm/LDP_man-pages.git] / draft / 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 .\" Japanese Version Copyright (c) 1998 Seiiti Obara
27 .\"     all rights reserved.
28 .\" Translated 1998-05-27, Seiiti Obara <SEO@ma1.seikyou.ne.jp>
29 .\" Updated 2009-02-24, Akihiro MOTOKI, LDP v3.19
30 .\"
31 .\"WORD:       stack context        スタックコンテキスト
32 .\"WORD:       signal masks         シグナルマスク
33 .\"WORD:       signal context       シグナルコンテキスト
34 .\"WORD:       flag                 フラグ
35 .\"WORD:       low-level            低レベル
36 .\"
37 .TH LONGJMP 3 2009-01-13 "" "Linux Programmer's Manual"
38 .\"O .SH NAME
39 .SH 名前
40 .\"O longjmp, siglongjmp \- nonlocal jump to a saved stack context
41 longjmp, siglongjmp \- 保存されたスタックコンテキスト (stack context)
42 への非局所的なジャンプ
43 .\"O .SH SYNOPSIS
44 .SH 書式
45 .nf
46 .B #include <setjmp.h>
47
48 .BI "void longjmp(jmp_buf " env ", int " val );
49
50 .BI "void siglongjmp(sigjmp_buf " env ", int " val );
51 .fi
52 .sp
53 .in -4n
54 .\"O Feature Test Macro Requirements for glibc (see
55 .\"O .BR feature_test_macros (7)):
56 glibc 向けの機能検査マクロの要件
57 .RB ( feature_test_macros (7)
58 参照):
59 .in
60 .sp
61 .BR siglongjmp ():
62 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_C_SOURCE
63 .\"O .SH DESCRIPTION
64 .SH 説明
65 .\"O .BR longjmp ()
66 .\"O and
67 .\"O .BR setjmp (3)
68 .\"O are useful for dealing with errors
69 .\"O and interrupts encountered in a low-level subroutine of a program.
70 .\"O .BR longjmp ()
71 .\"O restores the environment saved by the last call of
72 .\"O .BR setjmp (3)
73 .\"O with the corresponding \fIenv\fP argument.
74 .\"O After
75 .\"O .BR longjmp ()
76 .\"O is completed, program execution continues as if the
77 .\"O corresponding call of
78 .\"O .BR setjmp (3)
79 .\"O had just returned the value
80 .\"O \fIval\fP.
81 .\"O .BR longjmp ()
82 .\"O cannot cause 0 to be returned.
83 .\"O If
84 .\"O .BR longjmp ()
85 .\"O is invoked with a second argument of 0, 1 will be returned instead.
86 .BR longjmp ()
87
88 .BR setjmp (3)
89 は、プログラムの低レベルなサブルーチンにおいて、
90 エラーや割り込みが発生した時の処理に便利である。
91 .BR longjmp ()
92 は、\fIenv\fP 引き数を指定して呼び出された最後の
93 .BR setjmp (3)
94 によって保存された環境を復元する。
95 .BR longjmp ()
96 の完了後、プログラムの実行は、まるで対応する
97 .BR setjmp (3)
98 の呼び出しが値 \fIval\fP で返って来たかように続行される。
99 .BR longjmp ()
100 は 0 を返すように指示することはできない。
101 二番目の引き数に 0 を指定して
102 .BR longjmp ()
103 が呼ばれた場合は、代わりに 1 が返されることになる。
104 .P
105 .\"O .BR siglongjmp ()
106 .\"O is similar to
107 .\"O .BR longjmp ()
108 .\"O except for the type of
109 .\"O its \fIenv\fP argument.
110 .\"O If, and only if, the
111 .\"O .BR sigsetjmp (3)
112 .\"O call that set this
113 .\"O \fIenv\fP used a nonzero \fIsavesigs\fP flag,
114 .\"O .BR siglongjmp ()
115 .\"O also restores the signal mask that was saved by
116 .\"O .BR sigsetjmp (3).
117 .BR siglongjmp ()
118 は、引き数 \fIenv\fP の型が異なる点以外は、
119 .BR longjmp ()
120 と同様である。
121 \fIenv\fP を保存した
122 .BR sigsetjmp (3)
123 が 0 以外の \fIsavesigs\fP フラグで呼び出されていた場合で、
124 かつ、その場合にのみ、
125 .BR siglongjmp (3)
126
127 .BR sigsetjmp (3)
128 より保存されていたシグナルマスクの復元を行う。
129 .\"O .SH "RETURN VALUE"
130 .SH 返り値
131 .\"O These functions never return.
132 これらの関数が返ることはない。
133 .\"O .SH "CONFORMING TO"
134 .SH 準拠
135 .\"O C89, C99, and POSIX.1-2001 specify
136 .\"O .BR longjmp ().
137 .\"O POSIX.1-2001 specifies
138 .\"O .BR siglongjmp ().
139 .BR longjmp ()
140 は C89, C99, POSIX.1-2001 で規定されている。
141 .BR siglongjmp ()
142 は POSIX.1-2001 で規定されている。
143 .\"O .SH NOTES
144 .SH 注意
145 .\"O POSIX does not specify whether
146 .\"O .BR longjmp ()
147 .\"O will restore the signal context (see
148 .\"O .BR setjmp (3)
149 .\"O for some more details).
150 .\"O If you want to portably save and restore signal masks, use
151 .\"O .BR sigsetjmp ()
152 .\"O and
153 .\"O .BR siglongjmp ().
154 POSIX では、
155 .BR longjmp ()
156 がシグナルコンテキスト (signal context) を復元するかどうか規定されていない
157 .RB ( setjmp (3)
158 にも少し詳しい情報がある)。
159 移植性のある方法で、シグナルマスクを保存し復元させたい場合には、
160 .BR sigsetjmp (3)
161
162 .BR siglongjmp ()
163 を使うこと。
164 .P
165 .\"O The values of automatic variables are unspecified after a call to
166 .\"O .BR longjmp ()
167 .\"O if they meet all the following criteria:
168 以下の条件が全て成立する場合、
169 .BR longjmp ()
170 の呼び出しが行われた後の自動変数の値は未定義 (unspecified) となる。
171 .IP \(bu 3
172 .\"O they are local to the function that made the corresponding
173 .\"O .BR setjmp (3)
174 .\"O call;
175 その自動変数が、対応する
176 .BR setjmp (3)
177 呼び出しを行った関数のローカル変数である。
178 .IP \(bu
179 .\"O their values are changed between the calls to
180 .\"O .BR setjmp (3)
181 .\"O and
182 .\"O .BR longjmp ();
183 .\"O and
184 自動変数の値が
185 .BR setjmp (3)
186
187 .BR longjmp ()
188 の間で変更されている。
189 .IP \(bu
190 .\"O they are not declared as
191 .\"O .IR volatile .
192 .I volatile
193 として宣言されていない。
194 .P
195 .\"O Analogous remarks apply for
196 .\"O .BR siglongjmp ().
197 同様の注意が
198 .BR siglongjmp ()
199 にもあてはまる。
200 .P
201 .\"O .BR longjmp ()
202 .\"O and
203 .\"O .BR siglongjmp ()
204 .\"O make programs hard to
205 .\"O understand and maintain.
206 .\"O If possible an alternative should be used.
207 .BR longjmp ()
208
209 .BR siglongjmp ()
210 を使うと、プログラムは理解しづらく、保守しにくいものになる。
211 別の方法が可能なら、それを使うべきである。
212 .\"O .SH "SEE ALSO"
213 .SH 関連項目
214 .BR setjmp (3),
215 .BR sigsetjmp (3)