Skip to content

Commit

Permalink
Add thread safety annotations to RNG state
Browse files Browse the repository at this point in the history
  • Loading branch information
sipa authored and Fuzzbawls committed Apr 14, 2021
1 parent 2326535 commit 298f97c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,11 @@ void GetRandBytes(unsigned char* buf, int num)
namespace {
struct RNGState {
Mutex m_mutex;
unsigned char m_state[32] = {0};
uint64_t m_counter = 0;
unsigned char m_state[32] GUARDED_BY(m_mutex) = {0};
uint64_t m_counter GUARDED_BY(m_mutex) = 0;

explicit RNGState() {
RNGState()
{
InitHardwareRand();
}
};
Expand Down

0 comments on commit 298f97c

Please sign in to comment.