diff options
Diffstat (limited to 'src/lib/libc/stdlib/rand.3')
| -rw-r--r-- | src/lib/libc/stdlib/rand.3 | 135 |
1 files changed, 0 insertions, 135 deletions
diff --git a/src/lib/libc/stdlib/rand.3 b/src/lib/libc/stdlib/rand.3 deleted file mode 100644 index 76278c871a..0000000000 --- a/src/lib/libc/stdlib/rand.3 +++ /dev/null | |||
| @@ -1,135 +0,0 @@ | |||
| 1 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. | ||
| 2 | .\" All rights reserved. | ||
| 3 | .\" | ||
| 4 | .\" This code is derived from software contributed to Berkeley by | ||
| 5 | .\" the American National Standards Committee X3, on Information | ||
| 6 | .\" Processing Systems. | ||
| 7 | .\" | ||
| 8 | .\" Redistribution and use in source and binary forms, with or without | ||
| 9 | .\" modification, are permitted provided that the following conditions | ||
| 10 | .\" are met: | ||
| 11 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 12 | .\" notice, this list of conditions and the following disclaimer. | ||
| 13 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 14 | .\" notice, this list of conditions and the following disclaimer in the | ||
| 15 | .\" documentation and/or other materials provided with the distribution. | ||
| 16 | .\" 3. Neither the name of the University nor the names of its contributors | ||
| 17 | .\" may be used to endorse or promote products derived from this software | ||
| 18 | .\" without specific prior written permission. | ||
| 19 | .\" | ||
| 20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
| 21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| 24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 30 | .\" SUCH DAMAGE. | ||
| 31 | .\" | ||
| 32 | .\" $OpenBSD: rand.3,v 1.20 2021/02/12 17:03:51 deraadt Exp $ | ||
| 33 | .\" | ||
| 34 | .Dd $Mdocdate: February 12 2021 $ | ||
| 35 | .Dt RAND 3 | ||
| 36 | .Os | ||
| 37 | .Sh NAME | ||
| 38 | .Nm rand , | ||
| 39 | .Nm rand_r , | ||
| 40 | .Nm srand , | ||
| 41 | .Nm srand_deterministic | ||
| 42 | .Nd bad pseudo-random number generator | ||
| 43 | .Sh SYNOPSIS | ||
| 44 | .In stdlib.h | ||
| 45 | .Ft void | ||
| 46 | .Fn srand "unsigned int seed" | ||
| 47 | .Ft void | ||
| 48 | .Fn srand_deterministic "unsigned int seed" | ||
| 49 | .Ft int | ||
| 50 | .Fn rand void | ||
| 51 | .Ft int | ||
| 52 | .Fn rand_r "unsigned int *seed" | ||
| 53 | .Sh DESCRIPTION | ||
| 54 | .Bf -symbolic | ||
| 55 | Standards insist that this interface return deterministic results. | ||
| 56 | Unsafe usage is very common, so | ||
| 57 | .Ox | ||
| 58 | changed the subsystem to return non-deterministic results by default. | ||
| 59 | .Ef | ||
| 60 | .Pp | ||
| 61 | To satisfy portable code, | ||
| 62 | .Fn srand | ||
| 63 | may be called to initialize the subsystem. | ||
| 64 | In | ||
| 65 | .Ox | ||
| 66 | the | ||
| 67 | .Ar seed | ||
| 68 | variable is ignored, and strong random number results will be provided from | ||
| 69 | .Xr arc4random 3 . | ||
| 70 | In other systems, the | ||
| 71 | .Ar seed | ||
| 72 | variable primes a simplistic deterministic algorithm. | ||
| 73 | .Pp | ||
| 74 | If the standardized behavior is required | ||
| 75 | .Fn srand_deterministic | ||
| 76 | can be substituted for | ||
| 77 | .Fn srand , | ||
| 78 | then subsequent | ||
| 79 | .Fn rand | ||
| 80 | calls will return results using the deterministic algorithm. | ||
| 81 | The deterministic sequence algorithm changed a number of times since | ||
| 82 | original development, is underspecified, and should not be relied upon to | ||
| 83 | remain consistent between platforms and over time. | ||
| 84 | .Pp | ||
| 85 | The | ||
| 86 | .Fn rand | ||
| 87 | function returns a result in the range of 0 to | ||
| 88 | .Dv RAND_MAX . | ||
| 89 | By default, this result comes from | ||
| 90 | .Xr arc4random 3 . | ||
| 91 | If | ||
| 92 | .Fn srand_deterministic | ||
| 93 | was called, the result will be computed using the deterministic algorithm. | ||
| 94 | .Pp | ||
| 95 | The | ||
| 96 | .Fn rand_r | ||
| 97 | is a thread-safe version of | ||
| 98 | .Fn rand . | ||
| 99 | Storage for the seed must be provided through the | ||
| 100 | .Fa seed | ||
| 101 | argument, and needs to have been initialized by the caller. | ||
| 102 | It always operates using the deterministic algorithm. | ||
| 103 | .Sh SEE ALSO | ||
| 104 | .Xr arc4random 3 , | ||
| 105 | .Xr rand48 3 , | ||
| 106 | .Xr random 3 | ||
| 107 | .Sh STANDARDS | ||
| 108 | The | ||
| 109 | .Fn rand | ||
| 110 | function conforms to | ||
| 111 | .St -ansiC . | ||
| 112 | .Pp | ||
| 113 | The | ||
| 114 | .Fn rand_r | ||
| 115 | function conforms to | ||
| 116 | .St -p1003.1-2008 . | ||
| 117 | .Pp | ||
| 118 | The | ||
| 119 | .Fn srand | ||
| 120 | function does not conform to | ||
| 121 | .St -ansiC , | ||
| 122 | intentionally. | ||
| 123 | .Pp | ||
| 124 | The | ||
| 125 | .Fn srand_deterministic | ||
| 126 | function is an | ||
| 127 | .Ox | ||
| 128 | extension. | ||
| 129 | .Sh HISTORY | ||
| 130 | The functions | ||
| 131 | .Fn rand | ||
| 132 | and | ||
| 133 | .Fn srand | ||
| 134 | first appeared in | ||
| 135 | .At v3 . | ||
