mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
Deprecate bro_srandom(), replace with zeek::seed_random().
Avoiding zeek::srandom() to avoid potential for confusion with srandom()
This commit is contained in:
parent
d486af06b1
commit
b17627fa09
3 changed files with 16 additions and 2 deletions
|
@ -1078,7 +1078,7 @@ static void bro_srandom(unsigned int seed, bool deterministic)
|
|||
srandom(seed);
|
||||
}
|
||||
|
||||
void bro_srandom(unsigned int seed)
|
||||
void zeek::seed_random(unsigned int seed)
|
||||
{
|
||||
if ( bro_rand_determistic )
|
||||
bro_rand_state = seed == 0 ? 1 : seed;
|
||||
|
@ -1086,6 +1086,11 @@ void bro_srandom(unsigned int seed)
|
|||
srandom(seed);
|
||||
}
|
||||
|
||||
void bro_srandom(unsigned int seed)
|
||||
{
|
||||
zeek::seed_random(seed);
|
||||
}
|
||||
|
||||
void init_random_seed(const char* read_file, const char* write_file,
|
||||
bool use_empty_seeds)
|
||||
{
|
||||
|
|
|
@ -230,6 +230,7 @@ long int bro_random();
|
|||
|
||||
// Calls the system srandom() function with the given seed if not running
|
||||
// in deterministic mode, else it updates the state of the deterministic PRNG.
|
||||
[[deprecated("Remove in v4.1. Use zeek::seed_random()")]]
|
||||
void bro_srandom(unsigned int seed);
|
||||
|
||||
extern uint64_t rand64bit();
|
||||
|
@ -614,4 +615,12 @@ long int random_number();
|
|||
*/
|
||||
long int max_random();
|
||||
|
||||
/**
|
||||
* Wrapper for system srandom() in the default case, but when running in
|
||||
* deterministic mode, updates the state used for calling zeek::prng()
|
||||
* inside of zeek::random_number().
|
||||
* @param seed Value to use for initializing the PRNG.
|
||||
*/
|
||||
void seed_random(unsigned int seed);
|
||||
|
||||
} // namespace zeek
|
||||
|
|
|
@ -946,7 +946,7 @@ function rand%(max: count%): count
|
|||
## provided by the OS.
|
||||
function srand%(seed: count%): any
|
||||
%{
|
||||
bro_srandom(seed);
|
||||
zeek::seed_random(seed);
|
||||
return nullptr;
|
||||
%}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue