OSDN Git Service

af427d2048e9eb5b3e26924553cd1a94f74de245
[linuxjm/LDP_man-pages.git] / release / 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 .SH 名前
40 setjmp, sigsetjmp \- 非局所的なジャンプのために、スタックコンテキスト (stack context) を保存する
41 .SH 書式
42 .B #include <setjmp.h>
43 .sp
44 .nf
45 .BI "int setjmp(jmp_buf " env );
46
47 .BI "int sigsetjmp(sigjmp_buf " env ", int " savesigs );
48 .fi
49 .sp
50 .in -4n
51 glibc 向けの機能検査マクロの要件
52 .RB ( feature_test_macros (7)
53 参照):
54 .in
55 .sp
56 .BR setjmp ():
57 「注意」参照。
58 .br
59 .BR sigsetjmp ():
60 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_C_SOURCE
61 .SH 説明
62 .BR setjmp ()
63
64 .BR longjmp (3)
65 は、プログラムの低レベルなサブルーチン
66 において、エラーや割り込みが発生した時の処理に便利である。
67 .BR setjmp ()
68 は、
69 .BR longjmp (3)
70 によって使われる \fIenv\fP に
71 スタックコンテキスト/スタック環境を保存する。
72 .BR setjmp ()
73 を呼び出した
74 関数が返るときに、そのスタックコンテキストは無効になる。
75 .P
76 .BR sigsetjmp ()
77
78 .BR setjmp ()
79 と同様である。
80 \fIsavesigs\fP が 0 以外の場合、
81 このプロセスの現在のシグナルマスクも \fIenv\fP に保存され、
82 このシグナルは後で
83 .BR siglongjmp (3)
84 がこの \fIenv\fP で実行された際に復元される。
85 .SH 返り値
86 直接返ってくるときは、
87 .BR setjmp ()
88
89 .BR sigsetjmp ()
90 は 0 を返し、保存したコンテキストを使って
91 .BR longjmp (3)
92
93 .BR siglongjmp (3)
94 から返ってくるときは 0 以外を返す。
95 .SH 準拠
96 .BR setjmp ()
97 は C89, C99, POSIX.1-2001 で規定されている。
98 .BR sigsetjmp ()
99 は POSIX.1-2001 で規定されている。
100 .SH 注意
101 POSIX は、
102 .BR setjmp ()
103 がシグナルマスクを保存すべきかどうかを規定していない。
104 System V では保存しない。
105 4.3BSD では保存する;
106 4.3BSD にはシグナルコンテキストを保存しない関数 \fB_setjmp\fP もある。
107 デフォルトでは、Linux/glibc は System V の振る舞いに従うが、
108 .B _BSD_SOURCE
109 機能検査マクロが定義され、
110 .BR _POSIX_SOURCE ,
111 .BR _POSIX_C_SOURCE ,
112 .BR _XOPEN_SOURCE ,
113 .BR _XOPEN_SOURCE_EXTENDED ,
114 .BR _GNU_SOURCE ,
115 .B _SVID_SOURCE
116 のいずれも定義されていない時は BSD の振る舞いとなる。
117
118 移植性のある形でシグナルマスクを保存および復元したいのなら、
119 .BR sigsetjmp ()
120
121 .BR siglongjmp (3)
122 を使うこと。
123 .P
124 .BR setjmp ()
125
126 .BR sigsetjmp ()
127 を使うと、プログラムは理解しづらく、保守しにくいものになる。
128 別の方法が可能なら、それを使うべきである。
129 .SH 関連項目
130 .BR longjmp (3),
131 .BR siglongjmp (3)