diff --git a/AtlasTest/TestTools/ATLAS_CHECK_THREAD_SAFETY b/AtlasTest/TestTools/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/AtlasTest/TestTools/TestTools/leakcheck.h b/AtlasTest/TestTools/TestTools/leakcheck.h index 8d41b3a72c2a8eb212a2336aa43e2a30440930cc..f18439480d1bd63ec3805df03e88bb57a7c017d8 100644 --- a/AtlasTest/TestTools/TestTools/leakcheck.h +++ b/AtlasTest/TestTools/TestTools/leakcheck.h @@ -21,6 +21,10 @@ #ifndef TESTTOOLS_LEAKCHECK_H #define TESTTOOLS_LEAKCHECK_H +// Can't use CxxUtils/checker_macros.h here, since that would be circular dependency. +#ifdef ATLAS_GCC_CHECKERS +#pragma ATLAS no_check_thread_safety +#endif #include <malloc.h> #include <unordered_set> diff --git a/AtlasTest/TestTools/TestTools/random.h b/AtlasTest/TestTools/TestTools/random.h index 4b44f9f32f059016cd77f8107b4f4309779689b8..649074c600fd7120b4dd34988bd146a907b6769d 100644 --- a/AtlasTest/TestTools/TestTools/random.h +++ b/AtlasTest/TestTools/TestTools/random.h @@ -23,6 +23,14 @@ #define TESTTOOLS_RANDOM_H +// Can't use CxxUtils/checker_macros.h here, since that would be circular dependency. +#ifdef ATLAS_GCC_CHECKERS +#define ATLAS_NOT_REENTRANT [[gnu::not_reentrant]] +#else +#define ATLAS_NOT_REENTRANT +#endif + + #include <stdint.h> @@ -30,7 +38,7 @@ namespace Athena_test { /// Maximum number generated. -static uint32_t rngmax = static_cast<uint32_t> (-1); +static const uint32_t rngmax = static_cast<uint32_t> (-1); /// Generate a random number between 0 and @c rngmax @@ -59,8 +67,8 @@ int randi_seed (uint32_t& seed, int rmax, int rmin = 0) struct RNG { RNG() : seed(1) {} - int operator() (int n) const { return randi_seed (seed, n); } - mutable uint32_t seed; + int operator() (int n) { return randi_seed (seed, n); } + uint32_t seed; }; @@ -69,17 +77,17 @@ struct URNG { typedef uint32_t result_type; URNG() : seed(1) {} - static result_type min() { return 0; } - static result_type max() { return 1000000; } - result_type operator()() const { return randi_seed (seed, max()); } - mutable uint32_t seed; + static constexpr result_type min() { return 0; } + static constexpr result_type max() { return 1000000; } + result_type operator()() { return randi_seed (seed, max()); } + uint32_t seed; }; uint32_t seed = 1; -uint32_t rng() { return rng_seed(seed); } -int randi (int rmax, int rmin = 0) { return randi_seed (seed, rmax, rmin); } -float randf (float rmax, float rmin = 0) { return randf_seed (seed, rmax, rmin); } +uint32_t rng ATLAS_NOT_REENTRANT () { return rng_seed(seed); } +int randi ATLAS_NOT_REENTRANT (int rmax, int rmin = 0) { return randi_seed (seed, rmax, rmin); } +float randf ATLAS_NOT_REENTRANT (float rmax, float rmin = 0) { return randf_seed (seed, rmax, rmin); }