From 9d414f068dc2b66223724ff6719d9116e3573a72 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 17 Dec 2018 16:22:22 -0800 Subject: [PATCH] Remove hwrand_initialized. All access to hwrand is now gated by GetRNGState, which initializes the hwrand code. Cherry-picked from: 4ea8e50837a0932b31a241988fd68d6730a2048a --- src/random.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/random.cpp b/src/random.cpp index 78e66f94247..f8658ae5d31 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -74,7 +74,6 @@ static inline int64_t GetPerformanceCounter() } #if defined(__x86_64__) || defined(__amd64__) || defined(__i386__) -static std::atomic hwrand_initialized{false}; static bool rdrand_supported = false; static constexpr uint32_t CPUID_F1_ECX_RDRAND = 0x40000000; static void InitHardwareRand() @@ -83,12 +82,10 @@ static void InitHardwareRand() if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) && (ecx & CPUID_F1_ECX_RDRAND)) { rdrand_supported = true; } - hwrand_initialized.store(true); } static void ReportHardwareRand() { - assert(hwrand_initialized.load(std::memory_order_relaxed)); if (rdrand_supported) { // This must be done in a separate function, as HWRandInit() may be indirectly called // from global constructors, before logging is initialized. @@ -108,7 +105,6 @@ static void ReportHardwareRand() {} static bool GetHardwareRand(unsigned char* ent32) { #if defined(__x86_64__) || defined(__amd64__) || defined(__i386__) - assert(hwrand_initialized.load(std::memory_order_relaxed)); if (rdrand_supported) { uint8_t ok; // Not all assemblers support the rdrand instruction, write it in hex.