From cf7be329d6c8b097cc8ba32780a7dab8b7e3932e Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Sat, 9 Sep 2023 13:50:26 +0100 Subject: [PATCH] [*] Update fallback RNG entropy: reduce expected tick resolution --- Source/RNG/AuRNGEntropy.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/RNG/AuRNGEntropy.cpp b/Source/RNG/AuRNGEntropy.cpp index 79b6be4c..97d28d74 100644 --- a/Source/RNG/AuRNGEntropy.cpp +++ b/Source/RNG/AuRNGEntropy.cpp @@ -174,7 +174,7 @@ namespace Aurora::RNG #if 0 return clock(); // [...] resolution of 1 posix clock() tick (this is usually 1,000,000 == CLOCKS_PER_SEC per posix, but it can be 1k) #else - return AuTime::SteadyClockNS() / 1000ull; + return AuTime::SteadyClockNS() / 10'000ull; #endif } @@ -197,7 +197,7 @@ namespace Aurora::RNG do { t1 = RngTimeClock(); - while (t1 == RngTimeClock()) // spin within 1 microseconds + while (t1 == RngTimeClock()) // spin within 1 microseconds (*) { a ^= 1; // flip } @@ -207,6 +207,12 @@ namespace Aurora::RNG { b ^= 1; // flip } + + // Update 2023/Sept: Now x10 because we dont have enough timer res on some platforms. + // This is was generally never a CPU limitation or API limitation until Windows XP. Check software or motherboard... + // ...but still, let's continue. + // Deadlocking preprocess init, because for example the motherboard is failing or a VM configuration changed, is pretty dumb. + // (ask me how i know) } while (a == b); // ensure theres enough entropy for a deviation to occur acc = (acc << 1) | a; // push the first bit state