commit 97b9dfe3052f1fe3b14f47fc1326e235f96305b7 Author: Nick Mathewson nickm@torproject.org Date: Wed Feb 20 12:21:05 2019 -0500
Add a convenience macro to get a fast one-in-n calculation --- src/lib/crypt_ops/crypto_rand.h | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/lib/crypt_ops/crypto_rand.h b/src/lib/crypt_ops/crypto_rand.h index 6eef22ed4..bb424fd69 100644 --- a/src/lib/crypt_ops/crypto_rand.h +++ b/src/lib/crypt_ops/crypto_rand.h @@ -68,6 +68,9 @@ unsigned crypto_fast_rng_get_uint(crypto_fast_rng_t *rng, unsigned limit); uint64_t crypto_fast_rng_get_uint64(crypto_fast_rng_t *rng, uint64_t limit); double crypto_fast_rng_get_double(crypto_fast_rng_t *rng);
+#define crypto_fast_rng_one_in_n(rng, n) \ + (0 == (crypto_fast_rng_get_uint((rng), (n)))) + crypto_fast_rng_t *get_thread_fast_rng(void);
#ifdef CRYPTO_PRIVATE
tor-commits@lists.torproject.org