OSDN Git Service

6cf3cec7c431f4b510a67085f3480470a274ce1e
[linuxjm/LDP_man-pages.git] / draft / man3 / setjmp.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 sigsetjmp, 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 1999-12-11, Kentaro Shirakata <argrath@ub32.org>
30 .\" Modified 2007-12-20, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
31 .\" Updated 2009-02-12, Kentaro Shirakata <argrath@ub32.org>
32 .\"
33 .\"WORD:       stack context        スタックコンテキスト
34 .\"WORD:       signal masks         シグナルマスク
35 .\"WORD:       signal context       シグナルコンテキスト
36 .\"WORD:       low-level            低レベル
37 .\"
38 .TH SETJMP 3 2009-06-26 "" "Linux Programmer's Manual"
39 .\"O .SH NAME
40 .SH 名前
41 .\"O setjmp, sigsetjmp \- save stack context for nonlocal goto
42 setjmp, sigsetjmp \- 非局所的なジャンプのために、スタックコンテキスト (stack context) を保存する
43 .\"O .SH SYNOPSIS
44 .SH 書式
45 .B #include <setjmp.h>
46 .sp
47 .nf
48 .BI "int setjmp(jmp_buf " env );
49
50 .BI "int sigsetjmp(sigjmp_buf " env ", int " savesigs );
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 setjmp ():
62 .\"O see NOTES.
63 「注意」参照。
64 .br
65 .BR sigsetjmp ():
66 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_C_SOURCE
67 .\"O .SH DESCRIPTION
68 .SH 説明
69 .\"O .BR setjmp ()
70 .\"O and
71 .\"O .BR longjmp (3)
72 .\"O are useful for dealing with errors
73 .\"O and interrupts encountered in a low-level subroutine of a program.
74 .\"O .BR setjmp ()
75 .\"O saves the stack context/environment in \fIenv\fP for
76 .\"O later use by
77 .\"O .BR longjmp (3).
78 .\"O The stack context will be invalidated
79 .\"O if the function which called
80 .\"O .BR setjmp ()
81 .\"O returns.
82 .BR setjmp ()
83
84 .BR longjmp (3)
85 は、プログラムの低レベルなサブルーチン
86 において、エラーや割り込みが発生した時の処理に便利である。
87 .BR setjmp ()
88 は、
89 .BR longjmp (3)
90 によって使われる \fIenv\fP に
91 スタックコンテキスト/スタック環境を保存する。
92 .BR setjmp ()
93 を呼び出した
94 関数が返るときに、そのスタックコンテキストは無効になる。
95 .P
96 .\"O .BR sigsetjmp ()
97 .\"O is similar to
98 .\"O .BR setjmp ().
99 .\"O If, and only if, \fIsavesigs\fP is nonzero,
100 .\"O the process's current signal mask is saved in \fIenv\fP
101 .\"O and will be restored if a
102 .\"O .BR siglongjmp (3)
103 .\"O is later performed with this \fIenv\fP.
104 .BR sigsetjmp ()
105
106 .BR setjmp ()
107 と同様である。
108 \fIsavesigs\fP が 0 以外の場合、
109 このプロセスの現在のシグナルマスクも \fIenv\fP に保存され、
110 このシグナルは後で
111 .BR siglongjmp (3)
112 がこの \fIenv\fP で実行された際に復元される。
113 .\"O .SH "RETURN VALUE"
114 .SH 返り値
115 .\"O .BR setjmp ()
116 .\"O and
117 .\"O .BR sigsetjmp ()
118 .\"O return 0 if returning directly, and
119 .\"O nonzero when returning from
120 .\"O .BR longjmp (3)
121 .\"O or
122 .\"O .BR siglongjmp (3)
123 .\"O using the saved context.
124 直接返ってくるときは、
125 .BR setjmp ()
126
127 .BR sigsetjmp ()
128 は 0 を返し、保存したコンテキストを使って
129 .BR longjmp (3)
130
131 .BR siglongjmp (3)
132 から返ってくるときは 0 以外を返す。
133 .\"O .SH "CONFORMING TO"
134 .SH 準拠
135 .\"O C89, C99, and POSIX.1-2001 specify
136 .\"O .BR setjmp ().
137 .\"O POSIX.1-2001 specifies
138 .\"O .BR sigsetjmp ().
139 .BR setjmp ()
140 は C89, C99, POSIX.1-2001 で規定されている。
141 .BR sigsetjmp ()
142 は POSIX.1-2001 で規定されている。
143 .\"O .SH NOTES
144 .SH 注意
145 .\"O POSIX does not specify whether
146 .\"O .BR setjmp ()
147 .\"O will save the signal mask.
148 .\"O In System V it will not.
149 .\"O In 4.3BSD it will, and there
150 .\"O is a function \fB_setjmp\fP that will not.
151 POSIX は、
152 .BR setjmp ()
153 がシグナルマスクを保存すべきかどうかを規定していない。
154 System V では保存しない。
155 4.3BSD では保存する;
156 4.3BSD にはシグナルコンテキストを保存しない関数 \fB_setjmp\fP もある。
157 .\"O By default, Linux/glibc follows the System V behavior,
158 .\"O but the BSD behavior is provided if the
159 .\"O .BR _BSD_SOURCE
160 .\"O feature test macro is defined and none of
161 .\"O .BR _POSIX_SOURCE ,
162 .\"O .BR _POSIX_C_SOURCE ,
163 .\"O .BR _XOPEN_SOURCE ,
164 .\"O .BR _XOPEN_SOURCE_EXTENDED ,
165 .\"O .BR _GNU_SOURCE ,
166 .\"O or
167 .\"O .B _SVID_SOURCE
168 .\"O is defined.
169 デフォルトでは、Linux/glibc は System V の振る舞いに従うが、
170 .B _BSD_SOURCE
171 機能検査マクロが定義され、
172 .BR _POSIX_SOURCE ,
173 .BR _POSIX_C_SOURCE ,
174 .BR _XOPEN_SOURCE ,
175 .BR _XOPEN_SOURCE_EXTENDED ,
176 .BR _GNU_SOURCE ,
177 .B _SVID_SOURCE
178 のいずれも定義されていない時は BSD の振る舞いとなる。
179
180 .\"O If you want to portably save and restore signal masks, use
181 .\"O .BR sigsetjmp ()
182 .\"O and
183 .\"O .BR siglongjmp (3).
184 移植性のある形でシグナルマスクを保存および復元したいのなら、
185 .BR sigsetjmp ()
186
187 .BR siglongjmp (3)
188 を使うこと。
189 .P
190 .\"O .BR setjmp ()
191 .\"O and
192 .\"O .BR sigsetjmp ()
193 .\"O make programs hard to understand
194 .\"O and maintain.
195 .\"O If possible an alternative should be used.
196 .BR setjmp ()
197
198 .BR sigsetjmp ()
199 を使うと、プログラムは理解しづらく、保守しにくいものになる。
200 別の方法が可能なら、それを使うべきである。
201 .\"O .SH "SEE ALSO"
202 .SH 関連項目
203 .BR longjmp (3),
204 .BR siglongjmp (3)