OSDN Git Service

Convert release and draft pages to UTF-8.
[linuxjm/jm.git] / manual / LDP_man-pages / release / man3 / random_r.3
1 .\" Copyright 2008 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Japanese Version Copyright (c) 2008  Akihiro MOTOKI
24 .\"         all rights reserved.
25 .\" Translated 2008-08-21, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.04
26 .\" 
27 .\"
28 .TH RANDOM_R 3  2008-03-07 "GNU" "Linux Programmer's Manual"
29 .SH 名前
30 random_r, srandom_r, initstate_r, setstate_r \- リエントラントな
31 乱数生成器
32 .SH 書式
33 .nf
34 .B #include <stdlib.h>
35 .sp
36 .BI "int random_r(struct random_data *" buf ", int32_t *" result );
37
38 .BI "int srandom_r(unsigned int " seed ", struct random_data *" buf );
39
40 .BI "int initstate_r(unsigned int " seed ", char *" statebuf ,
41 .BI "                size_t " statelen ", struct random_data *" buf );
42 .br
43 .BI "int setstate_r(char *" statebuf ", struct random_data *" buf );
44 .fi
45 .sp
46 .in -4n
47 glibc 向けの機能検査マクロの要件
48 .RB ( feature_test_macros (7)
49 参照):
50 .in
51 .sp
52 .ad l
53 .BR random_r (),
54 .BR srandom_r (),
55 .BR initstate_r (),
56 .BR setstate_r ():
57 .RS 4
58 _SVID_SOURCE || _BSD_SOURCE
59 .RE
60 .ad b
61 .SH 説明
62 これらの関数は、
63 .BR random (3)
64 で説明されている関数のリエントラント版で、等価な機能を持つ。
65 これらは、独立した再現可能な乱数列を各スレッドが得る必要があるような
66 マルチスレッド・プログラムでの使用に適している。
67
68 .BR random_r ()
69 関数は
70 .BR random (3)
71 と同様だが、
72 大域変数 (global variable) で管理される状態情報を使うのではなく、
73 .I buf
74 が指す引き数に格納された状態情報を使う。
75 生成された乱数は引き数
76 .I result
77 に格納されて返される。
78
79 .BR srandom_r ()
80 関数は
81 .BR srandom (3)
82 と同様だが、
83 大域変数で管理される状態に対応する乱数生成器の種ではなく、
84 .I buf
85 が指すオブジェクトで管理される状態に対応する乱数生成器の種を
86 初期化する。
87
88 .BR initstate_r ()
89 関数は
90 .BR initstate (3)
91 と同様だが、大域変数で管理される状態を初期化するのではなく、
92 .I buf
93 が指すオブジェクト内の状態を初期化する。
94
95 .BR setstate_r ()
96 関数は
97 .BR setstate (3)
98 と同様だが、大域変数で管理される状態を変更するのではなく、
99 .I buf
100 が指すオブジェクト内の状態を変更する。
101 .SH 返り値
102 これらの関数は、成功すると 0 を返し、
103 エラーの場合は \-1 を返す。
104 .SH エラー
105 .TP
106 .B EINVAL
107 8 バイトより小さい状態配列が
108 .BR initstate_r ()
109 に指定された。
110 .TP
111 .B EINVAL
112 .BR setstate_r ()
113 の引き数
114 .I statebuf
115
116 .I buf
117 が NULL であった。
118 .TP
119 .B EINVAL
120 .BR random_r ()
121 の引き数
122 .I buf
123
124 .I result
125 が NULL であった。
126 .SH 準拠
127 これらの関数は非標準で glibc による拡張である。
128 .\" These functions appear to be on Tru64, but don't seem to be on
129 .\" Solaris, HP-UX, or FreeBSD.
130 .SH 関連項目
131 .BR drand48 (3),
132 .BR rand (3),
133 .BR random (3)