mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 19:18:19 +00:00
Expose Bro's linear congruence PRNG as utility function.
It was previously not possible to crank the wheel on the PRNG in a deterministic way without affecting the globally unique seed. The new extra utility function bro_prng takes a state in the form of a long int and returns the new PRNG state, now allowing arbitrary code parts to use the random number functionality. This commit also fixes a problem in the H3 constructor, which requires use of multiple seeds. The single seed passed in now serves as seed to crank out as many value needed using bro_prng.
This commit is contained in:
parent
79a6a26f9f
commit
9f74064289
3 changed files with 24 additions and 13 deletions
|
@ -173,9 +173,12 @@ unsigned int initial_seed();
|
|||
// Returns true if the user explicitly set a seed via init_random_seed();
|
||||
extern bool have_random_seed();
|
||||
|
||||
// A simple linear congruence PRNG. It takes its state as argument and returns
|
||||
// a new random value, which can serve as state for subsequent calls.
|
||||
long int bro_prng(long int state);
|
||||
|
||||
// Replacement for the system random(), to which is normally falls back
|
||||
// except when a seed has been given. In that case, we use our own
|
||||
// predictable PRNG.
|
||||
// except when a seed has been given. In that case, the function bro_prng.
|
||||
long int bro_random();
|
||||
|
||||
// Calls the system srandom() function with the given seed if not running
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue