From c773d8b1f41d5c2ceb228c44a9958e22db0990e2 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Fri, 7 Jul 2023 17:41:07 +0200 Subject: Backported fixes on issues #60 and #62 to STC 4.2. Note that cbits now uses long long for indices and sizes in the API, which is easier to print with "%lld", and is at least 64 bits. --- include/stc/cbits.h | 94 ++++++++++++++++++++++------------------------- include/stc/ccommon.h | 5 ++- misc/examples/bits.c | 12 +++--- misc/examples/bits2.c | 4 +- misc/examples/intrusive.c | 2 +- 5 files changed, 56 insertions(+), 61 deletions(-) diff --git a/include/stc/cbits.h b/include/stc/cbits.h index 826df847..9463c82c 100644 --- a/include/stc/cbits.h +++ b/include/stc/cbits.h @@ -31,7 +31,7 @@ int main() { cbits_reset(&bset, 9); cbits_resize(&bset, 43, false); - printf("%4zu: ", cbits_size(&bset)); + printf("%4lld: ", cbits_size(&bset)); c_forrange (i, cbits_size(&bset)) printf("%d", cbits_at(&bset, i)); puts(""); @@ -41,7 +41,7 @@ int main() { cbits_resize(&bset, 102, true); cbits_set_value(&bset, 99, false); - printf("%4zu: ", cbits_size(&bset)); + printf("%4lld: ", cbits_size(&bset)); c_forrange (i, cbits_size(&bset)) printf("%d", cbits_at(&bset, i)); puts(""); @@ -54,11 +54,8 @@ int main() { #include #include -#ifndef i_ssize -#define i_ssize intptr_t -#endif #define _cbits_bit(i) ((uint64_t)1 << ((i) & 63)) -#define _cbits_words(n) (i_ssize)(((n) + 63)>>6) +#define _cbits_words(n) (_llong)(((n) + 63)>>6) #define _cbits_bytes(n) (_cbits_words(n) * c_sizeof(uint64_t)) #if defined(__GNUC__) @@ -80,23 +77,23 @@ int main() { } #endif -STC_INLINE i_ssize _cbits_count(const uint64_t* set, const i_ssize sz) { - const i_ssize n = sz>>6; - i_ssize count = 0; - for (i_ssize i = 0; i < n; ++i) +STC_INLINE _llong _cbits_count(const uint64_t* set, const _llong sz) { + const _llong n = sz>>6; + _llong count = 0; + for (_llong i = 0; i < n; ++i) count += cpopcount64(set[i]); if (sz & 63) count += cpopcount64(set[n] & (_cbits_bit(sz) - 1)); return count; } -STC_INLINE char* _cbits_to_str(const uint64_t* set, const i_ssize sz, - char* out, i_ssize start, i_ssize stop) { +STC_INLINE char* _cbits_to_str(const uint64_t* set, const _llong sz, + char* out, _llong start, _llong stop) { if (stop > sz) stop = sz; assert(start <= stop); c_memset(out, '0', stop - start); - for (i_ssize i = start; i < stop; ++i) + for (_llong i = start; i < stop; ++i) if ((set[i>>6] & _cbits_bit(i)) != 0) out[i - start] = '1'; out[stop - start] = '\0'; @@ -104,8 +101,8 @@ STC_INLINE char* _cbits_to_str(const uint64_t* set, const i_ssize sz, } #define _cbits_OPR(OPR, VAL) \ - const i_ssize n = sz>>6; \ - for (i_ssize i = 0; i < n; ++i) \ + const _llong n = sz>>6; \ + for (_llong i = 0; i < n; ++i) \ if ((set[i] OPR other[i]) != VAL) \ return false; \ if (!(sz & 63)) \ @@ -113,10 +110,10 @@ STC_INLINE char* _cbits_to_str(const uint64_t* set, const i_ssize sz, const uint64_t i = (uint64_t)n, m = _cbits_bit(sz) - 1; \ return ((set[i] OPR other[i]) & m) == (VAL & m) -STC_INLINE bool _cbits_subset_of(const uint64_t* set, const uint64_t* other, const i_ssize sz) +STC_INLINE bool _cbits_subset_of(const uint64_t* set, const uint64_t* other, const _llong sz) { _cbits_OPR(|, set[i]); } -STC_INLINE bool _cbits_disjoint(const uint64_t* set, const uint64_t* other, const i_ssize sz) +STC_INLINE bool _cbits_disjoint(const uint64_t* set, const uint64_t* other, const _llong sz) { _cbits_OPR(&, 0); } #endif // CBITS_H_INCLUDED @@ -128,12 +125,11 @@ STC_INLINE bool _cbits_disjoint(const uint64_t* set, const uint64_t* other, cons #define _i_assert(x) assert(x) #define i_type cbits -struct { uint64_t *data64; i_ssize _size; } typedef i_type; +typedef struct { uint64_t *data64; _llong _size; } i_type; STC_INLINE cbits cbits_init(void) { return c_LITERAL(cbits){NULL}; } -STC_INLINE void cbits_create(cbits* self) { self->data64 = NULL; self->_size = 0; } STC_INLINE void cbits_drop(cbits* self) { c_free(self->data64); } -STC_INLINE i_ssize cbits_size(const cbits* self) { return self->_size; } +STC_INLINE _llong cbits_size(const cbits* self) { return self->_size; } STC_INLINE cbits* cbits_take(cbits* self, cbits other) { if (self->data64 != other.data64) { @@ -144,7 +140,7 @@ STC_INLINE cbits* cbits_take(cbits* self, cbits other) { } STC_INLINE cbits cbits_clone(cbits other) { - const i_ssize bytes = _cbits_bytes(other._size); + const _llong bytes = _cbits_bytes(other._size); cbits set = {(uint64_t *)c_memcpy(c_malloc(bytes), other.data64, bytes), other._size}; return set; } @@ -158,16 +154,16 @@ STC_INLINE cbits* cbits_copy(cbits* self, const cbits* other) { return self; } -STC_INLINE void cbits_resize(cbits* self, const i_ssize size, const bool value) { - const i_ssize new_n = _cbits_words(size), osize = self->_size, old_n = _cbits_words(osize); +STC_INLINE void cbits_resize(cbits* self, const _llong size, const bool value) { + const _llong new_n = _cbits_words(size), osize = self->_size, old_n = _cbits_words(osize); self->data64 = (uint64_t *)c_realloc(self->data64, new_n*8); self->_size = size; if (new_n >= old_n) { c_memset(self->data64 + old_n, -(int)value, (new_n - old_n)*8); if (old_n > 0) { - uint64_t m = _cbits_bit(osize) - 1; /* mask */ - value ? (self->data64[old_n - 1] |= ~m) - : (self->data64[old_n - 1] &= m); + uint64_t mask = _cbits_bit(osize) - 1; + if (value) self->data64[old_n - 1] |= ~mask; + else self->data64[old_n - 1] &= mask; } } } @@ -181,13 +177,13 @@ STC_INLINE cbits cbits_move(cbits* self) { return tmp; } -STC_INLINE cbits cbits_with_size(const i_ssize size, const bool value) { +STC_INLINE cbits cbits_with_size(const _llong size, const bool value) { cbits set = {(uint64_t *)c_malloc(_cbits_bytes(size)), size}; cbits_set_all(&set, value); return set; } -STC_INLINE cbits cbits_with_pattern(const i_ssize size, const uint64_t pattern) { +STC_INLINE cbits cbits_with_pattern(const _llong size, const uint64_t pattern) { cbits set = {(uint64_t *)c_malloc(_cbits_bytes(size)), size}; cbits_set_pattern(&set, pattern); return set; @@ -200,12 +196,11 @@ STC_INLINE cbits cbits_with_pattern(const i_ssize size, const uint64_t pattern) #define i_type c_PASTE(cbits, i_capacity) #endif -struct { uint64_t data64[(i_capacity - 1)/64 + 1]; } typedef i_type; +typedef struct { uint64_t data64[(i_capacity - 1)/64 + 1]; } i_type; -STC_INLINE i_type _i_memb(_init)(void) { return c_LITERAL(i_type){0}; } -STC_INLINE void _i_memb(_create)(i_type* self) {} +STC_INLINE void _i_memb(_init)(i_type* self) { memset(self->data64, 0, i_capacity*8); } STC_INLINE void _i_memb(_drop)(i_type* self) {} -STC_INLINE i_ssize _i_memb(_size)(const i_type* self) { return i_capacity; } +STC_INLINE _llong _i_memb(_size)(const i_type* self) { return i_capacity; } STC_INLINE i_type _i_memb(_move)(i_type* self) { return *self; } STC_INLINE i_type* _i_memb(_take)(i_type* self, i_type other) @@ -216,17 +211,17 @@ STC_INLINE i_type _i_memb(_clone)(i_type other) STC_INLINE i_type* _i_memb(_copy)(i_type* self, const i_type* other) { *self = *other; return self; } - + STC_INLINE void _i_memb(_set_all)(i_type *self, const bool value); STC_INLINE void _i_memb(_set_pattern)(i_type *self, const uint64_t pattern); -STC_INLINE i_type _i_memb(_with_size)(const i_ssize size, const bool value) { +STC_INLINE i_type _i_memb(_with_size)(const _llong size, const bool value) { assert(size <= i_capacity); i_type set; _i_memb(_set_all)(&set, value); return set; } -STC_INLINE i_type _i_memb(_with_pattern)(const i_ssize size, const uint64_t pattern) { +STC_INLINE i_type _i_memb(_with_pattern)(const _llong size, const uint64_t pattern) { assert(size <= i_capacity); i_type set; _i_memb(_set_pattern)(&set, pattern); return set; @@ -239,36 +234,36 @@ STC_INLINE void _i_memb(_set_all)(i_type *self, const bool value) { c_memset(self->data64, value? ~0 : 0, _cbits_bytes(_i_memb(_size)(self))); } STC_INLINE void _i_memb(_set_pattern)(i_type *self, const uint64_t pattern) { - i_ssize n = _cbits_words(_i_memb(_size)(self)); + _llong n = _cbits_words(_i_memb(_size)(self)); while (n--) self->data64[n] = pattern; } -STC_INLINE bool _i_memb(_test)(const i_type* self, const i_ssize i) +STC_INLINE bool _i_memb(_test)(const i_type* self, const _llong i) { return (self->data64[i>>6] & _cbits_bit(i)) != 0; } -STC_INLINE bool _i_memb(_at)(const i_type* self, const i_ssize i) +STC_INLINE bool _i_memb(_at)(const i_type* self, const _llong i) { return (self->data64[i>>6] & _cbits_bit(i)) != 0; } -STC_INLINE void _i_memb(_set)(i_type *self, const i_ssize i) +STC_INLINE void _i_memb(_set)(i_type *self, const _llong i) { self->data64[i>>6] |= _cbits_bit(i); } -STC_INLINE void _i_memb(_reset)(i_type *self, const i_ssize i) +STC_INLINE void _i_memb(_reset)(i_type *self, const _llong i) { self->data64[i>>6] &= ~_cbits_bit(i); } -STC_INLINE void _i_memb(_set_value)(i_type *self, const i_ssize i, const bool b) { +STC_INLINE void _i_memb(_set_value)(i_type *self, const _llong i, const bool b) { self->data64[i>>6] ^= ((uint64_t)-(int)b ^ self->data64[i>>6]) & _cbits_bit(i); } -STC_INLINE void _i_memb(_flip)(i_type *self, const i_ssize i) +STC_INLINE void _i_memb(_flip)(i_type *self, const _llong i) { self->data64[i>>6] ^= _cbits_bit(i); } STC_INLINE void _i_memb(_flip_all)(i_type *self) { - i_ssize n = _cbits_words(_i_memb(_size)(self)); + _llong n = _cbits_words(_i_memb(_size)(self)); while (n--) self->data64[n] ^= ~(uint64_t)0; } STC_INLINE i_type _i_memb(_from)(const char* str) { - int64_t n = c_strlen(str); + _llong n = c_strlen(str); i_type set = _i_memb(_with_size)(n, false); while (n--) if (str[n] == '1') _i_memb(_set)(&set, n); return set; @@ -277,26 +272,26 @@ STC_INLINE i_type _i_memb(_from)(const char* str) { /* Intersection */ STC_INLINE void _i_memb(_intersect)(i_type *self, const i_type* other) { _i_assert(self->_size == other->_size); - i_ssize n = _cbits_words(_i_memb(_size)(self)); + _llong n = _cbits_words(_i_memb(_size)(self)); while (n--) self->data64[n] &= other->data64[n]; } /* Union */ STC_INLINE void _i_memb(_union)(i_type *self, const i_type* other) { _i_assert(self->_size == other->_size); - i_ssize n = _cbits_words(_i_memb(_size)(self)); + _llong n = _cbits_words(_i_memb(_size)(self)); while (n--) self->data64[n] |= other->data64[n]; } /* Exclusive disjunction */ STC_INLINE void _i_memb(_xor)(i_type *self, const i_type* other) { _i_assert(self->_size == other->_size); - i_ssize n = _cbits_words(_i_memb(_size)(self)); + _llong n = _cbits_words(_i_memb(_size)(self)); while (n--) self->data64[n] ^= other->data64[n]; } -STC_INLINE int64_t _i_memb(_count)(const i_type* self) +STC_INLINE _llong _i_memb(_count)(const i_type* self) { return _cbits_count(self->data64, _i_memb(_size)(self)); } -STC_INLINE char* _i_memb(_to_str)(const i_type* self, char* out, int64_t start, int64_t stop) +STC_INLINE char* _i_memb(_to_str)(const i_type* self, char* out, _llong start, _llong stop) { return _cbits_to_str(self->data64, _i_memb(_size)(self), out, start, stop); } STC_INLINE bool _i_memb(_subset_of)(const i_type* self, const i_type* other) { @@ -312,7 +307,6 @@ STC_INLINE bool _i_memb(_disjoint)(const i_type* self, const i_type* other) { #pragma GCC diagnostic pop #endif #define CBITS_H_INCLUDED -#undef _i_size #undef _i_memb #undef _i_assert #undef i_capacity diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index d5508807..38dc2bd9 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -32,6 +32,7 @@ #include "priv/altnames.h" #include "priv/raii.h" +typedef long long _llong; #define c_NPOS INTPTR_MAX #define c_ZI PRIiPTR #define c_ZU PRIuPTR @@ -71,8 +72,8 @@ #define c_LITERAL(T) T #else #define _i_alloc(T) ((T*)i_malloc(c_sizeof(T))) - #define _i_new(T, ...) ((T*)memcpy(_i_alloc(T), (T[]){__VA_ARGS__}, sizeof(T))) - #define c_new(T, ...) ((T*)memcpy(malloc(sizeof(T)), (T[]){__VA_ARGS__}, sizeof(T))) + #define _i_new(T, ...) ((T*)memcpy(_i_alloc(T), ((T[]){__VA_ARGS__}), sizeof(T))) + #define c_new(T, ...) ((T*)memcpy(malloc(sizeof(T)), ((T[]){__VA_ARGS__}), sizeof(T))) #define c_LITERAL(T) (T) #endif #define c_malloc(sz) malloc(c_i2u(sz)) diff --git a/misc/examples/bits.c b/misc/examples/bits.c index 1323d4e7..e0a11346 100644 --- a/misc/examples/bits.c +++ b/misc/examples/bits.c @@ -9,18 +9,18 @@ int main(void) cbits_drop(&set), cbits_drop(&s2) ){ - printf("count %" c_ZI ", %" c_ZI "\n", cbits_count(&set), cbits_size(&set)); + printf("count %lld, %lld\n", cbits_count(&set), cbits_size(&set)); cbits s1 = cbits_from("1110100110111"); char buf[256]; cbits_to_str(&s1, buf, 0, 255); - printf("buf: %s: %" c_ZI "\n", buf, cbits_count(&s1)); + printf("buf: %s: %lld\n", buf, cbits_count(&s1)); cbits_drop(&s1); cbits_reset(&set, 9); cbits_resize(&set, 43, false); printf(" str: %s\n", cbits_to_str(&set, buf, 0, 255)); - printf("%4" c_ZI ": ", cbits_size(&set)); + printf("%4lld: ", cbits_size(&set)); c_forrange (i, cbits_size(&set)) printf("%d", cbits_test(&set, i)); puts(""); @@ -30,12 +30,12 @@ int main(void) cbits_resize(&set, 93, false); cbits_resize(&set, 102, true); cbits_set_value(&set, 99, false); - printf("%4" c_ZI ": ", cbits_size(&set)); + printf("%4lld: ", cbits_size(&set)); c_forrange (i, cbits_size(&set)) printf("%d", cbits_test(&set, i)); puts("\nIterate:"); - printf("%4" c_ZI ": ", cbits_size(&set)); + printf("%4lld: ", cbits_size(&set)); c_forrange (i, cbits_size(&set)) printf("%d", cbits_test(&set, i)); puts(""); @@ -58,7 +58,7 @@ int main(void) puts(""); cbits_set_all(&set, false); - printf("%4" c_ZI ": ", cbits_size(&set)); + printf("%4lld: ", cbits_size(&set)); c_forrange (i, cbits_size(&set)) printf("%d", cbits_test(&set, i)); puts(""); diff --git a/misc/examples/bits2.c b/misc/examples/bits2.c index b002af3c..913bd185 100644 --- a/misc/examples/bits2.c +++ b/misc/examples/bits2.c @@ -9,10 +9,10 @@ int main() { Bits s1 = Bits_from("1110100110111"); - printf("size %" c_ZI "\n", Bits_size(&s1)); + printf("size %lld\n", Bits_size(&s1)); char buf[256]; Bits_to_str(&s1, buf, 0, 256); - printf("buf: %s: count=%" c_ZI "\n", buf, Bits_count(&s1)); + printf("buf: %s: count=%lld\n", buf, Bits_count(&s1)); Bits_reset(&s1, 8); printf(" s1: %s\n", Bits_to_str(&s1, buf, 0, 256)); diff --git a/misc/examples/intrusive.c b/misc/examples/intrusive.c index 0d503575..0f153589 100644 --- a/misc/examples/intrusive.c +++ b/misc/examples/intrusive.c @@ -16,7 +16,7 @@ void printList(List list) { int main() { List list = {0}; c_forlist (i, int, {6, 9, 3, 1, 7, 4, 5, 2, 8}) - List_push_back_node(&list, c_new(List_node, {0, *i.ref})); + List_push_back_node(&list, c_new(List_node, {.value=*i.ref})); printList(list); -- cgit v1.2.3 From 071b41c0fe95cb3f9a72bbe0417d856e7989ca08 Mon Sep 17 00:00:00 2001 From: tylov Date: Sun, 9 Jul 2023 00:06:54 +0200 Subject: Backport from dev43: Bugfixes on 4.2 from raspberry pi 32-bit testing. Fixes issue #61: too small int used in example. --- misc/examples/make.sh | 2 +- misc/examples/prime.c | 20 +++++++++++--------- misc/examples/queue.c | 2 +- misc/examples/random.c | 2 +- misc/tests/cspan_test.c | 5 ++--- misc/tests/ctest.h | 3 ++- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/misc/examples/make.sh b/misc/examples/make.sh index 0297e5a1..b0c0bd52 100755 --- a/misc/examples/make.sh +++ b/misc/examples/make.sh @@ -6,7 +6,7 @@ if [ "$(uname)" = 'Linux' ]; then oflag='-o ' fi -cc=gcc; cflags="-s -O3 -std=c99 -Wconversion -Wpedantic -Wall -Wsign-compare -Wwrite-strings" +cc=gcc; cflags="-s -O3 -std=c99 -Wconversion -Wpedantic -Wall -Wsign-compare -Wwrite-strings -Wno-maybe-uninitialized" #cc=gcc; cflags="-g -std=c99 -Werror -Wfatal-errors -Wpedantic -Wall $sanitize" #cc=tcc; cflags="-Wall -std=c99" #cc=clang; cflags="-s -O2 -std=c99 -Werror -Wfatal-errors -Wpedantic -Wall -Wno-unused-function -Wsign-compare -Wwrite-strings" diff --git a/misc/examples/prime.c b/misc/examples/prime.c index d0887353..c3a0663c 100644 --- a/misc/examples/prime.c +++ b/misc/examples/prime.c @@ -5,20 +5,22 @@ #include #include +typedef long long llong; -cbits sieveOfEratosthenes(int64_t n) + +cbits sieveOfEratosthenes(llong n) { cbits bits = cbits_with_size(n/2 + 1, true); - int64_t q = (int64_t)sqrt((double) n) + 1; - for (int64_t i = 3; i < q; i += 2) { - int64_t j = i; + llong q = (llong)sqrt((double) n) + 1; + for (llong i = 3; i < q; i += 2) { + llong j = i; for (; j < n; j += 2) { if (cbits_test(&bits, j>>1)) { i = j; break; } } - for (int64_t j = i*i; j < n; j += i*2) + for (llong j = i*i; j < n; j += i*2) cbits_reset(&bits, j>>1); } return bits; @@ -26,15 +28,15 @@ cbits sieveOfEratosthenes(int64_t n) int main(void) { - int64_t n = 1000000000; - printf("Computing prime numbers up to %" c_ZI "\n", n); + llong n = 100000000; + printf("Computing prime numbers up to %lld\n", n); clock_t t1 = clock(); cbits primes = sieveOfEratosthenes(n + 1); - int64_t np = cbits_count(&primes); + llong np = cbits_count(&primes); clock_t t2 = clock(); - printf("Number of primes: %" c_ZI ", time: %f\n\n", np, (float)(t2 - t1) / (float)CLOCKS_PER_SEC); + printf("Number of primes: %lld, time: %f\n\n", np, (float)(t2 - t1) / (float)CLOCKS_PER_SEC); puts("Show all the primes in the range [2, 1000):"); printf("2"); c_forrange (i, 3, 1000, 2) diff --git a/misc/examples/queue.c b/misc/examples/queue.c index 83c18d09..90c800aa 100644 --- a/misc/examples/queue.c +++ b/misc/examples/queue.c @@ -6,7 +6,7 @@ #include int main() { - int n = 100000000; + int n = 1000000; crand_unif_t dist; crand_t rng = crand_init(1234); dist = crand_unif_init(0, n); diff --git a/misc/examples/random.c b/misc/examples/random.c index ea9c483e..b4b437cf 100644 --- a/misc/examples/random.c +++ b/misc/examples/random.c @@ -4,7 +4,7 @@ int main() { - const size_t N = 1000000000; + const size_t N = 10000000; const uint64_t seed = (uint64_t)time(NULL), range = 1000000; crand_t rng = crand_init(seed); diff --git a/misc/tests/cspan_test.c b/misc/tests/cspan_test.c index 5d46f579..83ac762b 100644 --- a/misc/tests/cspan_test.c +++ b/misc/tests/cspan_test.c @@ -112,10 +112,9 @@ CTEST_TEARDOWN(cspan_cube) { CTEST_F(cspan_cube, slice3) { - intptr_t n = cstack_int_size(&_self->stack); - //printf("\ntiles: %zi, cells: %zi\n", Tiles_size(&_self->tiles), n); + long long n = cstack_int_size(&_self->stack); + long long sum = 0; - int64_t sum = 0; // iterate each 3d tile in sequence c_foreach (i, Tiles, _self->tiles) c_foreach (t, intspan3, *i.ref) diff --git a/misc/tests/ctest.h b/misc/tests/ctest.h index 373cda0e..6b1b1084 100644 --- a/misc/tests/ctest.h +++ b/misc/tests/ctest.h @@ -408,7 +408,8 @@ void assert_dbl_compare(const char* cmp, double exp, double real, double tol, co void assert_pointers(const char* cmp, const void* exp, const void* real, const char* caller, int line) { if ((exp == real) != (cmp[0] == '=')) { - CTEST_ERR("%s:%d assertion failed (0x%02llx) %s (0x%02llx)", caller, line, (unsigned long long)exp , cmp, (unsigned long long)real); + CTEST_ERR("%s:%d assertion failed (0x%02llx) %s (0x%02llx)", caller, line, + (unsigned long long)(uintptr_t)exp , cmp, (unsigned long long)(uintptr_t)real); } } -- cgit v1.2.3 From 177418232a2d8a8b0df1667d3e4bd15dc37db59f Mon Sep 17 00:00:00 2001 From: tylov Date: Tue, 18 Jul 2023 02:50:44 +0200 Subject: Final merge fixes. --- misc/examples/prime.c | 2 +- misc/examples/random.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/examples/prime.c b/misc/examples/prime.c index c3db707d..e7b3d993 100644 --- a/misc/examples/prime.c +++ b/misc/examples/prime.c @@ -32,7 +32,7 @@ int main(void) llong n = 100000000; printf("Computing prime numbers up to %lld\n", n); - clock_t t = clock(); + clock_t t1 = clock(); cbits primes = sieveOfEratosthenes(n + 1); llong np = cbits_count(&primes); diff --git a/misc/examples/random.c b/misc/examples/random.c index 63c5a306..a36b2389 100644 --- a/misc/examples/random.c +++ b/misc/examples/random.c @@ -4,7 +4,7 @@ int main(void) { - const size_t N = 10000000; + const int N = 10000000; const uint64_t seed = (uint64_t)time(NULL), range = 1000000; crand_t rng = crand_init(seed); -- cgit v1.2.3