diff options
Diffstat (limited to 'src/lib/libc/stdlib/rand.3')
-rw-r--r-- | src/lib/libc/stdlib/rand.3 | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/src/lib/libc/stdlib/rand.3 b/src/lib/libc/stdlib/rand.3 index a0e7740e66..75395976f8 100644 --- a/src/lib/libc/stdlib/rand.3 +++ b/src/lib/libc/stdlib/rand.3 | |||
@@ -13,11 +13,7 @@ | |||
13 | .\" 2. Redistributions in binary form must reproduce the above copyright | 13 | .\" 2. Redistributions in binary form must reproduce the above copyright |
14 | .\" notice, this list of conditions and the following disclaimer in the | 14 | .\" notice, this list of conditions and the following disclaimer in the |
15 | .\" documentation and/or other materials provided with the distribution. | 15 | .\" documentation and/or other materials provided with the distribution. |
16 | .\" 3. All advertising materials mentioning features or use of this software | 16 | .\" 3. Neither the name of the University nor the names of its contributors |
17 | .\" must display the following acknowledgement: | ||
18 | .\" This product includes software developed by the University of | ||
19 | .\" California, Berkeley and its contributors. | ||
20 | .\" 4. Neither the name of the University nor the names of its contributors | ||
21 | .\" may be used to endorse or promote products derived from this software | 17 | .\" may be used to endorse or promote products derived from this software |
22 | .\" without specific prior written permission. | 18 | .\" without specific prior written permission. |
23 | .\" | 19 | .\" |
@@ -33,25 +29,28 @@ | |||
33 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
34 | .\" SUCH DAMAGE. | 30 | .\" SUCH DAMAGE. |
35 | .\" | 31 | .\" |
36 | .\" from: @(#)rand.3 6.7 (Berkeley) 6/29/91 | 32 | .\" $OpenBSD: rand.3,v 1.15 2014/04/07 17:57:56 schwarze Exp $ |
37 | .\" $Id: rand.3,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $ | ||
38 | .\" | 33 | .\" |
39 | .Dd June 29, 1991 | 34 | .Dd $Mdocdate: April 7 2014 $ |
40 | .Dt RAND 3 | 35 | .Dt RAND 3 |
41 | .Os | 36 | .Os |
42 | .Sh NAME | 37 | .Sh NAME |
43 | .Nm rand , | 38 | .Nm rand , |
39 | .Nm rand_r , | ||
44 | .Nm srand | 40 | .Nm srand |
45 | .Nd bad random number generator | 41 | .Nd bad random number generator |
46 | .Sh SYNOPSIS | 42 | .Sh SYNOPSIS |
47 | .Fd #include <stdlib.h> | 43 | .In stdlib.h |
48 | .Ft void | 44 | .Ft void |
49 | .Fn srand "unsigned seed" | 45 | .Fn srand "unsigned int seed" |
50 | .Ft int | 46 | .Ft int |
51 | .Fn rand void | 47 | .Fn rand void |
48 | .Ft int | ||
49 | .Fn rand_r "unsigned int *seed" | ||
52 | .Sh DESCRIPTION | 50 | .Sh DESCRIPTION |
53 | .Bf -symbolic | 51 | .Bf -symbolic |
54 | These interfaces are obsoleted by random(3). | 52 | These interfaces are obsoleted by |
53 | .Xr random 3 . | ||
55 | .Ef | 54 | .Ef |
56 | .Pp | 55 | .Pp |
57 | The | 56 | The |
@@ -60,7 +59,7 @@ function computes a sequence of pseudo-random integers in the range | |||
60 | of 0 to | 59 | of 0 to |
61 | .Dv RAND_MAX | 60 | .Dv RAND_MAX |
62 | (as defined by the header file | 61 | (as defined by the header file |
63 | .Aq Pa stdlib.h ) . | 62 | .In stdlib.h ) . |
64 | .Pp | 63 | .Pp |
65 | The | 64 | The |
66 | .Fn srand | 65 | .Fn srand |
@@ -73,13 +72,34 @@ with the same seed value. | |||
73 | .Pp | 72 | .Pp |
74 | If no seed value is provided, the functions are automatically | 73 | If no seed value is provided, the functions are automatically |
75 | seeded with a value of 1. | 74 | seeded with a value of 1. |
75 | .Pp | ||
76 | The | ||
77 | .Fn rand_r | ||
78 | is a thread-safe version of | ||
79 | .Fn rand . | ||
80 | Storage for the seed must be provided through the | ||
81 | .Fa seed | ||
82 | argument, and needs to have been initialized by the caller. | ||
76 | .Sh SEE ALSO | 83 | .Sh SEE ALSO |
84 | .Xr arc4random 3 , | ||
85 | .Xr rand48 3 , | ||
77 | .Xr random 3 | 86 | .Xr random 3 |
78 | .Sh STANDARDS | 87 | .Sh STANDARDS |
79 | The | 88 | The |
80 | .Fn rand | 89 | .Fn rand |
81 | and | 90 | and |
82 | .Fn srand | 91 | .Fn srand |
83 | functions | 92 | functions conform to |
84 | conform to | ||
85 | .St -ansiC . | 93 | .St -ansiC . |
94 | .Pp | ||
95 | The | ||
96 | .Fn rand_r | ||
97 | function conforms to | ||
98 | .St -p1003.1-2008 . | ||
99 | .Sh HISTORY | ||
100 | The functions | ||
101 | .Fn rand | ||
102 | and | ||
103 | .Fn srand | ||
104 | first appeared in | ||
105 | .At v3 . | ||