fix non-developer build with assertions

This commit is contained in:
Andrei Alexeyev 2020-03-08 14:17:26 +02:00
parent 673a73cf76
commit 8c78c5e08c
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
2 changed files with 3 additions and 1 deletions

View file

@ -73,7 +73,7 @@ void rng_make_active(RandomState *rng) {
}
rng_val_t rng_next_p(RandomState *rng) {
assert(!rng->locked);
assert(!rng_is_locked(rng));
return (rng_val_t) { xoshiro256plus(rng->state) };
}

View file

@ -40,9 +40,11 @@ rng_val_t rng_next_p(RandomState *rng) attr_nonnull(1);
#ifdef DEBUG
INLINE void rng_lock(RandomState *rng) { rng->locked = true; }
INLINE void rng_unlock(RandomState *rng) { rng->locked = false; }
INLINE bool rng_is_locked(RandomState *rng) { return rng->locked; }
#else
#define rng_lock(rng) (rng, (void)0)
#define rng_unlock(rng) (rng, (void)0)
#define rng_is_locked(rng) (false)
#endif
// NOTE: if you rename this, also update scripts/upkeep/check-rng-usage.py!