Changeset View
Changeset View
Standalone View
Standalone View
src/test/test_bitcoin.h
Show All 16 Lines | |||||
* Version of Boost::test prior to 1.64 have issues when dealing with nullptr_t. | * Version of Boost::test prior to 1.64 have issues when dealing with nullptr_t. | ||||
* In order to work around this, we ensure that the null pointers are typed in a | * In order to work around this, we ensure that the null pointers are typed in a | ||||
* way that Boost will like better. | * way that Boost will like better. | ||||
* | * | ||||
* TODO: Use nullptr directly once the minimum version of boost is 1.64 or more. | * TODO: Use nullptr directly once the minimum version of boost is 1.64 or more. | ||||
*/ | */ | ||||
#define NULLPTR(T) static_cast<T *>(nullptr) | #define NULLPTR(T) static_cast<T *>(nullptr) | ||||
thread_local extern FastRandomContext g_insecure_rand_ctx; | /** | ||||
* This global and the helpers that use it are not thread-safe. | |||||
* | |||||
* If thread-safety is needed, the global could be made thread_local (given | |||||
* that thread_local is supported on all architectures we support) or a | |||||
* per-thread instance could be used in the multi-threaded test. | |||||
*/ | |||||
extern FastRandomContext g_insecure_rand_ctx; | |||||
static inline void SeedInsecureRand(bool deterministic = false) { | static inline void SeedInsecureRand(bool deterministic = false) { | ||||
g_insecure_rand_ctx = FastRandomContext(deterministic); | g_insecure_rand_ctx = FastRandomContext(deterministic); | ||||
} | } | ||||
static inline uint32_t InsecureRand32() { | static inline uint32_t InsecureRand32() { | ||||
return g_insecure_rand_ctx.rand32(); | return g_insecure_rand_ctx.rand32(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 131 Lines • Show Last 20 Lines |