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

 



From: Tyson Smith <tysmith@xxxxxxxxxxxx>

I believe this is what was intended, previously the high bit was just being set.
Perhaps it was meant to be toggled? If that is the case we can add that too.
---
 random.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/random.c b/random.c
index ec20656..d671035 100644
--- a/random.c
+++ b/random.c
@@ -130,7 +130,7 @@ unsigned int rand32(void)
 
 	/* Sometimes flip sign */
 	if (rand_bool())
-		r |= (1L << 31);
+		r = ~r + 1;
 
 	/* we might get lucky if something is counting ints/longs etc. */
 	if (ONE_IN(4)) {
@@ -206,9 +206,9 @@ u64 rand64(void)
 			r |= (1UL << ((__WORDSIZE - 1) - (rand() % 8)));
 	}
 
-	/* randomly flip sign bit. */
+	/* Sometimes flip sign */
 	if (rand_bool())
-		r |= (1UL << (__WORDSIZE - 1));
+		r = ~r + 1;
 
 	return r;
 }
-- 
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