From c740492e7a5c14a524c31bbc769a07af2e2ac6be Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Tue, 17 Apr 2018 09:59:42 +0200 Subject: MPPA - Added uint64_t types to the tests + k1c test --- test/mppa/lib/prng.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'test/mppa/lib/prng.c') 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); } -- cgit