From: Søren Sandmann Pedersen <[email protected]>
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
_______________________________________________
Pixman mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pixman