From d5d547b7315c9deae74ead71ef434e9f25c674f7 Mon Sep 17 00:00:00 2001 From: Tylo Date: Mon, 15 Jun 2020 20:46:00 +0200 Subject: Compile on Linux. --- benchmark.c | 10 +++++----- demos.c | 6 +++--- rngtest.c | 10 +++++----- stc/cstring.h | 2 ++ 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/benchmark.c b/benchmark.c index d304e711..2222453a 100644 --- a/benchmark.c +++ b/benchmark.c @@ -78,7 +78,7 @@ const double maxLoadFactor = 0.77; const size_t N1 = 7000000; const size_t N2 = 10000000; -#define RR 24 +#define RR 20 int rr = RR; @@ -93,7 +93,7 @@ int rr = RR; erased += M##_ERASE(tag, RAND(rr)); \ } \ difference = clock() - before; \ - printf(#M "(" #tag "): sz: %llu, bucks: %llu, time: %.02f, sum: %llu, erase: %llu\n", \ + printf(#M "(" #tag "): sz: %zu, bucks: %zu, time: %.02f, sum: %zu, erase: %zu\n", \ M##_SIZE(tag), M##_BUCKETS(tag), (float) difference / CLOCKS_PER_SEC, checksum, erased); \ M##_CLEAR(tag); \ } @@ -109,7 +109,7 @@ int rr = RR; for (size_t i = 0; i < N2; ++i) \ erased += M##_ERASE(tag, i*17); \ difference = clock() - before; \ - printf(#M "(" #tag "): sz: %llu, bucks: %llu, time: %.02f, erase %llu\n", \ + printf(#M "(" #tag "): sz: %zu, bucks: %zu, time: %.02f, erase %zu\n", \ M##_SIZE(tag), M##_BUCKETS(tag), (float) difference / CLOCKS_PER_SEC, erased); \ M##_CLEAR(tag); \ } @@ -118,7 +118,7 @@ int rr = RR; int main(int argc, char* argv[]) { rr = argc == 2 ? atoi(argv[1]) : RR; - printf("\nmap: Insert + remove %llu random keys in range 0 - 2^%d:\n", N1, rr); + printf("\nmap: Insert + remove %zu random keys in range 0 - 2^%d:\n", N1, rr); MAP_TEST1(CMAP, ii) MAP_TEST1(KMAP, ii) #ifdef __cplusplus @@ -128,7 +128,7 @@ int main(int argc, char* argv[]) MAP_TEST1(RMAP, ii) #endif - printf("\nmap: Insert %llu keys, THEN remove them in same order:\n", N2); + printf("\nmap: Insert %zu keys, THEN remove them in same order:\n", N2); MAP_TEST2(CMAP, ii) MAP_TEST2(KMAP, ii) #ifdef __cplusplus diff --git a/demos.c b/demos.c index d9a0824c..a93be53a 100644 --- a/demos.c +++ b/demos.c @@ -43,11 +43,11 @@ void vectordemo1() for (size_t i = 0; i<=100; ++i) cvector_ix_pushBack(&bignums, i * i * i); - printf("erase - %llu: %llu\n", 100, bignums.data[100]); + printf("erase - %d: %zu\n", 100, bignums.data[100]); cvector_ix_popBack(&bignums); // erase the last for (size_t i = 0; i < cvector_size(bignums); ++i) { - if (i >= 90) printf("%llu: %llu\n", i, bignums.data[i]); + if (i >= 90) printf("%zu: %zu\n", i, bignums.data[i]); } cvector_ix_destroy(&bignums); } @@ -149,7 +149,7 @@ void mapdemo3() printf("remove: Make: %s\n", cmap_ss_get(&table, "Make")->value.str); cmap_ss_erase(&table, "Make"); - printf("size %llu\n", cmap_size(table)); + printf("size %zu\n", cmap_size(table)); c_foreach (i, cmap_ss, table) printf("key: %s\n", i.item->key.str); cmap_ss_destroy(&table); // frees key and value CStrings, and hash table (CVector). diff --git a/rngtest.c b/rngtest.c index 5ca8ec6b..ead389ff 100644 --- a/rngtest.c +++ b/rngtest.c @@ -24,7 +24,7 @@ int main(void) v += mt19937_rand(&state); } difference = clock() - before; - printf("my-mt: %.02f, %llu\n", (float) difference / CLOCKS_PER_SEC, v); + printf("my-mt: %.02f, %zu\n", (float) difference / CLOCKS_PER_SEC, v); #ifdef __cplusplus std::mt19937 mt_rand; @@ -34,7 +34,7 @@ int main(void) v += mt_rand(); } difference = clock() - before; - printf("c++mt: %.02f, %llu\n", (float) difference / CLOCKS_PER_SEC, v); + printf("c++mt: %.02f, %zu\n", (float) difference / CLOCKS_PER_SEC, v); #endif xoroshiro128ss_t xo = xoroshiro128ss_seed(1234); @@ -44,7 +44,7 @@ int main(void) v += xoroshiro128ss_rand(&xo) & 0xffffffff; } difference = clock() - before; - printf("xoros: %.02f, %llu\n", (float) difference / CLOCKS_PER_SEC, v); + printf("xoros: %.02f, %zu\n", (float) difference / CLOCKS_PER_SEC, v); sfc64_t sfc = sfc64_seed(1234); @@ -54,7 +54,7 @@ int main(void) v += sfc64_rand(&sfc) & 0xffffffff; } difference = clock() - before; - printf("sfc64: %.02f, %llu\n", (float) difference / CLOCKS_PER_SEC, v); + printf("sfc64: %.02f, %zu\n", (float) difference / CLOCKS_PER_SEC, v); /* before = clock(); \ @@ -63,6 +63,6 @@ int main(void) v += rand(); } difference = clock() - before; - printf("rand : %.02f, %llu\n", (float) difference / CLOCKS_PER_SEC, v); + printf("rand : %.02f, %zu\n", (float) difference / CLOCKS_PER_SEC, v); */ } \ No newline at end of file diff --git a/stc/cstring.h b/stc/cstring.h index f03cbc6e..cf635be8 100644 --- a/stc/cstring.h +++ b/stc/cstring.h @@ -23,7 +23,9 @@ #ifndef CSTRING__H__ #define CSTRING__H__ +#include /* alloca */ #include +#include #include #include #include -- cgit v1.2.3