.\" Written by Michael Haardt, Fri Nov 25 14:51:42 MET 1994 .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, .\" USA. .\" .\" Added sigsetjmp, Sun Mar 2 22:03:05 EST 1997, jrv@vanzandt.mv.com .\" Modifications, Sun Feb 26 14:39:45 1995, faith@cs.unc.edu .\" .\" Japanese Version Copyright (c) 1998 Seiiti Obara .\" all rights reserved. .\" Translated 1998-05-27, Seiiti Obara .\" Updated 1999-12-11, Kentaro Shirakata .\" Modified 2007-12-20, Akihiro MOTOKI .\" Updated 2009-02-12, Kentaro Shirakata .\" .\"WORD: stack context スタックコンテキスト .\"WORD: signal masks シグナルマスク .\"WORD: signal context シグナルコンテキスト .\"WORD: low-level 低レベル .\" .TH SETJMP 3 2009-06-26 "" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O setjmp, sigsetjmp \- save stack context for nonlocal goto setjmp, sigsetjmp \- 非局所的なジャンプのために、スタックコンテキスト (stack context) を保存する .\"O .SH SYNOPSIS .SH 書式 .B #include .sp .nf .BI "int setjmp(jmp_buf " env ); .BI "int sigsetjmp(sigjmp_buf " env ", int " savesigs ); .fi .sp .in -4n .\"O Feature Test Macro Requirements for glibc (see .\"O .BR feature_test_macros (7)): glibc 向けの機能検査マクロの要件 .RB ( feature_test_macros (7) 参照): .in .sp .BR setjmp (): .\"O see NOTES. 「注意」参照。 .br .BR sigsetjmp (): _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_C_SOURCE .\"O .SH DESCRIPTION .SH 説明 .\"O .BR setjmp () .\"O and .\"O .BR longjmp (3) .\"O are useful for dealing with errors .\"O and interrupts encountered in a low-level subroutine of a program. .\"O .BR setjmp () .\"O saves the stack context/environment in \fIenv\fP for .\"O later use by .\"O .BR longjmp (3). .\"O The stack context will be invalidated .\"O if the function which called .\"O .BR setjmp () .\"O returns. .BR setjmp () と .BR longjmp (3) は、プログラムの低レベルなサブルーチン において、エラーや割り込みが発生した時の処理に便利である。 .BR setjmp () は、 .BR longjmp (3) によって使われる \fIenv\fP に スタックコンテキスト/スタック環境を保存する。 .BR setjmp () を呼び出した 関数が返るときに、そのスタックコンテキストは無効になる。 .P .\"O .BR sigsetjmp () .\"O is similar to .\"O .BR setjmp (). .\"O If, and only if, \fIsavesigs\fP is nonzero, .\"O the process's current signal mask is saved in \fIenv\fP .\"O and will be restored if a .\"O .BR siglongjmp (3) .\"O is later performed with this \fIenv\fP. .BR sigsetjmp () も .BR setjmp () と同様である。 \fIsavesigs\fP が 0 以外の場合、 このプロセスの現在のシグナルマスクも \fIenv\fP に保存され、 このシグナルは後で .BR siglongjmp (3) がこの \fIenv\fP で実行された際に復元される。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O .BR setjmp () .\"O and .\"O .BR sigsetjmp () .\"O return 0 if returning directly, and .\"O nonzero when returning from .\"O .BR longjmp (3) .\"O or .\"O .BR siglongjmp (3) .\"O using the saved context. 直接返ってくるときは、 .BR setjmp () と .BR sigsetjmp () は 0 を返し、保存したコンテキストを使って .BR longjmp (3) や .BR siglongjmp (3) から返ってくるときは 0 以外を返す。 .\"O .SH "CONFORMING TO" .SH 準拠 .\"O C89, C99, and POSIX.1-2001 specify .\"O .BR setjmp (). .\"O POSIX.1-2001 specifies .\"O .BR sigsetjmp (). .BR setjmp () は C89, C99, POSIX.1-2001 で規定されている。 .BR sigsetjmp () は POSIX.1-2001 で規定されている。 .\"O .SH NOTES .SH 注意 .\"O POSIX does not specify whether .\"O .BR setjmp () .\"O will save the signal mask. .\"O In System V it will not. .\"O In 4.3BSD it will, and there .\"O is a function \fB_setjmp\fP that will not. POSIX は、 .BR setjmp () がシグナルマスクを保存すべきかどうかを規定していない。 System V では保存しない。 4.3BSD では保存する; 4.3BSD にはシグナルコンテキストを保存しない関数 \fB_setjmp\fP もある。 .\"O By default, Linux/glibc follows the System V behavior, .\"O but the BSD behavior is provided if the .\"O .BR _BSD_SOURCE .\"O feature test macro is defined and none of .\"O .BR _POSIX_SOURCE , .\"O .BR _POSIX_C_SOURCE , .\"O .BR _XOPEN_SOURCE , .\"O .BR _XOPEN_SOURCE_EXTENDED , .\"O .BR _GNU_SOURCE , .\"O or .\"O .B _SVID_SOURCE .\"O is defined. デフォルトでは、Linux/glibc は System V の振る舞いに従うが、 .B _BSD_SOURCE 機能検査マクロが定義され、 .BR _POSIX_SOURCE , .BR _POSIX_C_SOURCE , .BR _XOPEN_SOURCE , .BR _XOPEN_SOURCE_EXTENDED , .BR _GNU_SOURCE , .B _SVID_SOURCE のいずれも定義されていない時は BSD の振る舞いとなる。 .\"O If you want to portably save and restore signal masks, use .\"O .BR sigsetjmp () .\"O and .\"O .BR siglongjmp (3). 移植性のある形でシグナルマスクを保存および復元したいのなら、 .BR sigsetjmp () と .BR siglongjmp (3) を使うこと。 .P .\"O .BR setjmp () .\"O and .\"O .BR sigsetjmp () .\"O make programs hard to understand .\"O and maintain. .\"O If possible an alternative should be used. .BR setjmp () や .BR sigsetjmp () を使うと、プログラムは理解しづらく、保守しにくいものになる。 別の方法が可能なら、それを使うべきである。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR longjmp (3), .BR siglongjmp (3)