aboutsummaryrefslogtreecommitdiffstats
path: root/test/mppa/lib/prng.c
diff options
context:
space:
mode:
authorCyril SIX <cyril.six@kalray.eu>2018-04-17 09:59:42 +0200
committerCyril SIX <cyril.six@kalray.eu>2018-04-17 09:59:42 +0200
commitc740492e7a5c14a524c31bbc769a07af2e2ac6be (patch)
treef0e512f3a9fbacbda5fa146a900ec5d403928e73 /test/mppa/lib/prng.c
parentb26424165aa5ae75099792232eca9ea08e09d5a1 (diff)
downloadcompcert-kvx-c740492e7a5c14a524c31bbc769a07af2e2ac6be.tar.gz
compcert-kvx-c740492e7a5c14a524c31bbc769a07af2e2ac6be.zip
MPPA - Added uint64_t types to the tests + k1c test
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);
}