OSDN Git Service

(split) LDP v3.24 -> v3.29 の定型的な変更内容を反映。
[linuxjm/LDP_man-pages.git] / draft / 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 .\"O .SH NAME
30 .SH Ì¾Á°
31 .\"O random_r, srandom_r, initstate_r, setstate_r \- reentrant
32 .\"O random number generator
33 random_r, srandom_r, initstate_r, setstate_r \- ¥ê¥¨¥ó¥È¥é¥ó¥È¤Ê
34 Íð¿ôÀ¸À®´ï
35 .\"O .SH SYNOPSIS
36 .SH ½ñ¼°
37 .nf
38 .B #include <stdlib.h>
39 .sp
40 .BI "int random_r(struct random_data *" buf ", int32_t *" result );
41
42 .BI "int srandom_r(unsigned int " seed ", struct random_data *" buf );
43
44 .BI "int initstate_r(unsigned int " seed ", char *" statebuf ,
45 .BI "                size_t " statelen ", struct random_data *" buf );
46 .br
47 .BI "int setstate_r(char *" statebuf ", struct random_data *" buf );
48 .fi
49 .sp
50 .in -4n
51 .\"O Feature Test Macro Requirements for glibc (see
52 .\"O .BR feature_test_macros (7)):
53 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
54 .RB ( feature_test_macros (7)
55 »²¾È):
56 .in
57 .sp
58 .ad l
59 .BR random_r (),
60 .BR srandom_r (),
61 .BR initstate_r (),
62 .BR setstate_r ():
63 .RS 4
64 _SVID_SOURCE || _BSD_SOURCE
65 .RE
66 .ad b
67 .\"O .SH DESCRIPTION
68 .SH ÀâÌÀ
69 .\"O These functions are the reentrant equivalents
70 .\"O of the functions described in
71 .\"O .BR random (3).
72 .\"O They are suitable for use in multithreaded programs where each thread
73 .\"O needs to obtain an independent, reproducible sequence of random numbers.
74 ¤³¤ì¤é¤Î´Ø¿ô¤Ï¡¢
75 .BR random (3)
76 ¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë´Ø¿ô¤Î¥ê¥¨¥ó¥È¥é¥ó¥ÈÈǤǡ¢Åù²Á¤Êµ¡Ç½¤ò»ý¤Ä¡£
77 ¤³¤ì¤é¤Ï¡¢ÆÈΩ¤·¤¿ºÆ¸½²Äǽ¤ÊÍð¿ôÎó¤ò³Æ¥¹¥ì¥Ã¥É¤¬ÆÀ¤ëɬÍפ¬¤¢¤ë¤è¤¦¤Ê
78 ¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¡¦¥×¥í¥°¥é¥à¤Ç¤Î»ÈÍѤËŬ¤·¤Æ¤¤¤ë¡£
79
80 .\"O The
81 .\"O .BR random_r ()
82 .\"O function is like
83 .\"O .BR random (3),
84 .\"O except that instead of using state information maintained
85 .\"O in a global variable,
86 .\"O it uses the state information in the argument pointed to by
87 .\"O .IR buf .
88 .\"O The generated random number is returned in the argument
89 .\"O .IR result .
90 .BR random_r ()
91 ´Ø¿ô¤Ï
92 .BR random (3)
93 ¤ÈƱÍͤÀ¤¬¡¢
94 Âç°èÊÑ¿ô (global variable) ¤Ç´ÉÍý¤µ¤ì¤ë¾õÂÖ¾ðÊó¤ò»È¤¦¤Î¤Ç¤Ï¤Ê¤¯¡¢
95 .I buf
96 ¤¬»Ø¤¹°ú¤­¿ô¤Ë³ÊǼ¤µ¤ì¤¿¾õÂÖ¾ðÊó¤ò»È¤¦¡£
97 À¸À®¤µ¤ì¤¿Íð¿ô¤Ï°ú¤­¿ô
98 .I result
99 ¤Ë³ÊǼ¤µ¤ì¤ÆÊÖ¤µ¤ì¤ë¡£
100
101 .\"O The
102 .\"O .BR srandom_r ()
103 .\"O function is like
104 .\"O .BR srandom (3),
105 .\"O except that it initializes the seed for the random number generator
106 .\"O whose state is maintained in the object pointed to by
107 .\"O .IR buf ,
108 .\"O instead of the seed associated with the global state variable.
109 .BR srandom_r ()
110 ´Ø¿ô¤Ï
111 .BR srandom (3)
112 ¤ÈƱÍͤÀ¤¬¡¢
113 Âç°èÊÑ¿ô¤Ç´ÉÍý¤µ¤ì¤ë¾õÂÖ¤ËÂбþ¤¹¤ëÍð¿ôÀ¸À®´ï¤Î¼ï¤Ç¤Ï¤Ê¤¯¡¢
114 .I buf
115 ¤¬»Ø¤¹¥ª¥Ö¥¸¥§¥¯¥È¤Ç´ÉÍý¤µ¤ì¤ë¾õÂÖ¤ËÂбþ¤¹¤ëÍð¿ôÀ¸À®´ï¤Î¼ï¤ò
116 ½é´ü²½¤¹¤ë¡£
117
118 .\"O The
119 .\"O .BR initstate_r ()
120 .\"O function is like
121 .\"O .BR initstate (3)
122 .\"O except that it initializes the state in the object pointed to by
123 .\"O .IR buf ,
124 .\"O rather than initializing the global state variable.
125 .BR initstate_r ()
126 ´Ø¿ô¤Ï
127 .BR initstate (3)
128 ¤ÈƱÍͤÀ¤¬¡¢Âç°èÊÑ¿ô¤Ç´ÉÍý¤µ¤ì¤ë¾õÂÖ¤ò½é´ü²½¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢
129 .I buf
130 ¤¬»Ø¤¹¥ª¥Ö¥¸¥§¥¯¥ÈÆâ¤Î¾õÂÖ¤ò½é´ü²½¤¹¤ë¡£
131
132 .\"O The
133 .\"O .BR setstate_r ()
134 .\"O function is like
135 .\"O .BR setstate (3)
136 .\"O except that it modifies the state in the object pointer to by
137 .\"O .IR buf ,
138 .\"O rather than modifying the global state variable.
139 .BR setstate_r ()
140 ´Ø¿ô¤Ï
141 .BR setstate (3)
142 ¤ÈƱÍͤÀ¤¬¡¢Âç°èÊÑ¿ô¤Ç´ÉÍý¤µ¤ì¤ë¾õÂÖ¤òÊѹ¹¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢
143 .I buf
144 ¤¬»Ø¤¹¥ª¥Ö¥¸¥§¥¯¥ÈÆâ¤Î¾õÂÖ¤òÊѹ¹¤¹¤ë¡£
145 .\"O .SH "RETURN VALUE"
146 .SH ÊÖ¤êÃÍ
147 .\"O All of these functions return 0 on success, or \-1 on error.
148 ¤³¤ì¤é¤Î´Ø¿ô¤Ï¡¢À®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤·¡¢
149 ¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤òÊÖ¤¹¡£
150 .\"O .SH ERRORS
151 .SH ¥¨¥é¡¼
152 .TP
153 .B EINVAL
154 .\"O A state array of less than 8 bytes was specified to
155 .\"O .BR initstate_r ().
156 8 ¥Ð¥¤¥È¤è¤ê¾®¤µ¤¤¾õÂÖÇÛÎó¤¬
157 .BR initstate_r ()
158 ¤Ë»ØÄꤵ¤ì¤¿¡£
159 .TP
160 .B EINVAL
161 .\"O The
162 .\"O .I statebuf
163 .\"O or
164 .\"O .I buf
165 .\"O argument to
166 .\"O .BR setstate_r ()
167 .\"O was NULL.
168 .BR setstate_r ()
169 ¤Î°ú¤­¿ô
170 .I statebuf
171 ¤«
172 .I buf
173 ¤¬ NULL ¤Ç¤¢¤Ã¤¿¡£
174 .TP
175 .B EINVAL
176 .\"O The
177 .\"O .I buf
178 .\"O or
179 .\"O .I result
180 .\"O argument to
181 .\"O .BR random_r ()
182 .\"O was NULL.
183 .BR random_r ()
184 ¤Î°ú¤­¿ô
185 .I buf
186 ¤«
187 .I result
188 ¤¬ NULL ¤Ç¤¢¤Ã¤¿¡£
189 .\"O .SH "CONFORMING TO"
190 .SH ½àµò
191 .\"O These functions are nonstandard glibc extensions.
192 ¤³¤ì¤é¤Î´Ø¿ô¤ÏÈóɸ½à¤Ç glibc ¤Ë¤è¤ë³ÈÄ¥¤Ç¤¢¤ë¡£
193 .\" These functions appear to be on Tru64, but don't seem to be on
194 .\" Solaris, HP-UX, or FreeBSD.
195 .\"O .SH "SEE ALSO"
196 .SH ´ØÏ¢¹àÌÜ
197 .BR drand48 (3),
198 .BR rand (3),
199 .BR random (3)