.\" Copyright 2008 Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" 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. .\" %%%LICENSE_END .\" .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2008 Akihiro MOTOKI .\" all rights reserved. .\" Translated 2008-08-21, Akihiro MOTOKI , LDP v3.04 .\" .TH RANDOM_R 3 2014\-03\-25 GNU "Linux Programmer's Manual" .SH 名前 random_r, srandom_r, initstate_r, setstate_r \- リエントラントな 乱数生成器 .SH 書式 .nf \fB#include \fP .sp \fBint random_r(struct random_data *\fP\fIbuf\fP\fB, int32_t *\fP\fIresult\fP\fB);\fP \fBint srandom_r(unsigned int \fP\fIseed\fP\fB, struct random_data *\fP\fIbuf\fP\fB);\fP \fBint initstate_r(unsigned int \fP\fIseed\fP\fB, char *\fP\fIstatebuf\fP\fB,\fP \fB size_t \fP\fIstatelen\fP\fB, struct random_data *\fP\fIbuf\fP\fB);\fP .br \fBint setstate_r(char *\fP\fIstatebuf\fP\fB, struct random_data *\fP\fIbuf\fP\fB);\fP .fi .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp .ad l \fBrandom_r\fP(), \fBsrandom_r\fP(), \fBinitstate_r\fP(), \fBsetstate_r\fP(): .RS 4 _SVID_SOURCE || _BSD_SOURCE .RE .ad b .SH 説明 これらの関数は、 \fBrandom\fP(3) で説明されている関数のリエントラント版で、等価な機能を持つ。 これらは、独立した再現可能な乱数列を各スレッドが得る必要があるような マルチスレッドプログラムでの使用に適している。 \fBrandom_r\fP() 関数は \fBrandom\fP(3) と同様だが、 大域変数 (global variable) で管理される状態情報を使うのではなく、 \fIbuf\fP が指す引き数に格納された状態情報を使う。 生成された乱数は引き数 \fIresult\fP に格納されて返される。 \fBsrandom_r\fP() 関数は \fBsrandom\fP(3) と同様だが、 大域変数で管理される状態に対応する乱数生成器の種ではなく、 \fIbuf\fP が指すオブジェクトで管理される状態に対応する乱数生成器の種を 初期化する。 \fBinitstate_r\fP() 関数は \fBinitstate\fP(3) と同様だが、大域変数で管理される状態を初期化するのではなく、 \fIbuf\fP が指すオブジェクト内の状態を初期化する。 \fBsetstate_r\fP() 関数は \fBsetstate\fP(3) と同様だが、大域変数で管理される状態を変更するのではなく、 \fIbuf\fP が指すオブジェクト内の状態を変更する。 .SH 返り値 これらの関数はすべて、成功すると 0 を返す。 エラーの場合、\-1 を返し、 \fIerrno\fP にエラーの原因を示す値がセットされる。 .SH エラー .TP \fBEINVAL\fP 8 バイトより小さい状態配列が \fBinitstate_r\fP() に指定された。 .TP \fBEINVAL\fP \fBsetstate_r\fP() の引き数 \fIstatebuf\fP か \fIbuf\fP が NULL であった。 .TP \fBEINVAL\fP \fBrandom_r\fP() の引き数 \fIbuf\fP か \fIresult\fP が NULL であった。 .SH 属性 .SS "マルチスレッディング (pthreads(7) 参照)" 関数 \fBrandom_r\fP(), \fBsrandom_r\fP(), \fBinitstate_r\fP(), \fBsetstate_r\fP() はスレッドセーフである。 .SH 準拠 .\" These functions appear to be on Tru64, but don't seem to be on .\" Solaris, HP-UX, or FreeBSD. これらの関数は非標準で glibc による拡張である。 .SH 関連項目 \fBdrand48\fP(3), \fBrand\fP(3), \fBrandom\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。