]> git.saurik.com Git - apple/libc.git/blob - stdlib/FreeBSD/random.3.patch
Libc-498.1.5.tar.gz
[apple/libc.git] / stdlib / FreeBSD / random.3.patch
1 --- random.3 2004-11-25 11:38:42.000000000 -0800
2 +++ random.3.edit 2006-07-12 11:25:20.000000000 -0700
3 @@ -36,32 +36,45 @@
4 .Dt RANDOM 3
5 .Os
6 .Sh NAME
7 +.Nm initstate ,
8 .Nm random ,
9 +.Nm setstate ,
10 .Nm srandom ,
11 -.Nm srandomdev ,
12 -.Nm initstate ,
13 -.Nm setstate
14 +.Nm srandomdev
15 .Nd better random number generator; routines for changing generators
16 .Sh LIBRARY
17 .Lb libc
18 .Sh SYNOPSIS
19 .In stdlib.h
20 +.Ft char *
21 +.Fo initstate
22 +.Fa "unsigned seed"
23 +.Fa "char *state"
24 +.Fa "size_t size"
25 +.Fc
26 .Ft long
27 -.Fn random void
28 +.Fo random
29 +.Fa void
30 +.Fc
31 +.Ft char *
32 +.Fo setstate
33 +.Fa "const char *state"
34 +.Fc
35 .Ft void
36 -.Fn srandom "unsigned long seed"
37 +.Fo srandom
38 +.Fa "unsigned seed"
39 +.Fc
40 .Ft void
41 -.Fn srandomdev void
42 -.Ft char *
43 -.Fn initstate "unsigned long seed" "char *state" "long n"
44 -.Ft char *
45 -.Fn setstate "char *state"
46 +.Fo srandomdev
47 +.Fa void
48 +.Fc
49 .Sh DESCRIPTION
50 The
51 .Fn random
52 function
53 -uses a non-linear additive feedback random number generator employing a
54 -default table of size 31 long integers to return successive pseudo-random
55 +uses a non-linear, additive feedback, random number generator, employing a
56 +default table of size 31 long integers.
57 +It returns successive pseudo-random
58 numbers in the range from 0 to
59 .if t 2\u\s731\s10\d\(mi1.
60 .if n (2**31)\(mi1.
61 @@ -82,7 +95,7 @@
62 .Xr rand 3
63 produces a much less random sequence \(em in fact, the low dozen bits
64 generated by rand go through a cyclic pattern.
65 -All the bits generated by
66 +All of the bits generated by
67 .Fn random
68 are usable.
69 For example,
70 @@ -102,7 +115,7 @@
71 .Pp
72 The
73 .Fn srandomdev
74 -routine initializes a state array using the
75 +routine initializes a state array, using the
76 .Xr random 4
77 random number device which returns good random numbers,
78 suitable for cryptographic use.
79 @@ -127,7 +140,7 @@
80 the nearest known amount.
81 Using less than 8 bytes will cause an error.)
82 The seed for the initialization (which specifies a starting point for
83 -the random number sequence, and provides for restarting at the same
84 +the random number sequence and provides for restarting at the same
85 point) is also an argument.
86 The
87 .Fn initstate
88 @@ -166,7 +179,7 @@
89 With 256 bytes of state information, the period of the random number
90 generator is greater than
91 .if t 2\u\s769\s10\d,
92 -.if n 2**69
93 +.if n 2**69 ,
94 which should be sufficient for most purposes.
95 .Sh AUTHORS
96 .An Earl T. Cohen
97 @@ -177,11 +190,36 @@
98 .Fn setstate
99 detects that the state information has been garbled, error
100 messages are printed on the standard error output.
101 +.Sh LEGACY SYNOPSIS
102 +.Fd #include <stdlib.h>
103 +.Pp
104 +.Ft char *
105 +.br
106 +.Fo initstate
107 +.Fa "unsigned long seed"
108 +.Fa "char *state"
109 +.Fa "long size"
110 +.Fc ;
111 +.Pp
112 +.Ft char *
113 +.br
114 +.Fo setstate
115 +.Fa "char *state"
116 +.Fc ;
117 +.Pp
118 +.Ft void
119 +.br
120 +.Fo srandom
121 +.Fa "unsigned long seed"
122 +.Fc ;
123 +.Pp
124 +The type of each parameter is different in the legacy version.
125 .Sh SEE ALSO
126 .Xr arc4random 3 ,
127 .Xr rand 3 ,
128 .Xr srand 3 ,
129 -.Xr random 4
130 +.Xr random 4 ,
131 +.Xr compat 5
132 .Sh HISTORY
133 These
134 functions appeared in