ndis(4): Better mimic the behavior of rand() on Windows.
In ndis(4) we expose a rand() function that was constantly reseeding with a time depending function every time it was called. This essentially broke the reasoning behind seeding, and rendered srand() a no-op. Keep it simple, just use random() and srandom() as it's meant to work. It would have been tempting to just go for arc4random() but we want to mimic Microsoft, and we don't need crypto-grade randomness here. PR: 209616 MFC after: 2 weeks
This commit is contained in:
parent
da6da1575b
commit
0e6d3c6d16
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=300376
@ -3188,17 +3188,14 @@ atol(str)
|
||||
static int
|
||||
rand(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
microtime(&tv);
|
||||
srandom(tv.tv_usec);
|
||||
return ((int)random());
|
||||
return (random());
|
||||
}
|
||||
|
||||
static void
|
||||
srand(seed)
|
||||
unsigned int seed;
|
||||
srand(unsigned int seed)
|
||||
{
|
||||
|
||||
srandom(seed);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user