aboutsummaryrefslogtreecommitdiffstats
path: root/test/mppa/lib/prng.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/mppa/lib/prng.c')
-rw-r--r--test/mppa/lib/prng.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/test/mppa/lib/prng.c b/test/mppa/lib/prng.c
index 5846038c..bfc38678 100644
--- a/test/mppa/lib/prng.c
+++ b/test/mppa/lib/prng.c
@@ -1,25 +1,27 @@
// https://en.wikipedia.org/wiki/Linear_congruential_generator -> MMIX Donald Knuth
// modulo 2^64 = no need to do it explicitly
+#include "types.h"
+
#define MULTIPLIER 6364136223846793005LL
#define INCREMENT 1442695040888963407LL
-static unsigned long long current;
+static uint64_t current;
-void srand(long long seed){
+void srand(uint64_t seed){
seed = current;
}
-unsigned long long randlong(void){
+uint64_t randlong(void){
return (current = MULTIPLIER * current + INCREMENT);
}
#ifdef __UNIT_TEST__
-char bytewise_sum(unsigned long long to_check){
+char bytewise_sum(uint64_t to_check){
char sum = 0;
for (int i = 0 ; i < 8 ; i++)
- sum += (to_check & (unsigned long long)(0xFFULL << i*8)) >> i*8;
+ sum += (to_check & (uint64_t)(0xFFULL << i*8)) >> i*8;
return sum;
}
@@ -33,7 +35,7 @@ int main(void){
for (int i = 0 ; i < 1000 ; i++)
randlong();
- unsigned long long last = randlong();
+ uint64_t last = randlong();
return !((unsigned char)bytewise_sum(last) == 251);
}