Add thread safety annotations to RNG state

This commit is contained in:
Pieter Wuille committed 2019-01-16 16:31:34 -08:00
1 parent d3f54d1c82
commit aae8b9bf0f
1 file changed
+4 -3
+4 -3
View File
@@ -297,10 +297,11 @@ void GetRandBytes(unsigned char* buf, int num)
namespace { namespace {
struct RNGState { struct RNGState {
Mutex m_mutex; Mutex m_mutex;
unsigned char m_state[32] = {0}; unsigned char m_state[32] GUARDED_BY(m_mutex) = {0};
uint64_t m_counter = 0; uint64_t m_counter GUARDED_BY(m_mutex) = 0;
explicit RNGState() { RNGState()
{
InitHardwareRand(); InitHardwareRand();
} }
}; };