Skip to content

Commit 774899f

Browse files
sipaFuzzbawls
authored andcommitted
Remove hwrand_initialized.
All access to hwrand is now gated by GetRNGState, which initializes the hwrand code.
1 parent 698d133 commit 774899f

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

src/random.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ static inline int64_t GetPerformanceCounter()
7676
}
7777

7878
#if defined(__x86_64__) || defined(__amd64__) || defined(__i386__)
79-
static std::atomic<bool> hwrand_initialized{false};
8079
static bool rdrand_supported = false;
8180
static constexpr uint32_t CPUID_F1_ECX_RDRAND = 0x40000000;
8281
static void InitHardwareRand()
@@ -85,12 +84,10 @@ static void InitHardwareRand()
8584
if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) && (ecx & CPUID_F1_ECX_RDRAND)) {
8685
rdrand_supported = true;
8786
}
88-
hwrand_initialized.store(true);
8987
}
9088

9189
static void ReportHardwareRand()
9290
{
93-
assert(hwrand_initialized.load(std::memory_order_relaxed));
9491
if (rdrand_supported) {
9592
// This must be done in a separate function, as HWRandInit() may be indirectly called
9693
// from global constructors, before logging is initialized.
@@ -110,7 +107,6 @@ static void ReportHardwareRand() {}
110107

111108
static bool GetHardwareRand(unsigned char* ent32) {
112109
#if defined(__x86_64__) || defined(__amd64__) || defined(__i386__)
113-
assert(hwrand_initialized.load(std::memory_order_relaxed));
114110
if (rdrand_supported) {
115111
uint8_t ok;
116112
// Not all assemblers support the rdrand instruction, write it in hex.

0 commit comments

Comments
 (0)