From f6eb33a2353cdec72e219e0e47cda90787326fc9 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 16 Dec 2019 11:19:29 -0500 Subject: [PATCH] Use 64-bit atomic for thread counter in random seed initialization. --- src/random.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/random.cpp b/src/random.cpp index aaf4db2d..7bc620d6 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -2,6 +2,7 @@ #include #include #include +#include namespace rack { @@ -12,7 +13,7 @@ namespace random { // from http://xoroshiro.di.unimi.it/xoroshiro128plus.c thread_local uint64_t xoroshiro128plus_state[2]; -static int threadCounter = 0; +static std::atomic threadCounter {0}; static uint64_t rotl(const uint64_t x, int k) { return (x << k) | (x >> (64 - k));