<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/lib/libc/stdlib/rand.3, branch release/14.4.0</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src/atom?h=release%2F14.4.0</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src/atom?h=release%2F14.4.0'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/'/>
<updated>2023-08-16T17:55:15Z</updated>
<entry>
<title>Remove $FreeBSD$: one-line nroff pattern</title>
<updated>2023-08-16T17:55:15Z</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2023-08-16T17:55:15Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=b2c76c41be32f904179efed29c0ca04d53f3996c'/>
<id>urn:sha1:b2c76c41be32f904179efed29c0ca04d53f3996c</id>
<content type='text'>
Remove /^\.\\"\s*\$FreeBSD\$$\n/
</content>
</entry>
<entry>
<title>rand(3): Replace implementation with one backed by random(3) algorithm</title>
<updated>2020-02-01T20:33:23Z</updated>
<author>
<name>Conrad Meyer</name>
<email>cem@FreeBSD.org</email>
</author>
<published>2020-02-01T20:33:23Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=672e12255da9b211d5318889ed9441ffc63c9f30'/>
<id>urn:sha1:672e12255da9b211d5318889ed9441ffc63c9f30</id>
<content type='text'>
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
</content>
</entry>
<entry>
<title>Deprecate sranddev(3) API</title>
<updated>2019-12-14T08:28:10Z</updated>
<author>
<name>Conrad Meyer</name>
<email>cem@FreeBSD.org</email>
</author>
<published>2019-12-14T08:28:10Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=c62ff2800ba9e4b6e851ae71b1696b28920854b9'/>
<id>urn:sha1:c62ff2800ba9e4b6e851ae71b1696b28920854b9</id>
<content type='text'>
It serves no useful purpose and wasn't as popular as its equally meritless
cousin, srandomdev(3).

Setting aside the problems with rand(3) in general, the problem with this
interface is that the seed isn't shared with the caller (other than by
attacking the output of the generator, which is trivial, but not a hallmark of
pleasant API design).  The (arguable) utility of rand(3) or random(3) is as a
semi-fast simulation generator which produces consistent results from a given
seed.  These are mutually at odd.  Furthermore, sometimes people got the
mistaken impression that a high quality random seed meant a weak generator like
rand(3) or random(3) could be used for things like cryptographic key
generation.  This is absolutely not so.

The API was never part of a standard and was not widely used in tree.  Existing
in-tree uses have all been removed.

Possible replacement in out of tree codebases:

	char buf[3];
	time_t t;

	time(t);
	strftime(buf, sizeof(buf), "%S", gmtime(&amp;t));
	srand(atoi(buf));

Relnotes:	yes
</content>
</entry>
<entry>
<title>rand.3: Match better recommendation language from random.3</title>
<updated>2019-04-22T16:26:39Z</updated>
<author>
<name>Conrad Meyer</name>
<email>cem@FreeBSD.org</email>
</author>
<published>2019-04-22T16:26:39Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=0ab49eea7f7737c36460d90f0e785d83c43e05dc'/>
<id>urn:sha1:0ab49eea7f7737c36460d90f0e785d83c43e05dc</id>
<content type='text'>
Sponsored by:	Dell EMC Isilon
</content>
</entry>
<entry>
<title>Renumber clauses to reduce diffs to other versions</title>
<updated>2013-06-13T00:19:30Z</updated>
<author>
<name>Ed Maste</name>
<email>emaste@FreeBSD.org</email>
</author>
<published>2013-06-13T00:19:30Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=580b4d185bc1d20da91429229920ce590309cbf6'/>
<id>urn:sha1:580b4d185bc1d20da91429229920ce590309cbf6</id>
<content type='text'>
NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3,
so follow suit to make comparison easier.
</content>
</entry>
<entry>
<title>Replace access to /dev/random with the kernel pseudo-random number</title>
<updated>2013-04-02T23:41:20Z</updated>
<author>
<name>Xin LI</name>
<email>delphij@FreeBSD.org</email>
</author>
<published>2013-04-02T23:41:20Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=12a6865090ad2f88c671256c53a8fed4d5424424'/>
<id>urn:sha1:12a6865090ad2f88c671256c53a8fed4d5424424</id>
<content type='text'>
source sysctl(KERN_ARND) and remove the fallback code.

Obtained from:	OpenBSD
Reviewed by:	secteam
MFC after:	1 month
</content>
</entry>
<entry>
<title>Bump dates.</title>
<updated>2012-09-04T22:03:16Z</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2012-09-04T22:03:16Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=cf949d128392129bd09ae38efb7cf3731042f5de'/>
<id>urn:sha1:cf949d128392129bd09ae38efb7cf3731042f5de</id>
<content type='text'>
Reminded by:	bz@
</content>
</entry>
<entry>
<title>Add a prominent warning about these functions' unsuitability for</title>
<updated>2012-09-04T21:40:53Z</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2012-09-04T21:40:53Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=edab57e04e8c6bfbcb30dacc2135c2325d685646'/>
<id>urn:sha1:edab57e04e8c6bfbcb30dacc2135c2325d685646</id>
<content type='text'>
cryptographic purposes, and recommend using arc4random(3) instead.
</content>
</entry>
<entry>
<title>Missed space.</title>
<updated>2010-10-06T09:24:33Z</updated>
<author>
<name>Konstantin Belousov</name>
<email>kib@FreeBSD.org</email>
</author>
<published>2010-10-06T09:24:33Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=3ac535965a939ba237aafbf802676461e5494e25'/>
<id>urn:sha1:3ac535965a939ba237aafbf802676461e5494e25</id>
<content type='text'>
Submitted by:	brueffer
MFC after:	1 week
</content>
</entry>
<entry>
<title>Add cross-references to lrand48(3) and arc4random(3) from rand(3)</title>
<updated>2010-10-06T09:05:47Z</updated>
<author>
<name>Konstantin Belousov</name>
<email>kib@FreeBSD.org</email>
</author>
<published>2010-10-06T09:05:47Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=866dcc94625d9f09f3df85a630b6b5a8d2d50852'/>
<id>urn:sha1:866dcc94625d9f09f3df85a630b6b5a8d2d50852</id>
<content type='text'>
and random(3).

Submitted by:	Valentin Nechayev &lt;netch netch kiev ua&gt;
MFC after:	1 week
</content>
</entry>
</feed>
