aboutsummaryrefslogtreecommitdiffstats
path: root/test/c/lists.c
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-03-03 08:17:40 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-03-03 08:17:40 +0100
commit1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68 (patch)
tree210ffc156c83f04fb0c61a40b4f9037d7ba8a7e1 /test/c/lists.c
parent222c9047d61961db9c6b19fed5ca49829223fd33 (diff)
parent12be46d59a2483a10d77fa8ee67f7e0ca1bd702f (diff)
downloadcompcert-kvx-1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68.tar.gz
compcert-kvx-1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68.zip
Merge branch 'mppa-cse2' of gricad-gitlab.univ-grenoble-alpes.fr:sixcy/CompCert into mppa-work
Diffstat (limited to 'test/c/lists.c')
-rw-r--r--test/c/lists.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/c/lists.c b/test/c/lists.c
index ced384c0..8deb0f37 100644
--- a/test/c/lists.c
+++ b/test/c/lists.c
@@ -1,5 +1,6 @@
/* List manipulations */
+#include <assert.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
@@ -11,6 +12,7 @@ struct list * buildlist(int n)
struct list * r;
if (n < 0) return NULL;
r = malloc(sizeof(struct list));
+ assert(r != NULL && "buildlist: r malloc failed");
r->hd = n;
r->tl = buildlist(n - 1);
return r;
@@ -21,6 +23,7 @@ struct list * reverselist (struct list * l)
struct list * r, * r2;
for (r = NULL; l != NULL; l = l->tl) {
r2 = malloc(sizeof(struct list));
+ assert(r2 != NULL && "reverselist: r2 malloc failed");
r2->hd = l->hd;
r2->tl = r;
r = r2;
@@ -58,8 +61,13 @@ int main(int argc, char ** argv)
int n, niter, i;
struct list * l;
+#ifdef __K1C__
+ if (argc >= 2) n = atoi(argv[1]); else n = 500;
+ if (argc >= 3) niter = atoi(argv[1]); else niter = 100;
+#else
if (argc >= 2) n = atoi(argv[1]); else n = 1000;
if (argc >= 3) niter = atoi(argv[1]); else niter = 20000;
+#endif
l = buildlist(n);
if (checklist(n, reverselist(l))) {
printf("OK\n");