Skip to content

Commit aae8b9b

Browse files
committed
Add thread safety annotations to RNG state
1 parent d3f54d1 commit aae8b9b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/random.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,11 @@ void GetRandBytes(unsigned char* buf, int num)
297297
namespace {
298298
struct RNGState {
299299
Mutex m_mutex;
300-
unsigned char m_state[32] = {0};
301-
uint64_t m_counter = 0;
300+
unsigned char m_state[32] GUARDED_BY(m_mutex) = {0};
301+
uint64_t m_counter GUARDED_BY(m_mutex) = 0;
302302

303-
explicit RNGState() {
303+
RNGState()
304+
{
304305
InitHardwareRand();
305306
}
306307
};

0 commit comments

Comments
 (0)