aboutsummaryrefslogtreecommitdiffstats
path: root/test/mppa/lib
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
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')
-rw-r--r--test/mppa/lib/Makefile18
-rw-r--r--test/mppa/lib/prng.c14
-rw-r--r--test/mppa/lib/prng.h6
-rw-r--r--test/mppa/lib/types.h7
4 files changed, 34 insertions, 11 deletions
diff --git a/test/mppa/lib/Makefile b/test/mppa/lib/Makefile
index 10f40f23..e6a75707 100644
--- a/test/mppa/lib/Makefile
+++ b/test/mppa/lib/Makefile
@@ -1,8 +1,11 @@
prng-test-x86: prng.c
gcc -D__UNIT_TEST__ -O2 -std=c99 $< -o $@
+prng-test-k1c: prng.c
+ k1-gcc -D__UNIT_TEST__ -O2 -std=c99 $< -o $@
+
.PHONY:
-test: test-x86
+test: test-x86 test-k1c
.PHONY:
test-x86: prng-test-x86
@@ -10,9 +13,18 @@ test-x86: prng-test-x86
>&2 echo "ERROR: $< failed";\
exit;\
else\
- echo "Test Succeeded";\
+ echo "x86: Test Succeeded";\
+ fi
+
+.PHONY:
+test-k1c: prng-test-k1c
+ @if ! k1-cluster -- ./$<; then\
+ >&2 echo "ERROR: $< failed";\
+ exit;\
+ else\
+ echo "k1c: Test Succeeded";\
fi
.PHONY:
clean:
- rm -f prng-test-x86
+ rm -f prng-test-x86 prng-test-k1c
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);
}
diff --git a/test/mppa/lib/prng.h b/test/mppa/lib/prng.h
index fee8c865..6abdb45a 100644
--- a/test/mppa/lib/prng.h
+++ b/test/mppa/lib/prng.h
@@ -1,8 +1,10 @@
#ifndef __PRNG_H__
#define __PRNG_H__
-void srand(long long seed);
+#include "types.h"
-long long randlong(void);
+void srand(uint64_t seed);
+
+uint64_t randlong(void);
#endif // __PRNG_H__
diff --git a/test/mppa/lib/types.h b/test/mppa/lib/types.h
new file mode 100644
index 00000000..584023e3
--- /dev/null
+++ b/test/mppa/lib/types.h
@@ -0,0 +1,7 @@
+#ifndef __TYPES_H__
+#define __TYPES_H__
+
+#define uint64_t unsigned long long
+#define int64_t signed long long
+
+#endif // __TYPES_H__