aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/random.3
Commit message (Collapse)AuthorAgeFilesLines
* rand(3): Replace implementation with one backed by random(3) algorithmConrad Meyer2020-02-011-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | rand(3)'s standard C API is extremely limiting, but we can do better than the historical 32-bit state Park-Miller LCG we've shipped since 2001: r73156. The justification provided at the time for not using random(3) was that rand_r(3) could not be made to use the same algorithm. That is still true. However, the irrelevance of rand_r(3) is increasingly obvious. Since that time, POSIX has marked the interface obsolescent. rand_r(3) never became part of the standard C library. If not for API compatibility reasons, I would just remove rand_r(3) entirely. So, I do not believe it is a problem for rand_r(3) and rand(3) to diverge. The 12 ABI is maintained with compatibility definitions, but this revision does subtly change the API of rand(3). The sequences of pseudorandom numbers produced in programs built against new versions of libc will differ from programs built against prior versions of libc. Reviewed by: kevans, markm MFC after: no Relnotes: yes Differential Revision: https://reviews.freebsd.org/D23290 Notes: svn path=/head/; revision=357382
* random.3: Some minor improvements to wording/clarityConrad Meyer2020-01-201-44/+37
| | | | Notes: svn path=/head/; revision=356935
* random.3: Remove obsolete BUGS sectionConrad Meyer2019-04-221-9/+1
| | | | | | | | | | | | | Relative performance to rand(3) is sort of irrelevant; they do different things and a user with sensitivity to RNG performance won't use libc random(3) anyway. The historical note about bad seeding is long obsolete, referring to a 1996 or earlier version of FreeBSD. Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=346566
* random.3: Clarify confusing summaryConrad Meyer2019-04-151-2/+2
| | | | | | | | | | | | | | | | | random.3 is only "better" in contrast to rand.3. Both are non-cryptographic pseudo-random number generators. The opening blurbs of each's DESCRIPTION section does emphasize this, and correctly directs unfamiliar developers to arc4random(3). However, the summary (".Nd" or Name description) of random.3 conflicted in tone and message with that warning. Resolve the conflict by clarifying in the Nd section that random(3) is non-cryptographic and pseudo-random. Elide the "better" qualifier which implied a comparison but did not provide a specific object to contrast. Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=346251
* Fix typing of srandom() and initstate().Ed Schouten2016-07-261-3/+3
| | | | | | | | | | | | | | | | POSIX requires that these functions have an unsigned int for their first argument; not an unsigned long. My reasoning is that we can safely change these functions without breaking the ABI. As far as I know, our supported architectures either use registers for passing function arguments that are at least as big as long (e.g., amd64), or int and long are of the same size (e.g., i386). Reviewed by: ache Differential Revision: https://reviews.freebsd.org/D6644 Notes: svn path=/head/; revision=303342
* Reflect error indication according to POSIX and what those functionsAndrey A. Chernov2016-06-051-2/+2
| | | | | | | currently do. Notes: svn path=/head/; revision=301448
* Adjust wording slightly to emphasize that random(3) should not be used forColin Percival2015-02-251-3/+2
| | | | | | | | | | | any applications which need unpredictable random numbers, not merely those which are cryptographic in nature. If you work for a lottery and you're using random(3) to select the winning numbers, please let me know. Notes: svn path=/head/; revision=279269
* Renumber clauses to reduce diffs to other versionsEd Maste2013-06-131-1/+1
| | | | | | | | NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3, so follow suit to make comparison easier. Notes: svn path=/head/; revision=251672
* Replace access to /dev/random with the kernel pseudo-random numberXin LI2013-04-021-3/+3
| | | | | | | | | | | source sysctl(KERN_ARND) and remove the fallback code. Obtained from: OpenBSD Reviewed by: secteam MFC after: 1 month Notes: svn path=/head/; revision=249035
* Add the same warning to rand48(3) as to rand(3) and random(3).Dag-Erling Smørgrav2012-09-111-1/+0
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=240361
* Bump dates.Dag-Erling Smørgrav2012-09-041-1/+1
| | | | | | | Reminded by: bz@ Notes: svn path=/head/; revision=240111
* Add a prominent warning about these functions' unsuitability forDag-Erling Smørgrav2012-09-041-7/+10
| | | | | | | cryptographic purposes, and recommend using arc4random(3) instead. Notes: svn path=/head/; revision=240107
* Add cross-references to lrand48(3) and arc4random(3) from rand(3)Konstantin Belousov2010-10-061-0/+1
| | | | | | | | | | and random(3). Submitted by: Valentin Nechayev <netch netch kiev ua> MFC after: 1 week Notes: svn path=/head/; revision=213476
* Per Regents of the University of Calfornia letter, remove advertisingWarner Losh2007-01-091-4/+0
| | | | | | | | | clause. # If I've done so improperly on a file, please let me know. Notes: svn path=/head/; revision=165903
* Sort sections.Ruslan Ermilov2005-01-201-2/+2
| | | | Notes: svn path=/head/; revision=140505
* Mechanically kill hard sentence breaks.Ruslan Ermilov2004-07-021-4/+8
| | | | Notes: svn path=/head/; revision=131504
* Cross-reference arc4random(3).David Schultz2003-07-311-0/+4
| | | | Notes: svn path=/head/; revision=118248
* Fix grammar bogons.Jens Schweikhardt2003-05-311-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=115571
* Move to using .In instead of .Fd #include <> for include mark-up.Jeroen Ruigrok van der Werven2001-09-071-1/+1
| | | | | | | Inspired by comment from: dd Notes: svn path=/head/; revision=83206
* Remove whitespace at EOL.Dima Dorfman2001-07-151-4/+4
| | | | Notes: svn path=/head/; revision=79754
* mdoc(7) police: removed HISTORY info from the .Os call.Ruslan Ermilov2001-07-101-1/+1
| | | | Notes: svn path=/head/; revision=79531
* mdoc(7) police: remove extraneous .Pp before and/or after .Sh.Dima Dorfman2001-07-091-1/+0
| | | | Notes: svn path=/head/; revision=79454
* urandom(4) -> random(4)Dima Dorfman2001-06-071-2/+2
| | | | | | | | | PR: 27858 Submitted by: Yoshihiro Koya <Yoshihiro.Koya@math.yokohama-cu.ac.jp> Approved by: markm Notes: svn path=/head/; revision=77850
* Introduce ".Lb" macro to libc manpages.Alexey Zelkin2000-04-211-0/+2
| | | | | | | More libraries manpages updates following. Notes: svn path=/head/; revision=59460
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50476
* Add $Id$, to make it simpler for members of the translation teams toNik Clayton1999-07-121-0/+1
| | | | | | | | | | | | | | | | | | | | track. The $Id$ line is normally at the bottom of the main comment block in the man page, separated from the rest of the manpage by an empty comment, like so; .\" $Id$ .\" If the immediately preceding comment is a @(#) format ID marker than the the $Id$ will line up underneath it with no intervening blank lines. Otherwise, an additional blank line is inserted. Approved by: bde Notes: svn path=/head/; revision=48794
* .Sh AUTHOR -> .Sh AUTHORS. Use .An/.AqPhilippe Charnier1998-03-191-2/+2
| | | | Notes: svn path=/head/; revision=34669
* Instead of copying fallback code over and over in each program,Andrey A. Chernov1997-06-141-6/+1
| | | | | | | | | implement (better) falback code inside srandomdev() itself. Change return type from int to void (binary compatibility surprisely achieved). Userland code will be changed soon. Notes: svn path=/head/; revision=26624
* Remove orand* code as promised for the next releaseAndrey A. Chernov1997-03-291-12/+1
| | | | Notes: svn path=/head/; revision=24390
* Add srandomdev() descriptionAndrey A. Chernov1997-03-231-1/+24
| | | | Notes: svn path=/head/; revision=24153
* Use the .Tn macro for generic FreeBSD references. Other minor cleanup.Mike Pritchard1997-03-211-3/+3
| | | | Notes: svn path=/head/; revision=24094
* Fix arg types to match Lite2Andrey A. Chernov1997-03-171-2/+2
| | | | Notes: svn path=/head/; revision=23969
* Improve seeding, the random sequence did not vary matchAndrey A. Chernov1996-10-091-9/+20
| | | | | | | with the seed. Old variant will be available via libcompat soon. Notes: svn path=/head/; revision=18832
* Added missing section numbers to a bunch of .Xr macros, orMike Pritchard1996-03-271-4/+9
| | | | | | | | converted them into .Fn macros where appropriate. Also fixed up some minor formatting problems. Notes: svn path=/head/; revision=14855
* BSD 4.4 Lite Lib SourcesRodney W. Grimes1994-05-271-0/+166
Notes: svn path=/cvs2svn/branches/unlabeled-1.1.1/; revision=1573