OSDN Git Service

Convert release and draft pages to UTF-8.
[linuxjm/jm.git] / manual / LDP_man-pages / release / 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 .SH 名前
39 longjmp, siglongjmp \- 保存されたスタックコンテキスト (stack context)
40 への非局所的なジャンプ
41 .SH 書式
42 .nf
43 .B #include <setjmp.h>
44
45 .BI "void longjmp(jmp_buf " env ", int " val );
46
47 .BI "void siglongjmp(sigjmp_buf " env ", int " val );
48 .fi
49 .sp
50 .in -4n
51 glibc 向けの機能検査マクロの要件
52 .RB ( feature_test_macros (7)
53 参照):
54 .in
55 .sp
56 .BR siglongjmp ():
57 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_C_SOURCE
58 .SH 説明
59 .BR longjmp ()
60
61 .BR setjmp (3)
62 は、プログラムの低レベルなサブルーチンにおいて、
63 エラーや割り込みが発生した時の処理に便利である。
64 .BR longjmp ()
65 は、\fIenv\fP 引き数を指定して呼び出された最後の
66 .BR setjmp (3)
67 によって保存された環境を復元する。
68 .BR longjmp ()
69 の完了後、プログラムの実行は、まるで対応する
70 .BR setjmp (3)
71 の呼び出しが値 \fIval\fP で返って来たかように続行される。
72 .BR longjmp ()
73 は 0 を返すように指示することはできない。
74 二番目の引き数に 0 を指定して
75 .BR longjmp ()
76 が呼ばれた場合は、代わりに 1 が返されることになる。
77 .P
78 .BR siglongjmp ()
79 は、引き数 \fIenv\fP の型が異なる点以外は、
80 .BR longjmp ()
81 と同様である。
82 \fIenv\fP を保存した
83 .BR sigsetjmp (3)
84 が 0 以外の \fIsavesigs\fP フラグで呼び出されていた場合で、
85 かつ、その場合にのみ、
86 .BR siglongjmp (3)
87
88 .BR sigsetjmp (3)
89 より保存されていたシグナルマスクの復元を行う。
90 .SH 返り値
91 これらの関数が返ることはない。
92 .SH 準拠
93 .BR longjmp ()
94 は C89, C99, POSIX.1-2001 で規定されている。
95 .BR siglongjmp ()
96 は POSIX.1-2001 で規定されている。
97 .SH 注意
98 POSIX では、
99 .BR longjmp ()
100 がシグナルコンテキスト (signal context) を復元するかどうか規定されていない
101 .RB ( setjmp (3)
102 にも少し詳しい情報がある)。
103 移植性のある方法で、シグナルマスクを保存し復元させたい場合には、
104 .BR sigsetjmp (3)
105
106 .BR siglongjmp ()
107 を使うこと。
108 .P
109 以下の条件が全て成立する場合、
110 .BR longjmp ()
111 の呼び出しが行われた後の自動変数の値は未定義 (unspecified) となる。
112 .IP \(bu 3
113 その自動変数が、対応する
114 .BR setjmp (3)
115 呼び出しを行った関数のローカル変数である。
116 .IP \(bu
117 自動変数の値が
118 .BR setjmp (3)
119
120 .BR longjmp ()
121 の間で変更されている。
122 .IP \(bu
123 .I volatile
124 として宣言されていない。
125 .P
126 同様の注意が
127 .BR siglongjmp ()
128 にもあてはまる。
129 .P
130 .BR longjmp ()
131
132 .BR siglongjmp ()
133 を使うと、プログラムは理解しづらく、保守しにくいものになる。
134 別の方法が可能なら、それを使うべきである。
135 .SH 関連項目
136 .BR setjmp (3),
137 .BR sigsetjmp (3)