diff options
author | David Robillard <d@drobilla.net> | 2021-09-10 20:11:27 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-09-10 20:11:27 -0400 |
commit | b45b6b442f0e3f821921a48f957944f485adfd1b (patch) | |
tree | 8c90c3b6842b66f4708ab415e500e1eed41fe0b0 /test/test_data.h | |
parent | 87ae32d754d211d1f6510af098c2349a28f17351 (diff) | |
download | zix-b45b6b442f0e3f821921a48f957944f485adfd1b.tar.gz zix-b45b6b442f0e3f821921a48f957944f485adfd1b.tar.bz2 zix-b45b6b442f0e3f821921a48f957944f485adfd1b.zip |
Fix conversion warnings
Diffstat (limited to 'test/test_data.h')
-rw-r--r-- | test/test_data.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/test/test_data.h b/test/test_data.h index 9c9a51d..405b716 100644 --- a/test/test_data.h +++ b/test/test_data.h @@ -40,6 +40,17 @@ lcg64(const uint64_t i) return (a * i) + c; } +/// Linear Congruential Generator for making random pointer-sized integers +static inline uintptr_t +lcg(const uintptr_t i) +{ +#if UINTPTR_MAX >= UINT64_MAX + return lcg64(i); +#else + return lcg32(i); +#endif +} + /// Return a pseudo-pseudo-pseudo-random-ish integer with no duplicates static inline size_t unique_rand(size_t i) @@ -52,7 +63,7 @@ unique_rand(size_t i) return i; // Values >= prime are mapped to themselves } - const size_t residue = ((uint64_t)i * i) % prime; + const size_t residue = (size_t)(((uint64_t)i * i) % prime); return (i <= prime / 2) ? residue : prime - residue; } |