[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tyson Smith <tyson.w.smith@xxxxxxxxx>

---
 random.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/random.c b/random.c
index 7917f78..8b4f715 100644
--- a/random.c
+++ b/random.c
@@ -171,15 +171,9 @@ u64 rand64(void)
 	if (ONE_IN(25))
 		r = ~r;
 
-	/* increase distribution in MSB */
-	if (ONE_IN(10)) {
-		unsigned int i;
-		unsigned int rounds;
-
-		rounds = rand() % 4;
-		for (i = 0; i < rounds; i++)
-			r |= (1UL << ((__WORDSIZE - 1) - (rand() % 8)));
-	}
+	/* Set ~2 bits in MSB to increase distribution */
+	if (ONE_IN(10))
+		r |= (rand() & rand() & 0xffULL) << 56;
 
 	/* Sometimes flip sign */
 	if (ONE_IN(25))
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe trinity" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux