[Pixman] [PATCH 1/4] Fix lcg_rand_u32() to return 32 random bits.
Søren Sandmann
sandmann at cs.au.dk
Wed Aug 3 19:21:17 PDT 2011
From: Søren Sandmann Pedersen <ssp at redhat.com>
The lcg_rand() function only returns 15 random bits, so lcg_rand_u32()
would always have 0 in bit 31 and bit 15. Fix that by calling
lcg_rand() three times, to generate 15, 15, and 2 random bits
respectively.
---
test/utils.h | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/test/utils.h b/test/utils.h
index 615ad78..a249627 100644
--- a/test/utils.h
+++ b/test/utils.h
@@ -45,9 +45,10 @@ static inline uint32_t
lcg_rand_u32 (void)
{
uint32_t lo = lcg_rand();
- uint32_t hi = lcg_rand();
+ uint32_t mid = lcg_rand() << 15;
+ uint32_t hi = lcg_rand() << 30;
- return (hi << 16) | lo;
+ return (hi | mid | lo);
}
/* CRC 32 computation
--
1.7.4
More information about the Pixman
mailing list