improve random seed (for dummy generators)

This commit is contained in:
Robin Gareus 2014-11-10 22:20:36 +01:00
parent 1317b57221
commit a37ffd1f0c
1 changed files with 9 additions and 0 deletions

View File

@ -1436,7 +1436,16 @@ bool DummyPort::is_physically_connected () const
void DummyPort::setup_random_number_generator ()
{
#ifdef PLATFORM_WINDOWS
LARGE_INTEGER Count;
if (QueryPerformanceCounter (&Count)) {
_rseed = Count.QuadPart % UINT_MAX;
} else
#endif
{
_rseed = g_get_monotonic_time() % UINT_MAX;
}
_rseed = (_rseed + (uint64_t)this) % UINT_MAX;
}
inline uint32_t