Issue #4709 RFC? refactor and reseed rand::Rng #4958
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For Issue #4709:
c531506 rt: rand.rs expects
rust_next()to returnuint32_t, notsize_trand.rs expects
rustrt::rand_next()to returnu32, but therand_next()C function returnssize_t: https://github.com/mozilla/rust/blob/ca71c6ec5bb8106121cbe33eec5a6a9ca7786039/src/libcore/rand.rs#L34f4320b6 move isaac RNG utility functions to new rust_rng.cpp file
665e900 encapsulate isaac RNG in
rust_rngstructMove isaac's
randctxinto arust_rngstruct to make names similar torand::Rngfunction names and prepare for auto-reseeding in the next commit.9a78dc9 reseed
rust_rngafter generating 32KBPrecedents from other languages:
GenAutoReseedgenerator reseeds itself after generating 32KB: http://hackage.haskell.org/packages/archive/DRBG/0.1.2/doc/html/Crypto-Random-DRBG.html#t:GenAutoReseed9a76d71 don't deplete RNG entropy when there is only one runnable task
rust_sched_loop::schedule_task()unnecessarily callsisaac_rand()for the common case when there is only 1 runnable task, thus depleting RNG entropy and incurring unnecessary overhead.