.\" Copyright 2008 Michael Kerrisk .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" Japanese Version Copyright (c) 2008 Akihiro MOTOKI .\" all rights reserved. .\" Translated 2008-08-21, Akihiro MOTOKI , LDP v3.04 .\" .\" .TH RANDOM_R 3 2008-03-07 "GNU" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O random_r, srandom_r, initstate_r, setstate_r \- reentrant .\"O random number generator random_r, srandom_r, initstate_r, setstate_r \- リエントラントな 乱数生成器 .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .sp .BI "int random_r(struct random_data *" buf ", int32_t *" result ); .BI "int srandom_r(unsigned int " seed ", struct random_data *" buf ); .BI "int initstate_r(unsigned int " seed ", char *" statebuf , .BI " size_t " statelen ", struct random_data *" buf ); .br .BI "int setstate_r(char *" statebuf ", struct random_data *" buf ); .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 .ad l .BR random_r (), .BR srandom_r (), .BR initstate_r (), .BR setstate_r (): .RS 4 _SVID_SOURCE || _BSD_SOURCE .RE .ad b .\"O .SH DESCRIPTION .SH 説明 .\"O These functions are the reentrant equivalents .\"O of the functions described in .\"O .BR random (3). .\"O They are suitable for use in multithreaded programs where each thread .\"O needs to obtain an independent, reproducible sequence of random numbers. これらの関数は、 .BR random (3) で説明されている関数のリエントラント版で、等価な機能を持つ。 これらは、独立した再現可能な乱数列を各スレッドが得る必要があるような マルチスレッド・プログラムでの使用に適している。 .\"O The .\"O .BR random_r () .\"O function is like .\"O .BR random (3), .\"O except that instead of using state information maintained .\"O in a global variable, .\"O it uses the state information in the argument pointed to by .\"O .IR buf . .\"O The generated random number is returned in the argument .\"O .IR result . .BR random_r () 関数は .BR random (3) と同様だが、 大域変数 (global variable) で管理される状態情報を使うのではなく、 .I buf が指す引き数に格納された状態情報を使う。 生成された乱数は引き数 .I result に格納されて返される。 .\"O The .\"O .BR srandom_r () .\"O function is like .\"O .BR srandom (3), .\"O except that it initializes the seed for the random number generator .\"O whose state is maintained in the object pointed to by .\"O .IR buf , .\"O instead of the seed associated with the global state variable. .BR srandom_r () 関数は .BR srandom (3) と同様だが、 大域変数で管理される状態に対応する乱数生成器の種ではなく、 .I buf が指すオブジェクトで管理される状態に対応する乱数生成器の種を 初期化する。 .\"O The .\"O .BR initstate_r () .\"O function is like .\"O .BR initstate (3) .\"O except that it initializes the state in the object pointed to by .\"O .IR buf , .\"O rather than initializing the global state variable. .BR initstate_r () 関数は .BR initstate (3) と同様だが、大域変数で管理される状態を初期化するのではなく、 .I buf が指すオブジェクト内の状態を初期化する。 .\"O The .\"O .BR setstate_r () .\"O function is like .\"O .BR setstate (3) .\"O except that it modifies the state in the object pointer to by .\"O .IR buf , .\"O rather than modifying the global state variable. .BR setstate_r () 関数は .BR setstate (3) と同様だが、大域変数で管理される状態を変更するのではなく、 .I buf が指すオブジェクト内の状態を変更する。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O All of these functions return 0 on success, or \-1 on error. これらの関数は、成功すると 0 を返し、 エラーの場合は \-1 を返す。 .\"O .SH ERRORS .SH エラー .TP .B EINVAL .\"O A state array of less than 8 bytes was specified to .\"O .BR initstate_r (). 8 バイトより小さい状態配列が .BR initstate_r () に指定された。 .TP .B EINVAL .\"O The .\"O .I statebuf .\"O or .\"O .I buf .\"O argument to .\"O .BR setstate_r () .\"O was NULL. .BR setstate_r () の引き数 .I statebuf か .I buf が NULL であった。 .TP .B EINVAL .\"O The .\"O .I buf .\"O or .\"O .I result .\"O argument to .\"O .BR random_r () .\"O was NULL. .BR random_r () の引き数 .I buf か .I result が NULL であった。 .\"O .SH "CONFORMING TO" .SH 準拠 .\"O These functions are nonstandard glibc extensions. これらの関数は非標準で glibc による拡張である。 .\" These functions appear to be on Tru64, but don't seem to be on .\" Solaris, HP-UX, or FreeBSD. .\"O .SH "SEE ALSO" .SH 関連項目 .BR drand48 (3), .BR rand (3), .BR random (3)