mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
Deprecate bro_prng(), replace with zeek::prng()
The type used for storing the state of the RNG is changed from `unsigned int` to `long int` since the former has a minimal range of [0, 65,535] while the RNG function itself has a range of [1, 2147483646]. A `long int` must be capable of [−2147483647, +2147483647] and is also the return type of `random()`, which is what zeek::prng() aims to roughly parity.
This commit is contained in:
parent
887b53b7f3
commit
6bbb0a6b48
3 changed files with 23 additions and 5 deletions
11
src/util.h
11
src/util.h
|
@ -220,6 +220,7 @@ 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.
|
||||
[[deprecated("Remove in v4.1. Use zeek::prng()")]]
|
||||
unsigned int bro_prng(unsigned int state);
|
||||
|
||||
// Replacement for the system random(), to which is normally falls back
|
||||
|
@ -588,4 +589,14 @@ namespace zeek {
|
|||
*/
|
||||
void set_thread_name(const char* name, pthread_t tid = pthread_self());
|
||||
|
||||
/**
|
||||
* A platform-independent PRNG implementation. Note that this is not
|
||||
* necessarily a "statistically sound" implementation as the main purpose is
|
||||
* not for production use, but rather for regression testing.
|
||||
* @param state The value used to generate the next random number.
|
||||
* @return A new random value generated from *state* and that can passed
|
||||
* back into subsequent calls to generate further random numbers.
|
||||
*/
|
||||
long int prng(long int state);
|
||||
|
||||
} // namespace zeek
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue