diff --git a/examples/ice_cream.c b/examples/ice_cream.c new file mode 100644 index 0000000..edc6388 --- /dev/null +++ b/examples/ice_cream.c @@ -0,0 +1,87 @@ +/** + * ice_cream.c + * + * Creation Date: 03/04/2019 + * + * Authors: + * Leonardo Vencovsky (https://github.com/LeoVen) + * + */ +#include +#include +#include + +#define PFX q +#define SNAME queue +#define V const char * +#define CMC_EXT_ITER +#include "cmc/queue.h" + +int main() +{ + srand((unsigned)time(NULL)); + + // 1- People are lining up to get some ice cream but there is not enough + // for everyone! Hurry! Get in the queue! + + size_t total_icecreams = 20; + + struct queue *lineup = q_new(10, &(struct queue_fval){ 0 }); + + bool ok = true; + + ok = ok && q_enqueue(lineup, "Albert"); + ok = ok && q_enqueue(lineup, "Newton"); + ok = ok && q_enqueue(lineup, "Marie"); + ok = ok && q_enqueue(lineup, "Charles"); + ok = ok && q_enqueue(lineup, "Nikola"); + ok = ok && q_enqueue(lineup, "Thomas"); + ok = ok && q_enqueue(lineup, "Niels"); + ok = ok && q_enqueue(lineup, "Galileo"); + ok = ok && q_enqueue(lineup, "Stephen"); + ok = ok && q_enqueue(lineup, "Leonardo"); + ok = ok && q_enqueue(lineup, "Max"); + ok = ok && q_enqueue(lineup, "Dmitri"); + + if (!ok) + { + fprintf(stderr, "Something went wrong!"); + return 1; + } + + while (total_icecreams > 0) + { + size_t catch = rand() % 5; + + const char *name = q_peek(lineup); + + if (!q_dequeue(lineup)) + break; + + printf("%-8s got %zu ice cream(s) from the ice cream truck\n", name, catch); + + total_icecreams = catch > total_icecreams ? 0 : total_icecreams - catch; + } + + if (!q_empty(lineup)) + { + printf("\nOh no! Someone didn't get their ice cream!\n\n"); + + while (!q_empty(lineup)) + { + const char *name = q_peek(lineup); + + q_dequeue(lineup); + + printf("%-8s got no ice cream and he is sad\n", name); + } + } + else if (total_icecreams > 0) + { + printf("\n%zu ice creams remaining to be sold on the next day.\n", total_icecreams); + } + + q_free(lineup); + + return 0; +} diff --git a/src/cmc/bitset.h b/src/cmc/bitset.h index 4e7a890..3a806f6 100644 --- a/src/cmc/bitset.h +++ b/src/cmc/bitset.h @@ -55,6 +55,10 @@ #include "cor/bitset.h" #include "cor/core.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * SNAME - struct name and prefix of other related structs diff --git a/src/cmc/cmc/bitset/code.h b/src/cmc/cmc/bitset/code.h index dcecc08..016e610 100644 --- a/src/cmc/cmc/bitset/code.h +++ b/src/cmc/cmc/bitset/code.h @@ -27,12 +27,20 @@ bool CMC_(PFX, _impl_resize)(struct SNAME *_bitset_, size_t n_bits, bool do_resi struct SNAME *CMC_(PFX, _new)(size_t n_bits) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(n_bits, NULL, NULL); } struct SNAME *CMC_(PFX, _new_custom)(size_t n_bits, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (n_bits < 1) @@ -66,12 +74,20 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t n_bits, struct CMC_ALLOC_NODE_NAME * struct SNAME CMC_(PFX, _init)(size_t n_bits) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _init_custom)(n_bits, NULL, NULL); } struct SNAME CMC_(PFX, _init_custom)(size_t n_bits, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *CMC_UNUSED(callbacks)) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); struct SNAME _bitset_ = { 0 }; @@ -99,18 +115,30 @@ struct SNAME CMC_(PFX, _init_custom)(size_t n_bits, struct CMC_ALLOC_NODE_NAME * void CMC_(PFX, _free)(struct SNAME *_bitset_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + free(_bitset_->buffer); free(_bitset_); } void CMC_(PFX, _release)(struct SNAME _bitset_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + free(_bitset_.buffer); } void CMC_(PFX, _customize)(struct SNAME *_bitset_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -125,6 +153,10 @@ void CMC_(PFX, _customize)(struct SNAME *_bitset_, struct CMC_ALLOC_NODE_NAME *a bool CMC_(PFX, _set)(struct SNAME *_bitset_, size_t bit_index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _impl_resize)(_bitset_, bit_index + 1, false)) return false; @@ -144,6 +176,10 @@ bool CMC_(PFX, _set)(struct SNAME *_bitset_, size_t bit_index) bool CMC_(PFX, _set_range)(struct SNAME *_bitset_, size_t from, size_t to) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (to < from) { _bitset_->flag = CMC_FLAG_INVALID; @@ -191,6 +227,10 @@ bool CMC_(PFX, _set_range)(struct SNAME *_bitset_, size_t from, size_t to) bool CMC_(PFX, _clear)(struct SNAME *_bitset_, size_t bit_index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _impl_resize)(_bitset_, bit_index + 1, false)) return false; @@ -210,6 +250,10 @@ bool CMC_(PFX, _clear)(struct SNAME *_bitset_, size_t bit_index) bool CMC_(PFX, _clear_range)(struct SNAME *_bitset_, size_t from, size_t to) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (to < from) { _bitset_->flag = CMC_FLAG_INVALID; @@ -257,6 +301,10 @@ bool CMC_(PFX, _clear_range)(struct SNAME *_bitset_, size_t from, size_t to) bool CMC_(PFX, _flip)(struct SNAME *_bitset_, size_t bit_index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _impl_resize)(_bitset_, bit_index + 1, false)) return false; @@ -276,6 +324,10 @@ bool CMC_(PFX, _flip)(struct SNAME *_bitset_, size_t bit_index) bool CMC_(PFX, _flip_range)(struct SNAME *_bitset_, size_t from, size_t to) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (to < from) { _bitset_->flag = CMC_FLAG_INVALID; @@ -323,6 +375,10 @@ bool CMC_(PFX, _flip_range)(struct SNAME *_bitset_, size_t from, size_t to) bool CMC_(PFX, _put)(struct SNAME *_bitset_, size_t bit_index, bool state) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (state) return CMC_(PFX, _set)(_bitset_, bit_index); else @@ -331,6 +387,10 @@ bool CMC_(PFX, _put)(struct SNAME *_bitset_, size_t bit_index, bool state) bool CMC_(PFX, _put_range)(struct SNAME *_bitset_, size_t from, size_t to, bool state) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (state) return CMC_(PFX, _set_range)(_bitset_, from, to); else @@ -339,6 +399,10 @@ bool CMC_(PFX, _put_range)(struct SNAME *_bitset_, size_t from, size_t to, bool bool CMC_(PFX, _set_all)(struct SNAME *_bitset_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + for (size_t i = 0; i < _bitset_->capacity; i++) _bitset_->buffer[i] = ~((cmc_bitset_word)0); @@ -351,6 +415,10 @@ bool CMC_(PFX, _set_all)(struct SNAME *_bitset_) bool CMC_(PFX, _clear_all)(struct SNAME *_bitset_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + for (size_t i = 0; i < _bitset_->capacity; i++) _bitset_->buffer[i] = 0; @@ -363,6 +431,10 @@ bool CMC_(PFX, _clear_all)(struct SNAME *_bitset_) bool CMC_(PFX, _flip_all)(struct SNAME *_bitset_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + for (size_t i = 0; i < _bitset_->capacity; i++) _bitset_->buffer[i] ^= ~((cmc_bitset_word)0); @@ -375,6 +447,10 @@ bool CMC_(PFX, _flip_all)(struct SNAME *_bitset_) bool CMC_(PFX, _get)(struct SNAME *_bitset_, size_t bit_index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* How many bits in a word */ const cmc_bitset_word bits = sizeof(cmc_bitset_word) * CHAR_BIT; @@ -385,6 +461,10 @@ bool CMC_(PFX, _get)(struct SNAME *_bitset_, size_t bit_index) bool CMC_(PFX, _resize)(struct SNAME *_bitset_, size_t n_bits) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _impl_resize)(_bitset_, n_bits, true); } @@ -392,6 +472,10 @@ bool CMC_(PFX, _resize)(struct SNAME *_bitset_, size_t n_bits) /* can accommodate n_bits */ bool CMC_(PFX, _impl_resize)(struct SNAME *_bitset_, size_t n_bits, bool do_resize) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (n_bits == 0) { _bitset_->flag = CMC_FLAG_INVALID; diff --git a/src/cmc/cmc/deque/code.h b/src/cmc/cmc/deque/code.h index 89ec618..b556a0a 100644 --- a/src/cmc/cmc/deque/code.h +++ b/src/cmc/cmc/deque/code.h @@ -27,12 +27,20 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL); } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (capacity < 1) @@ -71,6 +79,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) void CMC_(PFX, _clear)(struct SNAME *_deque_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_deque_->f_val->free) { for (size_t i = _deque_->front, j = 0; j < _deque_->count; j++) @@ -92,6 +104,10 @@ void CMC_(PFX, _clear)(struct SNAME *_deque_) void CMC_(PFX, _free)(struct SNAME *_deque_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_deque_->f_val->free) { for (size_t i = _deque_->front, j = 0; j < _deque_->count; j++) @@ -109,6 +125,10 @@ void CMC_(PFX, _free)(struct SNAME *_deque_) void CMC_(PFX, _customize)(struct SNAME *_deque_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -123,6 +143,10 @@ void CMC_(PFX, _customize)(struct SNAME *_deque_, struct CMC_ALLOC_NODE_NAME *al bool CMC_(PFX, _push_front)(struct SNAME *_deque_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _full)(_deque_)) { if (!CMC_(PFX, _resize)(_deque_, _deque_->capacity * 2)) @@ -143,6 +167,10 @@ bool CMC_(PFX, _push_front)(struct SNAME *_deque_, V value) bool CMC_(PFX, _push_back)(struct SNAME *_deque_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _full)(_deque_)) { if (!CMC_(PFX, _resize)(_deque_, _deque_->capacity * 2)) @@ -163,6 +191,10 @@ bool CMC_(PFX, _push_back)(struct SNAME *_deque_, V value) bool CMC_(PFX, _pop_front)(struct SNAME *_deque_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_deque_)) { _deque_->flag = CMC_FLAG_EMPTY; @@ -183,6 +215,10 @@ bool CMC_(PFX, _pop_front)(struct SNAME *_deque_) bool CMC_(PFX, _pop_back)(struct SNAME *_deque_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_deque_)) { _deque_->flag = CMC_FLAG_EMPTY; @@ -203,6 +239,10 @@ bool CMC_(PFX, _pop_back)(struct SNAME *_deque_) V CMC_(PFX, _front)(struct SNAME *_deque_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_deque_)) { _deque_->flag = CMC_FLAG_EMPTY; @@ -218,6 +258,10 @@ V CMC_(PFX, _front)(struct SNAME *_deque_) V CMC_(PFX, _back)(struct SNAME *_deque_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_deque_)) { _deque_->flag = CMC_FLAG_EMPTY; @@ -233,6 +277,10 @@ V CMC_(PFX, _back)(struct SNAME *_deque_) bool CMC_(PFX, _contains)(struct SNAME *_deque_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _deque_->flag = CMC_FLAG_OK; bool result = false; @@ -255,31 +303,55 @@ bool CMC_(PFX, _contains)(struct SNAME *_deque_, V value) bool CMC_(PFX, _empty)(struct SNAME *_deque_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _deque_->count == 0; } bool CMC_(PFX, _full)(struct SNAME *_deque_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _deque_->count >= _deque_->capacity; } size_t CMC_(PFX, _count)(struct SNAME *_deque_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _deque_->count; } size_t CMC_(PFX, _capacity)(struct SNAME *_deque_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _deque_->capacity; } int CMC_(PFX, _flag)(struct SNAME *_deque_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _deque_->flag; } bool CMC_(PFX, _resize)(struct SNAME *_deque_, size_t capacity) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _deque_->flag = CMC_FLAG_OK; if (_deque_->capacity == capacity) @@ -322,6 +394,10 @@ success: struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_deque_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *result = CMC_(PFX, _new_custom)(_deque_->capacity, _deque_->f_val, _deque_->alloc, NULL); if (!result) @@ -362,6 +438,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_deque_) bool CMC_(PFX, _equals)(struct SNAME *_deque1_, struct SNAME *_deque2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _deque1_->flag = CMC_FLAG_OK; _deque2_->flag = CMC_FLAG_OK; diff --git a/src/cmc/cmc/deque/ext/code.h b/src/cmc/cmc/deque/ext/code.h index dc4a1b5..f99c4b7 100644 --- a/src/cmc/cmc/deque/ext/code.h +++ b/src/cmc/cmc/deque/ext/code.h @@ -32,12 +32,20 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _init_custom)(capacity, f_val, NULL, NULL); } struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); struct SNAME _deque_ = { 0 }; @@ -70,6 +78,10 @@ struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) void CMC_(PFX, _release)(struct SNAME _deque_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_deque_.f_val->free) { for (size_t i = _deque_.front, j = 0; j < _deque_.count; j++) @@ -94,6 +106,10 @@ void CMC_(PFX, _release)(struct SNAME _deque_) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -107,6 +123,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -134,16 +154,28 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) bool CMC_(PFX, _iter_at_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_at_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->target->front; @@ -159,6 +191,10 @@ bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { if (iter->target->back == 0) @@ -179,6 +215,10 @@ bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -198,6 +238,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -218,6 +262,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -241,6 +289,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -270,6 +322,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -283,6 +339,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (V){ 0 }; @@ -291,6 +351,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return NULL; @@ -299,6 +363,10 @@ V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->index; } @@ -313,6 +381,10 @@ size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _to_string)(struct SNAME *_deque_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *d_ = _deque_; return 0 <= fprintf(fptr, @@ -333,6 +405,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_deque_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_deque_, FILE *fptr, const char *start, const char *separator, const char *end) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + fprintf(fptr, "%s", start); for (size_t i = _deque_->front, j = 0; j < _deque_->count; j++) diff --git a/src/cmc/cmc/hashbidimap/code.h b/src/cmc/cmc/hashbidimap/code.h index 998f7f1..6664b36 100644 --- a/src/cmc/cmc/hashbidimap/code.h +++ b/src/cmc/cmc/hashbidimap/code.h @@ -35,6 +35,10 @@ static size_t CMC_(PFX, _impl_calculate_size)(size_t required); struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(capacity, load, f_key, f_val, NULL, NULL); } @@ -42,6 +46,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DE struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (capacity == 0 || load <= 0 || load >= 1) @@ -88,6 +96,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DE void CMC_(PFX, _clear)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + for (size_t i = 0; i < _map_->capacity; i++) { struct CMC_DEF_ENTRY(SNAME) *entry = _map_->buffer[i][0]; @@ -112,6 +124,10 @@ void CMC_(PFX, _clear)(struct SNAME *_map_) void CMC_(PFX, _free)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_(PFX, _clear)(_map_); _map_->alloc->free(_map_->buffer); @@ -120,6 +136,10 @@ void CMC_(PFX, _free)(struct SNAME *_map_) void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -134,6 +154,10 @@ void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *allo bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _full)(_map_)) { if (!CMC_(PFX, _resize)(_map_, _map_->capacity + 1)) @@ -176,6 +200,10 @@ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value) bool CMC_(PFX, _update_key)(struct SNAME *_map_, V val, K new_key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -239,6 +267,10 @@ success: bool CMC_(PFX, _update_val)(struct SNAME *_map_, K key, V new_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -303,6 +335,10 @@ success: bool CMC_(PFX, _remove_by_key)(struct SNAME *_map_, K key, K *out_key, V *out_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -348,6 +384,10 @@ bool CMC_(PFX, _remove_by_key)(struct SNAME *_map_, K key, K *out_key, V *out_va bool CMC_(PFX, _remove_by_val)(struct SNAME *_map_, V val, K *out_key, V *out_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -393,6 +433,10 @@ bool CMC_(PFX, _remove_by_val)(struct SNAME *_map_, V val, K *out_key, V *out_va K CMC_(PFX, _get_key)(struct SNAME *_map_, V val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ENTRY(SNAME) **entry = CMC_(PFX, _impl_get_entry_by_val)(_map_, val); if (!entry) @@ -410,6 +454,10 @@ K CMC_(PFX, _get_key)(struct SNAME *_map_, V val) V CMC_(PFX, _get_val)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ENTRY(SNAME) **entry = CMC_(PFX, _impl_get_entry_by_key)(_map_, key); if (!entry) @@ -427,6 +475,10 @@ V CMC_(PFX, _get_val)(struct SNAME *_map_, K key) bool CMC_(PFX, _contains_key)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _map_->flag = CMC_FLAG_OK; bool result = CMC_(PFX, _impl_get_entry_by_key)(_map_, key) != NULL; @@ -438,6 +490,10 @@ bool CMC_(PFX, _contains_key)(struct SNAME *_map_, K key) bool CMC_(PFX, _contains_val)(struct SNAME *_map_, V val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _map_->flag = CMC_FLAG_OK; bool result = CMC_(PFX, _impl_get_entry_by_val)(_map_, val) != NULL; @@ -449,36 +505,64 @@ bool CMC_(PFX, _contains_val)(struct SNAME *_map_, V val) bool CMC_(PFX, _empty)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->count == 0; } bool CMC_(PFX, _full)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return (double)_map_->capacity * _map_->load <= (double)_map_->count; } size_t CMC_(PFX, _count)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->count; } size_t CMC_(PFX, _capacity)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->capacity; } double CMC_(PFX, _load)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->load; } int CMC_(PFX, _flag)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->flag; } bool CMC_(PFX, _resize)(struct SNAME *_map_, size_t capacity) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _map_->flag = CMC_FLAG_OK; if (_map_->capacity == capacity) @@ -572,6 +656,10 @@ success: struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* TODO this function can be optimized */ struct SNAME *result = CMC_(PFX, _new_custom)(_map_->capacity * _map_->load, _map_->load, _map_->f_key, _map_->f_val, _map_->alloc, NULL); @@ -620,6 +708,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_map_) bool CMC_(PFX, _equals)(struct SNAME *_map1_, struct SNAME *_map2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _map1_->flag = CMC_FLAG_OK; _map2_->flag = CMC_FLAG_OK; @@ -661,6 +753,10 @@ bool CMC_(PFX, _equals)(struct SNAME *_map1_, struct SNAME *_map2_) static struct CMC_DEF_ENTRY(SNAME) * CMC_(PFX, _impl_new_entry)(struct SNAME *_map_, K key, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ENTRY(SNAME) *entry = _map_->alloc->malloc(sizeof(struct CMC_DEF_ENTRY(SNAME))); if (!entry) @@ -678,6 +774,10 @@ static struct CMC_DEF_ENTRY(SNAME) * CMC_(PFX, _impl_new_entry)(struct SNAME *_m static struct CMC_DEF_ENTRY(SNAME) * *CMC_(PFX, _impl_get_entry_by_key)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + size_t hash = _map_->f_key->hash(key); size_t pos = hash % _map_->capacity; @@ -697,6 +797,10 @@ static struct CMC_DEF_ENTRY(SNAME) * *CMC_(PFX, _impl_get_entry_by_key)(struct S static struct CMC_DEF_ENTRY(SNAME) * *CMC_(PFX, _impl_get_entry_by_val)(struct SNAME *_map_, V val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + size_t hash = _map_->f_val->hash(val); size_t pos = hash % _map_->capacity; @@ -717,6 +821,10 @@ static struct CMC_DEF_ENTRY(SNAME) * *CMC_(PFX, _impl_get_entry_by_val)(struct S static struct CMC_DEF_ENTRY(SNAME) * *CMC_(PFX, _impl_add_entry_to_key)(struct SNAME *_map_, struct CMC_DEF_ENTRY(SNAME) * entry) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ENTRY(SNAME) **to_return = NULL; size_t hash = _map_->f_key->hash(entry->key); @@ -775,6 +883,10 @@ static struct CMC_DEF_ENTRY(SNAME) * static struct CMC_DEF_ENTRY(SNAME) * *CMC_(PFX, _impl_add_entry_to_val)(struct SNAME *_map_, struct CMC_DEF_ENTRY(SNAME) * entry) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ENTRY(SNAME) **to_return = NULL; size_t hash = _map_->f_val->hash(entry->value); @@ -832,6 +944,10 @@ static struct CMC_DEF_ENTRY(SNAME) * static size_t CMC_(PFX, _impl_calculate_size)(size_t required) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + const size_t count = sizeof(cmc_hashtable_primes) / sizeof(cmc_hashtable_primes[0]); if (cmc_hashtable_primes[count - 1] < required) diff --git a/src/cmc/cmc/hashbidimap/ext/code.h b/src/cmc/cmc/hashbidimap/ext/code.h index 44db22f..3701195 100644 --- a/src/cmc/cmc/hashbidimap/ext/code.h +++ b/src/cmc/cmc/hashbidimap/ext/code.h @@ -33,6 +33,10 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _init_custom)(capacity, load, f_key, f_val, NULL, NULL); } @@ -40,6 +44,10 @@ struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DE struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); struct SNAME _map_ = { 0 }; @@ -79,6 +87,10 @@ struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DE void CMC_(PFX, _release)(struct SNAME _map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_(PFX, _clear)(&_map_); _map_.alloc->free(_map_.buffer); @@ -95,6 +107,10 @@ void CMC_(PFX, _release)(struct SNAME _map_) struct CMC_DEF_ITER(SNAME) * CMC_(PFX, _iter_new)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) *iter = target->alloc->malloc(sizeof(struct CMC_DEF_ITER(SNAME))); if (!iter) @@ -107,11 +123,19 @@ struct CMC_DEF_ITER(SNAME) * CMC_(PFX, _iter_new)(struct SNAME *target) void CMC_(PFX, _iter_free)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + iter->target->alloc->free(iter); } void CMC_(PFX, _iter_init)(struct CMC_DEF_ITER(SNAME) * iter, struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + memset(iter, 0, sizeof(struct CMC_DEF_ITER(SNAME))); iter->target = target; @@ -148,16 +172,28 @@ void CMC_(PFX, _iter_init)(struct CMC_DEF_ITER(SNAME) * iter, struct SNAME *targ bool CMC_(PFX, _iter_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } void CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->first; @@ -169,6 +205,10 @@ void CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) void CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->last; @@ -180,6 +220,10 @@ void CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -209,6 +253,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -239,6 +287,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -260,6 +312,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -282,6 +338,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* the given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -295,6 +355,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) K CMC_(PFX, _iter_key)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) { iter->target->flag = CMC_FLAG_EMPTY; @@ -306,6 +370,10 @@ K CMC_(PFX, _iter_key)(struct CMC_DEF_ITER(SNAME) * iter) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) { iter->target->flag = CMC_FLAG_EMPTY; @@ -317,6 +385,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->index; } @@ -331,6 +403,10 @@ size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _to_string)(struct SNAME *_map_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *m_ = _map_; return 0 <= fprintf(fptr, @@ -352,6 +428,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_map_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_map_, FILE *fptr, const char *start, const char *separator, const char *end, const char *key_val_sep) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + fprintf(fptr, "%s", start); size_t last = 0; diff --git a/src/cmc/cmc/hashmap/code.h b/src/cmc/cmc/hashmap/code.h index abea5c5..de71deb 100644 --- a/src/cmc/cmc/hashmap/code.h +++ b/src/cmc/cmc/hashmap/code.h @@ -36,6 +36,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DE struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (capacity == 0 || load <= 0 || load >= 1) @@ -80,6 +84,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DE void CMC_(PFX, _clear)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_map_->f_key->free || _map_->f_val->free) { for (size_t i = 0; i < _map_->capacity; i++) @@ -104,6 +112,10 @@ void CMC_(PFX, _clear)(struct SNAME *_map_) void CMC_(PFX, _free)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_map_->f_key->free || _map_->f_val->free) { for (size_t i = 0; i < _map_->capacity; i++) @@ -126,6 +138,10 @@ void CMC_(PFX, _free)(struct SNAME *_map_) void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -140,6 +156,10 @@ void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *allo bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _full)(_map_)) { if (!CMC_(PFX, _resize)(_map_, _map_->capacity + 1)) @@ -208,6 +228,10 @@ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value) bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -236,6 +260,10 @@ bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value) bool CMC_(PFX, _remove)(struct SNAME *_map_, K key, V *out_value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -268,6 +296,10 @@ bool CMC_(PFX, _remove)(struct SNAME *_map_, K key, V *out_value) bool CMC_(PFX, _max)(struct SNAME *_map_, K *key, V *value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -310,6 +342,10 @@ bool CMC_(PFX, _max)(struct SNAME *_map_, K *key, V *value) bool CMC_(PFX, _min)(struct SNAME *_map_, K *key, V *value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -352,6 +388,10 @@ bool CMC_(PFX, _min)(struct SNAME *_map_, K *key, V *value) V CMC_(PFX, _get)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -375,6 +415,10 @@ V CMC_(PFX, _get)(struct SNAME *_map_, K key) V *CMC_(PFX, _get_ref)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -398,6 +442,10 @@ V *CMC_(PFX, _get_ref)(struct SNAME *_map_, K key) bool CMC_(PFX, _contains)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _map_->flag = CMC_FLAG_OK; bool result = CMC_(PFX, _impl_get_entry)(_map_, key) != NULL; @@ -409,36 +457,64 @@ bool CMC_(PFX, _contains)(struct SNAME *_map_, K key) bool CMC_(PFX, _empty)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->count == 0; } bool CMC_(PFX, _full)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return (double)_map_->capacity * _map_->load <= (double)_map_->count; } size_t CMC_(PFX, _count)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->count; } size_t CMC_(PFX, _capacity)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->capacity; } double CMC_(PFX, _load)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->load; } int CMC_(PFX, _flag)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->flag; } bool CMC_(PFX, _resize)(struct SNAME *_map_, size_t capacity) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _map_->flag = CMC_FLAG_OK; if (_map_->capacity == capacity) @@ -518,6 +594,10 @@ success: struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *result = CMC_(PFX, _new_custom)(_map_->capacity * _map_->load, _map_->load, _map_->f_key, _map_->f_val, _map_->alloc, NULL); @@ -571,6 +651,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_map_) bool CMC_(PFX, _equals)(struct SNAME *_map1_, struct SNAME *_map2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _map1_->flag = CMC_FLAG_OK; _map2_->flag = CMC_FLAG_OK; @@ -604,6 +688,10 @@ bool CMC_(PFX, _equals)(struct SNAME *_map1_, struct SNAME *_map2_) static struct CMC_DEF_ENTRY(SNAME) * CMC_(PFX, _impl_get_entry)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + size_t hash = _map_->f_key->hash(key); size_t pos = hash % _map_->capacity; @@ -623,6 +711,10 @@ static struct CMC_DEF_ENTRY(SNAME) * CMC_(PFX, _impl_get_entry)(struct SNAME *_m static size_t CMC_(PFX, _impl_calculate_size)(size_t required) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + const size_t count = sizeof(cmc_hashtable_primes) / sizeof(cmc_hashtable_primes[0]); if (cmc_hashtable_primes[count - 1] < required) diff --git a/src/cmc/cmc/hashmap/ext/code.h b/src/cmc/cmc/hashmap/ext/code.h index c9741e1..7ddafaf 100644 --- a/src/cmc/cmc/hashmap/ext/code.h +++ b/src/cmc/cmc/hashmap/ext/code.h @@ -33,6 +33,10 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _init_custom)(capacity, load, f_key, f_val, NULL, NULL); } @@ -40,6 +44,10 @@ struct SNAME CMC_(PFX, _init_custom)(size_t capacity, double load, struct CMC_DE struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); struct SNAME _map_ = { 0 }; @@ -108,6 +116,10 @@ void CMC_(PFX, _release)(struct SNAME _map_) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -146,6 +158,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -185,16 +201,28 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) bool CMC_(PFX, _iter_at_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_at_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->first; @@ -210,6 +238,10 @@ bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->last; @@ -225,6 +257,10 @@ bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -254,6 +290,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -284,6 +324,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -305,6 +349,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -327,6 +375,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -340,6 +392,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) K CMC_(PFX, _iter_key)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (K){ 0 }; @@ -348,6 +404,10 @@ K CMC_(PFX, _iter_key)(struct CMC_DEF_ITER(SNAME) * iter) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (V){ 0 }; @@ -356,6 +416,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return NULL; @@ -364,6 +428,10 @@ V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->index; } @@ -378,6 +446,10 @@ size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _to_string)(struct SNAME *_map_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *m_ = _map_; return 0 <= fprintf(fptr, @@ -399,6 +471,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_map_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_map_, FILE *fptr, const char *start, const char *separator, const char *end, const char *key_val_sep) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + fprintf(fptr, "%s", start); size_t last = 0; diff --git a/src/cmc/cmc/hashmultimap/code.h b/src/cmc/cmc/hashmultimap/code.h index a38ff0a..7f7c296 100644 --- a/src/cmc/cmc/hashmultimap/code.h +++ b/src/cmc/cmc/hashmultimap/code.h @@ -31,6 +31,10 @@ size_t CMC_(PFX, _impl_calculate_size)(size_t required); struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(capacity, load, f_key, f_val, NULL, NULL); } @@ -38,6 +42,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DE struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (capacity == 0 || load <= 0) @@ -82,6 +90,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DE void CMC_(PFX, _clear)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + for (size_t i = 0; i < _map_->capacity; i++) { struct CMC_DEF_ENTRY(SNAME) *scan = _map_->buffer[i][0]; @@ -109,6 +121,10 @@ void CMC_(PFX, _clear)(struct SNAME *_map_) void CMC_(PFX, _free)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + size_t index = 0; while (index < _map_->capacity) @@ -153,6 +169,10 @@ void CMC_(PFX, _free)(struct SNAME *_map_) void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -167,6 +187,10 @@ void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *allo bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _full)(_map_)) { if (!CMC_(PFX, _resize)(_map_, _map_->capacity + 1)) @@ -201,6 +225,10 @@ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value) bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -229,6 +257,10 @@ bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value) size_t CMC_(PFX, _update_all)(struct SNAME *_map_, K key, V new_value, V **old_values) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -289,6 +321,10 @@ size_t CMC_(PFX, _update_all)(struct SNAME *_map_, K key, V new_value, V **old_v bool CMC_(PFX, _remove)(struct SNAME *_map_, K key, V *out_value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -372,6 +408,10 @@ bool CMC_(PFX, _remove)(struct SNAME *_map_, K key, V *out_value) size_t CMC_(PFX, _remove_all)(struct SNAME *_map_, K key, V **out_values) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -463,6 +503,10 @@ size_t CMC_(PFX, _remove_all)(struct SNAME *_map_, K key, V **out_values) bool CMC_(PFX, _max)(struct SNAME *_map_, K *key, V *value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -510,6 +554,10 @@ bool CMC_(PFX, _max)(struct SNAME *_map_, K *key, V *value) bool CMC_(PFX, _min)(struct SNAME *_map_, K *key, V *value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -557,6 +605,10 @@ bool CMC_(PFX, _min)(struct SNAME *_map_, K *key, V *value) V CMC_(PFX, _get)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -580,6 +632,10 @@ V CMC_(PFX, _get)(struct SNAME *_map_, K key) V *CMC_(PFX, _get_ref)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -603,6 +659,10 @@ V *CMC_(PFX, _get_ref)(struct SNAME *_map_, K key) bool CMC_(PFX, _contains)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _map_->flag = CMC_FLAG_OK; bool result = CMC_(PFX, _impl_get_entry)(_map_, key) != NULL; @@ -614,41 +674,73 @@ bool CMC_(PFX, _contains)(struct SNAME *_map_, K key) bool CMC_(PFX, _empty)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->count == 0; } bool CMC_(PFX, _full)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return (double)_map_->capacity * _map_->load <= (double)_map_->count; } size_t CMC_(PFX, _count)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->count; } size_t CMC_(PFX, _key_count)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _impl_key_count)(_map_, key); } size_t CMC_(PFX, _capacity)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->capacity; } double CMC_(PFX, _load)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->load; } int CMC_(PFX, _flag)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->flag; } bool CMC_(PFX, _resize)(struct SNAME *_map_, size_t capacity) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _map_->flag = CMC_FLAG_OK; if (_map_->capacity == capacity) @@ -728,6 +820,10 @@ success: struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Callback will be added later */ struct SNAME *result = CMC_(PFX, _new_custom)(_map_->capacity * _map_->load, _map_->load, _map_->f_key, _map_->f_val, _map_->alloc, NULL); @@ -771,6 +867,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_map_) bool CMC_(PFX, _equals)(struct SNAME *_map1_, struct SNAME *_map2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _map1_->flag = CMC_FLAG_OK; _map2_->flag = CMC_FLAG_OK; @@ -803,6 +903,10 @@ bool CMC_(PFX, _equals)(struct SNAME *_map1_, struct SNAME *_map2_) struct CMC_DEF_ENTRY(SNAME) * CMC_(PFX, _impl_new_entry)(struct SNAME *_map_, K key, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ENTRY(SNAME) *entry = _map_->alloc->malloc(sizeof(struct CMC_DEF_ENTRY(SNAME))); if (!entry) @@ -818,6 +922,10 @@ struct CMC_DEF_ENTRY(SNAME) * CMC_(PFX, _impl_new_entry)(struct SNAME *_map_, K struct CMC_DEF_ENTRY(SNAME) * CMC_(PFX, _impl_get_entry)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + size_t hash = _map_->f_key->hash(key); struct CMC_DEF_ENTRY(SNAME) *entry = _map_->buffer[hash % _map_->capacity][0]; @@ -835,6 +943,10 @@ struct CMC_DEF_ENTRY(SNAME) * CMC_(PFX, _impl_get_entry)(struct SNAME *_map_, K size_t CMC_(PFX, _impl_key_count)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + size_t hash = _map_->f_key->hash(key); struct CMC_DEF_ENTRY(SNAME) *entry = _map_->buffer[hash % _map_->capacity][0]; @@ -857,6 +969,10 @@ size_t CMC_(PFX, _impl_key_count)(struct SNAME *_map_, K key) size_t CMC_(PFX, _impl_calculate_size)(size_t required) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + const size_t count = sizeof(cmc_hashtable_primes) / sizeof(cmc_hashtable_primes[0]); if (cmc_hashtable_primes[count - 1] < required) diff --git a/src/cmc/cmc/hashmultimap/ext/code.h b/src/cmc/cmc/hashmultimap/ext/code.h index 2ed798f..8e76667 100644 --- a/src/cmc/cmc/hashmultimap/ext/code.h +++ b/src/cmc/cmc/hashmultimap/ext/code.h @@ -41,6 +41,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -85,6 +89,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -130,16 +138,28 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) bool CMC_(PFX, _iter_at_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_at_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->first; @@ -156,6 +176,10 @@ bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->last; @@ -172,6 +196,10 @@ bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -205,6 +233,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -239,6 +271,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -260,6 +296,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -282,6 +322,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -295,6 +339,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) K CMC_(PFX, _iter_key)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (K){ 0 }; @@ -303,6 +351,10 @@ K CMC_(PFX, _iter_key)(struct CMC_DEF_ITER(SNAME) * iter) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (V){ 0 }; @@ -311,6 +363,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return NULL; @@ -319,6 +375,10 @@ V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->index; } @@ -333,6 +393,10 @@ size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _to_string)(struct SNAME *_map_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *m_ = _map_; return 0 <= fprintf(fptr, @@ -354,6 +418,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_map_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_map_, FILE *fptr, const char *start, const char *separator, const char *end, const char *key_val_sep) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + fprintf(fptr, "%s", start); size_t last = 0; diff --git a/src/cmc/cmc/hashmultiset/code.h b/src/cmc/cmc/hashmultiset/code.h index ad50857..5f82358 100644 --- a/src/cmc/cmc/hashmultiset/code.h +++ b/src/cmc/cmc/hashmultiset/code.h @@ -29,12 +29,20 @@ static size_t CMC_(PFX, _impl_calculate_size)(size_t required); struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(capacity, load, f_val, NULL, NULL); } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (capacity == 0 || load <= 0 || load >= 1) @@ -79,6 +87,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DE void CMC_(PFX, _clear)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_set_->f_val->free) { for (size_t i = 0; i < _set_->capacity; i++) @@ -100,6 +112,10 @@ void CMC_(PFX, _clear)(struct SNAME *_set_) void CMC_(PFX, _free)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_set_->f_val->free) { for (size_t i = 0; i < _set_->capacity; i++) @@ -119,6 +135,10 @@ void CMC_(PFX, _free)(struct SNAME *_set_) void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -133,6 +153,10 @@ void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *allo bool CMC_(PFX, _insert)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + bool new_node; struct CMC_DEF_ENTRY(SNAME) *entry = CMC_(PFX, _impl_insert_and_return)(_set_, value, &new_node); @@ -156,6 +180,10 @@ bool CMC_(PFX, _insert)(struct SNAME *_set_, V value) bool CMC_(PFX, _insert_many)(struct SNAME *_set_, V value, size_t count) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (count == 0) goto success; @@ -187,6 +215,10 @@ success: bool CMC_(PFX, _update)(struct SNAME *_set_, V value, size_t multiplicity) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (multiplicity == 0) { /* Effectively delete the entry */ @@ -232,6 +264,10 @@ success: bool CMC_(PFX, _remove)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_set_)) { _set_->flag = CMC_FLAG_EMPTY; @@ -268,6 +304,10 @@ bool CMC_(PFX, _remove)(struct SNAME *_set_, V value) size_t CMC_(PFX, _remove_all)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_set_)) { _set_->flag = CMC_FLAG_EMPTY; @@ -300,6 +340,10 @@ size_t CMC_(PFX, _remove_all)(struct SNAME *_set_, V value) bool CMC_(PFX, _max)(struct SNAME *_set_, V *value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_set_)) { _set_->flag = CMC_FLAG_EMPTY; @@ -337,6 +381,10 @@ bool CMC_(PFX, _max)(struct SNAME *_set_, V *value) bool CMC_(PFX, _min)(struct SNAME *_set_, V *value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_set_)) { _set_->flag = CMC_FLAG_EMPTY; @@ -374,6 +422,10 @@ bool CMC_(PFX, _min)(struct SNAME *_set_, V *value) size_t CMC_(PFX, _multiplicity_of)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ENTRY(SNAME) *entry = CMC_(PFX, _impl_get_entry)(_set_, value); _set_->flag = CMC_FLAG_OK; @@ -388,6 +440,10 @@ size_t CMC_(PFX, _multiplicity_of)(struct SNAME *_set_, V value) bool CMC_(PFX, _contains)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _set_->flag = CMC_FLAG_OK; bool result = CMC_(PFX, _impl_get_entry)(_set_, value) != NULL; @@ -399,41 +455,73 @@ bool CMC_(PFX, _contains)(struct SNAME *_set_, V value) bool CMC_(PFX, _empty)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _set_->count == 0; } bool CMC_(PFX, _full)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return (double)_set_->capacity * _set_->load <= (double)_set_->count; } size_t CMC_(PFX, _count)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _set_->count; } size_t CMC_(PFX, _cardinality)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _set_->cardinality; } size_t CMC_(PFX, _capacity)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _set_->capacity; } double CMC_(PFX, _load)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _set_->load; } int CMC_(PFX, _flag)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _set_->flag; } bool CMC_(PFX, _resize)(struct SNAME *_set_, size_t capacity) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _set_->flag = CMC_FLAG_OK; if (_set_->capacity == capacity) @@ -513,6 +601,10 @@ success: struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *result = CMC_(PFX, _new_custom)(_set_->capacity * _set_->load, _set_->load, _set_->f_val, _set_->alloc, NULL); @@ -560,6 +652,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_set_) bool CMC_(PFX, _equals)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _set1_->flag = CMC_FLAG_OK; _set2_->flag = CMC_FLAG_OK; @@ -599,6 +695,10 @@ bool CMC_(PFX, _equals)(struct SNAME *_set1_, struct SNAME *_set2_) static struct CMC_DEF_ENTRY(SNAME) * CMC_(PFX, _impl_insert_and_return)(struct SNAME *_set_, V value, bool *new_node) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* If the entry already exists simply return it as we might do */ /* something with it. This function only guarantees that there is */ /* a valid entry for a given value */ @@ -685,6 +785,10 @@ static struct CMC_DEF_ENTRY(SNAME) * CMC_(PFX, _impl_insert_and_return)(struct S static struct CMC_DEF_ENTRY(SNAME) * CMC_(PFX, _impl_get_entry)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + size_t hash = _set_->f_val->hash(value); size_t pos = hash % _set_->capacity; @@ -704,6 +808,10 @@ static struct CMC_DEF_ENTRY(SNAME) * CMC_(PFX, _impl_get_entry)(struct SNAME *_s static size_t CMC_(PFX, _impl_calculate_size)(size_t required) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + const size_t count = sizeof(cmc_hashtable_primes) / sizeof(cmc_hashtable_primes[0]); if (cmc_hashtable_primes[count - 1] < required) diff --git a/src/cmc/cmc/hashmultiset/ext/code.h b/src/cmc/cmc/hashmultiset/ext/code.h index eb9cd4a..8b7f12f 100644 --- a/src/cmc/cmc/hashmultiset/ext/code.h +++ b/src/cmc/cmc/hashmultiset/ext/code.h @@ -41,6 +41,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -79,6 +83,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -118,16 +126,28 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) bool CMC_(PFX, _iter_at_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_at_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->first; @@ -143,6 +163,10 @@ bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->last; @@ -158,6 +182,10 @@ bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -187,6 +215,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -217,6 +249,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -238,6 +274,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -260,6 +300,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -273,6 +317,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (V){ 0 }; @@ -281,6 +329,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_multiplicity)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return 0; @@ -289,6 +341,10 @@ size_t CMC_(PFX, _iter_multiplicity)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->index; } @@ -306,6 +362,10 @@ static size_t CMC_(PFX, _impl_multiplicity_of)(struct SNAME *_set_, V value); struct SNAME *CMC_(PFX, _union)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Callbacks are added later */ struct SNAME *_set_r_ = CMC_(PFX, _new_custom)(_set1_->capacity, _set1_->load, _set1_->f_val, _set1_->alloc, NULL); @@ -344,6 +404,10 @@ struct SNAME *CMC_(PFX, _union)(struct SNAME *_set1_, struct SNAME *_set2_) struct SNAME *CMC_(PFX, _intersection)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Callbacks are added later */ struct SNAME *_set_r_ = CMC_(PFX, _new_custom)(_set1_->capacity, _set1_->load, _set1_->f_val, _set1_->alloc, NULL); @@ -373,6 +437,10 @@ struct SNAME *CMC_(PFX, _intersection)(struct SNAME *_set1_, struct SNAME *_set2 struct SNAME *CMC_(PFX, _difference)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Callbacks are added later */ struct SNAME *_set_r_ = CMC_(PFX, _new_custom)(_set1_->capacity, _set1_->load, _set1_->f_val, _set1_->alloc, NULL); @@ -399,6 +467,10 @@ struct SNAME *CMC_(PFX, _difference)(struct SNAME *_set1_, struct SNAME *_set2_) struct SNAME *CMC_(PFX, _summation)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Callbacks are added later */ struct SNAME *_set_r_ = CMC_(PFX, _new_custom)(_set1_->capacity, _set1_->load, _set1_->f_val, _set1_->alloc, NULL); @@ -427,6 +499,10 @@ struct SNAME *CMC_(PFX, _summation)(struct SNAME *_set1_, struct SNAME *_set2_) struct SNAME *CMC_(PFX, _symmetric_difference)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Callbacks are added later */ struct SNAME *_set_r_ = CMC_(PFX, _new_custom)(_set1_->capacity, _set1_->load, _set1_->f_val, _set1_->alloc, NULL); @@ -474,6 +550,10 @@ struct SNAME *CMC_(PFX, _symmetric_difference)(struct SNAME *_set1_, struct SNAM bool CMC_(PFX, _is_subset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_set1_->count > _set2_->count) return false; @@ -498,11 +578,19 @@ bool CMC_(PFX, _is_subset)(struct SNAME *_set1_, struct SNAME *_set2_) bool CMC_(PFX, _is_superset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _is_subset)(_set2_, _set1_); } bool CMC_(PFX, _is_proper_subset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_set1_->count >= _set2_->count) return false; @@ -532,11 +620,19 @@ bool CMC_(PFX, _is_proper_subset)(struct SNAME *_set1_, struct SNAME *_set2_) bool CMC_(PFX, _is_proper_superset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _is_proper_subset)(_set2_, _set1_); } bool CMC_(PFX, _is_disjointset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_set1_)) return true; @@ -555,6 +651,10 @@ bool CMC_(PFX, _is_disjointset)(struct SNAME *_set1_, struct SNAME *_set2_) static size_t CMC_(PFX, _impl_multiplicity_of)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ENTRY(SNAME) *entry = CMC_(PFX, _impl_get_entry)(_set_, value); if (!entry) @@ -574,6 +674,10 @@ static size_t CMC_(PFX, _impl_multiplicity_of)(struct SNAME *_set_, V value) bool CMC_(PFX, _to_string)(struct SNAME *_set_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *s_ = _set_; return 0 <= fprintf(fptr, @@ -595,6 +699,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_set_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_set_, FILE *fptr, const char *start, const char *separator, const char *end, const char *val_mul_sep) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + fprintf(fptr, "%s", start); size_t last = 0; diff --git a/src/cmc/cmc/hashset/code.h b/src/cmc/cmc/hashset/code.h index 82d8fef..239c883 100644 --- a/src/cmc/cmc/hashset/code.h +++ b/src/cmc/cmc/hashset/code.h @@ -28,12 +28,20 @@ static size_t CMC_(PFX, _impl_calculate_size)(size_t required); struct SNAME *CMC_(PFX, _new)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(capacity, load, f_val, NULL, NULL); } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (capacity == 0 || load <= 0 || load >= 1) @@ -77,6 +85,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, double load, struct CMC_DE void CMC_(PFX, _clear)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_set_->f_val->free) { for (size_t i = 0; i < _set_->capacity; i++) @@ -98,6 +110,10 @@ void CMC_(PFX, _clear)(struct SNAME *_set_) void CMC_(PFX, _free)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_set_->f_val->free) { for (size_t i = 0; i < _set_->capacity; i++) @@ -117,6 +133,10 @@ void CMC_(PFX, _free)(struct SNAME *_set_) void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -131,6 +151,10 @@ void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *allo bool CMC_(PFX, _insert)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _full)(_set_)) { if (!CMC_(PFX, _resize)(_set_, _set_->capacity + 1)) @@ -194,6 +218,10 @@ bool CMC_(PFX, _insert)(struct SNAME *_set_, V value) bool CMC_(PFX, _remove)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_set_)) { _set_->flag = CMC_FLAG_EMPTY; @@ -222,6 +250,10 @@ bool CMC_(PFX, _remove)(struct SNAME *_set_, V value) bool CMC_(PFX, _max)(struct SNAME *_set_, V *value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_set_)) { _set_->flag = CMC_FLAG_EMPTY; @@ -259,6 +291,10 @@ bool CMC_(PFX, _max)(struct SNAME *_set_, V *value) bool CMC_(PFX, _min)(struct SNAME *_set_, V *value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_set_)) { _set_->flag = CMC_FLAG_EMPTY; @@ -296,6 +332,10 @@ bool CMC_(PFX, _min)(struct SNAME *_set_, V *value) bool CMC_(PFX, _contains)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _set_->flag = CMC_FLAG_OK; bool result = CMC_(PFX, _impl_get_entry)(_set_, value) != NULL; @@ -307,36 +347,64 @@ bool CMC_(PFX, _contains)(struct SNAME *_set_, V value) bool CMC_(PFX, _empty)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _set_->count == 0; } bool CMC_(PFX, _full)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return (double)_set_->capacity * _set_->load <= (double)_set_->count; } size_t CMC_(PFX, _count)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _set_->count; } size_t CMC_(PFX, _capacity)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _set_->capacity; } double CMC_(PFX, _load)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _set_->load; } int CMC_(PFX, _flag)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _set_->flag; } bool CMC_(PFX, _resize)(struct SNAME *_set_, size_t capacity) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _set_->flag = CMC_FLAG_OK; if (_set_->capacity == capacity) @@ -413,6 +481,10 @@ success: struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *result = CMC_(PFX, _new_custom)(_set_->capacity * _set_->load, _set_->load, _set_->f_val, _set_->alloc, NULL); @@ -458,6 +530,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_set_) bool CMC_(PFX, _equals)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _set1_->flag = CMC_FLAG_OK; _set2_->flag = CMC_FLAG_OK; @@ -486,6 +562,10 @@ bool CMC_(PFX, _equals)(struct SNAME *_set1_, struct SNAME *_set2_) static struct CMC_DEF_ENTRY(SNAME) * CMC_(PFX, _impl_get_entry)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + size_t hash = _set_->f_val->hash(value); size_t pos = hash % _set_->capacity; @@ -505,6 +585,10 @@ static struct CMC_DEF_ENTRY(SNAME) * CMC_(PFX, _impl_get_entry)(struct SNAME *_s static size_t CMC_(PFX, _impl_calculate_size)(size_t required) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + const size_t count = sizeof(cmc_hashtable_primes) / sizeof(cmc_hashtable_primes[0]); if (cmc_hashtable_primes[count - 1] < required) diff --git a/src/cmc/cmc/hashset/ext/code.h b/src/cmc/cmc/hashset/ext/code.h index 6a839db..5bad20f 100644 --- a/src/cmc/cmc/hashset/ext/code.h +++ b/src/cmc/cmc/hashset/ext/code.h @@ -41,6 +41,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -79,6 +83,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -118,16 +126,28 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) bool CMC_(PFX, _iter_at_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_at_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->first; @@ -143,6 +163,10 @@ bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->last; @@ -158,6 +182,10 @@ bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -187,6 +215,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -217,6 +249,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -238,6 +274,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -260,6 +300,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -273,6 +317,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (V){ 0 }; @@ -281,6 +329,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->index; } @@ -295,6 +347,10 @@ size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) struct SNAME *CMC_(PFX, _union)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Callbacks are added later */ struct SNAME *_set_r_ = CMC_(PFX, _new_custom)(_set1_->capacity, _set1_->load, _set1_->f_val, _set1_->alloc, NULL); @@ -326,6 +382,10 @@ struct SNAME *CMC_(PFX, _union)(struct SNAME *_set1_, struct SNAME *_set2_) struct SNAME *CMC_(PFX, _intersection)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Callbacks are added later */ struct SNAME *_set_r_ = CMC_(PFX, _new_custom)(_set1_->capacity, _set1_->load, _set1_->f_val, _set1_->alloc, NULL); @@ -356,6 +416,10 @@ struct SNAME *CMC_(PFX, _intersection)(struct SNAME *_set1_, struct SNAME *_set2 struct SNAME *CMC_(PFX, _difference)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Callbacks are added later */ struct SNAME *_set_r_ = CMC_(PFX, _new_custom)(_set1_->capacity, _set1_->load, _set1_->f_val, _set1_->alloc, NULL); @@ -383,6 +447,10 @@ struct SNAME *CMC_(PFX, _difference)(struct SNAME *_set1_, struct SNAME *_set2_) struct SNAME *CMC_(PFX, _symmetric_difference)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Callbacks are added later */ struct SNAME *_set_r_ = CMC_(PFX, _new_custom)(_set1_->capacity, _set1_->load, _set1_->f_val, _set1_->alloc, NULL); @@ -422,6 +490,10 @@ struct SNAME *CMC_(PFX, _symmetric_difference)(struct SNAME *_set1_, struct SNAM /* If X is a subset of Y, then Y is a superset of X */ bool CMC_(PFX, _is_subset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _set1_->flag = CMC_FLAG_OK; _set2_->flag = CMC_FLAG_OK; @@ -452,6 +524,10 @@ bool CMC_(PFX, _is_subset)(struct SNAME *_set1_, struct SNAME *_set2_) /* If X is a superset of Y, then Y is a subset of X */ bool CMC_(PFX, _is_superset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _is_subset)(_set2_, _set1_); } @@ -460,6 +536,10 @@ bool CMC_(PFX, _is_superset)(struct SNAME *_set1_, struct SNAME *_set2_) /* If X is a proper subset of Y, then Y is a proper superset of X */ bool CMC_(PFX, _is_proper_subset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _set1_->flag = CMC_FLAG_OK; _set2_->flag = CMC_FLAG_OK; @@ -498,6 +578,10 @@ bool CMC_(PFX, _is_proper_subset)(struct SNAME *_set1_, struct SNAME *_set2_) /* If X is a proper superset of Y, then Y is a proper subset of X */ bool CMC_(PFX, _is_proper_superset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _is_proper_subset)(_set2_, _set1_); } @@ -506,6 +590,10 @@ bool CMC_(PFX, _is_proper_superset)(struct SNAME *_set1_, struct SNAME *_set2_) /* that is, if there are no elements in common between the two */ bool CMC_(PFX, _is_disjointset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _set1_->flag = CMC_FLAG_OK; _set2_->flag = CMC_FLAG_OK; @@ -538,6 +626,10 @@ bool CMC_(PFX, _is_disjointset)(struct SNAME *_set1_, struct SNAME *_set2_) bool CMC_(PFX, _to_string)(struct SNAME *_set_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *s_ = _set_; return 0 <= fprintf(fptr, @@ -557,6 +649,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_set_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_set_, FILE *fptr, const char *start, const char *separator, const char *end) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + fprintf(fptr, "%s", start); size_t last = 0; diff --git a/src/cmc/cmc/heap/code.h b/src/cmc/cmc/heap/code.h index aea0b31..9d12fd1 100644 --- a/src/cmc/cmc/heap/code.h +++ b/src/cmc/cmc/heap/code.h @@ -28,12 +28,20 @@ static void CMC_(PFX, _impl_float_down)(struct SNAME *_heap_, size_t index); struct SNAME *CMC_(PFX, _new)(size_t capacity, enum cmc_heap_order HO, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(capacity, HO, f_val, NULL, NULL); } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, enum cmc_heap_order HO, struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (capacity < 1) @@ -74,6 +82,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, enum cmc_heap_order HO, st void CMC_(PFX, _clear)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_heap_->f_val->free) { for (size_t i = 0; i < _heap_->count; i++) @@ -90,6 +102,10 @@ void CMC_(PFX, _clear)(struct SNAME *_heap_) void CMC_(PFX, _free)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_heap_->f_val->free) { for (size_t i = 0; i < _heap_->count; i++) @@ -105,6 +121,10 @@ void CMC_(PFX, _free)(struct SNAME *_heap_) void CMC_(PFX, _customize)(struct SNAME *_heap_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -119,6 +139,10 @@ void CMC_(PFX, _customize)(struct SNAME *_heap_, struct CMC_ALLOC_NODE_NAME *all bool CMC_(PFX, _insert)(struct SNAME *_heap_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _full)(_heap_)) { if (!CMC_(PFX, _resize)(_heap_, _heap_->count * 2)) @@ -141,6 +165,10 @@ bool CMC_(PFX, _insert)(struct SNAME *_heap_, V value) bool CMC_(PFX, _remove)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_heap_)) { _heap_->flag = CMC_FLAG_EMPTY; @@ -163,6 +191,10 @@ bool CMC_(PFX, _remove)(struct SNAME *_heap_) V CMC_(PFX, _peek)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_heap_)) { _heap_->flag = CMC_FLAG_EMPTY; @@ -178,6 +210,10 @@ V CMC_(PFX, _peek)(struct SNAME *_heap_) bool CMC_(PFX, _contains)(struct SNAME *_heap_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _heap_->flag = CMC_FLAG_OK; bool result = false; @@ -198,31 +234,55 @@ bool CMC_(PFX, _contains)(struct SNAME *_heap_, V value) bool CMC_(PFX, _empty)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _heap_->count == 0; } bool CMC_(PFX, _full)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _heap_->count >= _heap_->capacity; } size_t CMC_(PFX, _count)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _heap_->count; } size_t CMC_(PFX, _capacity)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _heap_->capacity; } int CMC_(PFX, _flag)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _heap_->flag; } bool CMC_(PFX, _resize)(struct SNAME *_heap_, size_t capacity) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _heap_->flag = CMC_FLAG_OK; if (_heap_->capacity == capacity) @@ -256,6 +316,10 @@ success: struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *result = CMC_(PFX, _new_custom)(_heap_->capacity, _heap_->HO, _heap_->f_val, _heap_->alloc, NULL); if (!result) @@ -283,6 +347,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_heap_) bool CMC_(PFX, _equals)(struct SNAME *_heap1_, struct SNAME *_heap2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _heap1_->flag = CMC_FLAG_OK; _heap2_->flag = CMC_FLAG_OK; @@ -300,6 +368,10 @@ bool CMC_(PFX, _equals)(struct SNAME *_heap1_, struct SNAME *_heap2_) static void CMC_(PFX, _impl_float_up)(struct SNAME *_heap_, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Current index */ size_t C = index; V child = _heap_->buffer[C]; @@ -328,6 +400,10 @@ static void CMC_(PFX, _impl_float_up)(struct SNAME *_heap_, size_t index) static void CMC_(PFX, _impl_float_down)(struct SNAME *_heap_, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + int mod = _heap_->HO; while (index < _heap_->count) diff --git a/src/cmc/cmc/heap/ext/code.h b/src/cmc/cmc/heap/ext/code.h index ccb6aca..0d63a3c 100644 --- a/src/cmc/cmc/heap/ext/code.h +++ b/src/cmc/cmc/heap/ext/code.h @@ -41,6 +41,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -53,6 +57,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -68,16 +76,28 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) bool CMC_(PFX, _iter_at_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_at_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = 0; @@ -92,6 +112,10 @@ bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->target->count - 1; @@ -106,6 +130,10 @@ bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -124,6 +152,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -143,6 +175,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -168,6 +204,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -191,6 +231,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -204,6 +248,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (V){ 0 }; @@ -212,6 +260,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->cursor; } @@ -226,6 +278,10 @@ size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _to_string)(struct SNAME *_heap_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *h_ = _heap_; const char *t = h_->HO == 1 ? "MaxHeap" : "MinHeap"; @@ -246,6 +302,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_heap_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_heap_, FILE *fptr, const char *start, const char *separator, const char *end) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + fprintf(fptr, "%s", start); for (size_t i = 0; i < _heap_->count; i++) diff --git a/src/cmc/cmc/intervalheap/code.h b/src/cmc/cmc/intervalheap/code.h index 4e48ae5..6a5d307 100644 --- a/src/cmc/cmc/intervalheap/code.h +++ b/src/cmc/cmc/intervalheap/code.h @@ -30,12 +30,20 @@ static void CMC_(PFX, _impl_float_down_min)(struct SNAME *_heap_); struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL); } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (capacity == 0 || capacity == UINTMAX_MAX) @@ -75,6 +83,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) void CMC_(PFX, _clear)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_heap_->f_val->free) { for (size_t i = 0; i < _heap_->count; i++) @@ -92,6 +104,10 @@ void CMC_(PFX, _clear)(struct SNAME *_heap_) void CMC_(PFX, _free)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_heap_->f_val->free) { for (size_t i = 0; i < _heap_->count; i++) @@ -108,6 +124,10 @@ void CMC_(PFX, _free)(struct SNAME *_heap_) void CMC_(PFX, _customize)(struct SNAME *_heap_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -122,6 +142,10 @@ void CMC_(PFX, _customize)(struct SNAME *_heap_, struct CMC_ALLOC_NODE_NAME *all bool CMC_(PFX, _insert)(struct SNAME *_heap_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _full)(_heap_)) { if (!CMC_(PFX, _resize)(_heap_, _heap_->capacity * 4)) @@ -178,6 +202,10 @@ bool CMC_(PFX, _insert)(struct SNAME *_heap_, V value) bool CMC_(PFX, _remove_max)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_heap_)) { _heap_->flag = CMC_FLAG_EMPTY; @@ -230,6 +258,10 @@ success: bool CMC_(PFX, _remove_min)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_heap_)) { _heap_->flag = CMC_FLAG_EMPTY; @@ -282,6 +314,10 @@ success: bool CMC_(PFX, _update_max)(struct SNAME *_heap_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_heap_)) { _heap_->flag = CMC_FLAG_EMPTY; @@ -318,6 +354,10 @@ bool CMC_(PFX, _update_max)(struct SNAME *_heap_, V value) bool CMC_(PFX, _update_min)(struct SNAME *_heap_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_heap_)) { _heap_->flag = CMC_FLAG_EMPTY; @@ -354,6 +394,10 @@ bool CMC_(PFX, _update_min)(struct SNAME *_heap_, V value) V CMC_(PFX, _max)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_heap_)) { _heap_->flag = CMC_FLAG_EMPTY; @@ -374,6 +418,10 @@ V CMC_(PFX, _max)(struct SNAME *_heap_) V CMC_(PFX, _min)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_heap_)) { _heap_->flag = CMC_FLAG_EMPTY; @@ -389,6 +437,10 @@ V CMC_(PFX, _min)(struct SNAME *_heap_) bool CMC_(PFX, _contains)(struct SNAME *_heap_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _heap_->flag = CMC_FLAG_OK; bool result = false; @@ -409,32 +461,56 @@ bool CMC_(PFX, _contains)(struct SNAME *_heap_, V value) bool CMC_(PFX, _empty)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _heap_->count == 0; } bool CMC_(PFX, _full)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* The heap is full if all nodes are completely filled */ return _heap_->size >= _heap_->capacity && _heap_->count % 2 == 0; } size_t CMC_(PFX, _count)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _heap_->count; } size_t CMC_(PFX, _capacity)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _heap_->capacity; } int CMC_(PFX, _flag)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _heap_->flag; } bool CMC_(PFX, _resize)(struct SNAME *_heap_, size_t capacity) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_heap_->capacity == capacity) goto success; @@ -480,6 +556,10 @@ success: struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *result = _heap_->alloc->malloc(sizeof(struct SNAME)); if (!result) @@ -522,6 +602,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_heap_) bool CMC_(PFX, _equals)(struct SNAME *_heap1_, struct SNAME *_heap2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _heap1_->flag = CMC_FLAG_OK; _heap2_->flag = CMC_FLAG_OK; @@ -542,6 +626,10 @@ bool CMC_(PFX, _equals)(struct SNAME *_heap1_, struct SNAME *_heap2_) static void CMC_(PFX, _impl_float_up_max)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + size_t index = _heap_->size - 1; V(*curr_node)[2] = &(_heap_->buffer[index]); @@ -589,6 +677,10 @@ static void CMC_(PFX, _impl_float_up_max)(struct SNAME *_heap_) static void CMC_(PFX, _impl_float_up_min)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + size_t index = _heap_->size - 1; V(*curr_node)[2] = &(_heap_->buffer[index]); @@ -617,6 +709,10 @@ static void CMC_(PFX, _impl_float_up_min)(struct SNAME *_heap_) static void CMC_(PFX, _impl_float_down_max)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Floats Down from the MaxHeap */ size_t index = 0; @@ -700,6 +796,10 @@ static void CMC_(PFX, _impl_float_down_max)(struct SNAME *_heap_) static void CMC_(PFX, _impl_float_down_min)(struct SNAME *_heap_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Floats Down from the MinHeap */ size_t index = 0; diff --git a/src/cmc/cmc/intervalheap/ext/code.h b/src/cmc/cmc/intervalheap/ext/code.h index 67ea111..b36a39f 100644 --- a/src/cmc/cmc/intervalheap/ext/code.h +++ b/src/cmc/cmc/intervalheap/ext/code.h @@ -43,6 +43,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -55,6 +59,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -70,16 +78,28 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) bool CMC_(PFX, _iter_at_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_at_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = 0; @@ -94,6 +114,10 @@ bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->target->count - 1; @@ -108,6 +132,10 @@ bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -126,6 +154,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -145,6 +177,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -170,6 +206,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -193,6 +233,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -206,6 +250,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (V){ 0 }; @@ -214,6 +262,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->cursor; } @@ -228,6 +280,10 @@ size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _to_string)(struct SNAME *_heap_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *h_ = _heap_; return 0 <= fprintf(fptr, @@ -247,6 +303,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_heap_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_heap_, FILE *fptr, const char *start, const char *separator, const char *end) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + fprintf(fptr, "%s", start); for (size_t i = 0; i < _heap_->count; i++) diff --git a/src/cmc/cmc/linkedlist/code.h b/src/cmc/cmc/linkedlist/code.h index e37b882..65f8040 100644 --- a/src/cmc/cmc/linkedlist/code.h +++ b/src/cmc/cmc/linkedlist/code.h @@ -28,12 +28,20 @@ struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _impl_new_node)(struct SNAME *_list_, V v struct SNAME *CMC_(PFX, _new)(struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(f_val, NULL, NULL); } struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!f_val) @@ -60,6 +68,10 @@ struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct void CMC_(PFX, _clear)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *scan = _list_->head; while (_list_->head != NULL) @@ -84,6 +96,10 @@ void CMC_(PFX, _clear)(struct SNAME *_list_) void CMC_(PFX, _free)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_(PFX, _clear)(_list_); _list_->alloc->free(_list_); @@ -92,6 +108,10 @@ void CMC_(PFX, _free)(struct SNAME *_list_) void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -106,6 +126,10 @@ void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *all bool CMC_(PFX, _push_front)(struct SNAME *_list_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *_node_ = CMC_(PFX, _impl_new_node)(_list_, value); if (!_node_) @@ -133,6 +157,10 @@ bool CMC_(PFX, _push_front)(struct SNAME *_list_, V value) bool CMC_(PFX, _push_at)(struct SNAME *_list_, V value, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index > _list_->count) { _list_->flag = CMC_FLAG_RANGE; @@ -170,6 +198,10 @@ bool CMC_(PFX, _push_at)(struct SNAME *_list_, V value, size_t index) bool CMC_(PFX, _push_back)(struct SNAME *_list_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *_node_ = CMC_(PFX, _impl_new_node)(_list_, value); if (!_node_) @@ -197,6 +229,10 @@ bool CMC_(PFX, _push_back)(struct SNAME *_list_, V value) bool CMC_(PFX, _pop_front)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -223,6 +259,10 @@ bool CMC_(PFX, _pop_front)(struct SNAME *_list_) bool CMC_(PFX, _pop_at)(struct SNAME *_list_, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -264,6 +304,10 @@ bool CMC_(PFX, _pop_at)(struct SNAME *_list_, size_t index) bool CMC_(PFX, _pop_back)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -290,6 +334,10 @@ bool CMC_(PFX, _pop_back)(struct SNAME *_list_) V CMC_(PFX, _front)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -305,6 +353,10 @@ V CMC_(PFX, _front)(struct SNAME *_list_) V CMC_(PFX, _get)(struct SNAME *_list_, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -329,6 +381,10 @@ V CMC_(PFX, _get)(struct SNAME *_list_, size_t index) V *CMC_(PFX, _get_ref)(struct SNAME *_list_, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -353,6 +409,10 @@ V *CMC_(PFX, _get_ref)(struct SNAME *_list_, size_t index) V CMC_(PFX, _back)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -368,6 +428,10 @@ V CMC_(PFX, _back)(struct SNAME *_list_) bool CMC_(PFX, _contains)(struct SNAME *_list_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _list_->flag = CMC_FLAG_OK; bool result = false; @@ -392,21 +456,37 @@ bool CMC_(PFX, _contains)(struct SNAME *_list_, V value) bool CMC_(PFX, _empty)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->count == 0; } size_t CMC_(PFX, _count)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->count; } int CMC_(PFX, _flag)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->flag; } struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *result = CMC_(PFX, _new_custom)(_list_->f_val, _list_->alloc, NULL); if (!result) @@ -451,6 +531,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_list_) bool CMC_(PFX, _equals)(struct SNAME *_list1_, struct SNAME *_list2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _list1_->flag = CMC_FLAG_OK; _list2_->flag = CMC_FLAG_OK; @@ -474,6 +558,10 @@ bool CMC_(PFX, _equals)(struct SNAME *_list1_, struct SNAME *_list2_) struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _impl_new_node)(struct SNAME *_list_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *_node_ = _list_->alloc->malloc(sizeof(struct CMC_DEF_NODE(SNAME))); if (!_node_) @@ -491,6 +579,10 @@ struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _impl_new_node)(struct SNAME *_list_, V v struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _impl_get_node)(struct SNAME *_list_, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; diff --git a/src/cmc/cmc/linkedlist/ext/code.h b/src/cmc/cmc/linkedlist/ext/code.h index b6eb0df..ecc99dd 100644 --- a/src/cmc/cmc/linkedlist/ext/code.h +++ b/src/cmc/cmc/linkedlist/ext/code.h @@ -41,6 +41,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -54,6 +58,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -70,16 +78,28 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) bool CMC_(PFX, _iter_at_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_at_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->target->head; @@ -95,6 +115,10 @@ bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->target->tail; @@ -110,6 +134,10 @@ bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -129,6 +157,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -149,6 +181,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -174,6 +210,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -200,6 +240,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -213,6 +257,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (V){ 0 }; @@ -221,6 +269,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return NULL; @@ -229,11 +281,19 @@ V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->index; } struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _iter_node)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->cursor; } @@ -248,6 +308,10 @@ struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _iter_node)(struct CMC_DEF_ITER(SNAME) * struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _new_node)(struct SNAME *_list_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *_node_ = _list_->alloc->malloc(sizeof(struct CMC_DEF_NODE(SNAME))); if (!_node_) @@ -265,16 +329,28 @@ struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _new_node)(struct SNAME *_list_, V value) void CMC_(PFX, _free_node)(struct SNAME *_list_, struct CMC_DEF_NODE(SNAME) * _node_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _list_->alloc->free(_node_); } struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _head)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->head; } struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _get_node)(struct SNAME *_list_, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -313,11 +389,19 @@ struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _get_node)(struct SNAME *_list_, size_t i struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _tail)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->tail; } bool CMC_(PFX, _add_next)(struct SNAME *_owner_, struct CMC_DEF_NODE(SNAME) * _node_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *new_node = CMC_(PFX, _new_node)(_owner_, value); if (!new_node) @@ -341,6 +425,10 @@ bool CMC_(PFX, _add_next)(struct SNAME *_owner_, struct CMC_DEF_NODE(SNAME) * _n bool CMC_(PFX, _add_prev)(struct SNAME *_owner_, struct CMC_DEF_NODE(SNAME) * _node_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *new_node = CMC_(PFX, _new_node)(_owner_, value); if (!new_node) @@ -364,6 +452,10 @@ bool CMC_(PFX, _add_prev)(struct SNAME *_owner_, struct CMC_DEF_NODE(SNAME) * _n bool CMC_(PFX, _del_next)(struct SNAME *_owner_, struct CMC_DEF_NODE(SNAME) * _node_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_node_->next == NULL) { _owner_->flag = CMC_FLAG_INVALID; @@ -389,6 +481,10 @@ bool CMC_(PFX, _del_next)(struct SNAME *_owner_, struct CMC_DEF_NODE(SNAME) * _n bool CMC_(PFX, _del_curr)(struct SNAME *_owner_, struct CMC_DEF_NODE(SNAME) * _node_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_node_->prev != NULL) _node_->prev->next = _node_->next; else @@ -409,6 +505,10 @@ bool CMC_(PFX, _del_curr)(struct SNAME *_owner_, struct CMC_DEF_NODE(SNAME) * _n bool CMC_(PFX, _del_prev)(struct SNAME *_owner_, struct CMC_DEF_NODE(SNAME) * _node_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_node_->prev == NULL) { _owner_->flag = CMC_FLAG_INVALID; @@ -434,11 +534,19 @@ bool CMC_(PFX, _del_prev)(struct SNAME *_owner_, struct CMC_DEF_NODE(SNAME) * _n struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _next_node)(struct CMC_DEF_NODE(SNAME) * _node_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _node_->next; } struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _prev_node)(struct CMC_DEF_NODE(SNAME) * _node_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _node_->prev; } @@ -453,6 +561,10 @@ struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _prev_node)(struct CMC_DEF_NODE(SNAME) * bool CMC_(PFX, _to_string)(struct SNAME *_list_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *l_ = _list_; return 0 <= fprintf(fptr, @@ -471,6 +583,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_list_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_list_, FILE *fptr, const char *start, const char *separator, const char *end) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + fprintf(fptr, "%s", start); struct CMC_DEF_NODE(SNAME) *scan = _list_->head; diff --git a/src/cmc/cmc/list/code.h b/src/cmc/cmc/list/code.h index 0de9edd..7bb0630 100644 --- a/src/cmc/cmc/list/code.h +++ b/src/cmc/cmc/list/code.h @@ -27,12 +27,20 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL); } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (capacity < 1) @@ -69,6 +77,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) void CMC_(PFX, _clear)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_list_->f_val->free) { for (size_t i = 0; i < _list_->count; i++) @@ -83,6 +95,10 @@ void CMC_(PFX, _clear)(struct SNAME *_list_) void CMC_(PFX, _free)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_list_->f_val->free) { for (size_t i = 0; i < _list_->count; i++) @@ -96,6 +112,10 @@ void CMC_(PFX, _free)(struct SNAME *_list_) void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -110,6 +130,10 @@ void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *all bool CMC_(PFX, _push_front)(struct SNAME *_list_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _full)(_list_)) { if (!CMC_(PFX, _resize)(_list_, _list_->count * 2)) @@ -133,6 +157,10 @@ bool CMC_(PFX, _push_front)(struct SNAME *_list_, V value) bool CMC_(PFX, _push_at)(struct SNAME *_list_, V value, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index > _list_->count) { _list_->flag = CMC_FLAG_RANGE; @@ -158,6 +186,10 @@ bool CMC_(PFX, _push_at)(struct SNAME *_list_, V value, size_t index) bool CMC_(PFX, _push_back)(struct SNAME *_list_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _full)(_list_)) { if (!CMC_(PFX, _resize)(_list_, _list_->count * 2)) @@ -174,6 +206,10 @@ bool CMC_(PFX, _push_back)(struct SNAME *_list_, V value) bool CMC_(PFX, _pop_front)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -192,6 +228,10 @@ bool CMC_(PFX, _pop_front)(struct SNAME *_list_) bool CMC_(PFX, _pop_at)(struct SNAME *_list_, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -216,6 +256,10 @@ bool CMC_(PFX, _pop_at)(struct SNAME *_list_, size_t index) bool CMC_(PFX, _pop_back)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) return false; @@ -229,6 +273,10 @@ bool CMC_(PFX, _pop_back)(struct SNAME *_list_) V CMC_(PFX, _front)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -244,6 +292,10 @@ V CMC_(PFX, _front)(struct SNAME *_list_) V CMC_(PFX, _get)(struct SNAME *_list_, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -265,6 +317,10 @@ V CMC_(PFX, _get)(struct SNAME *_list_, size_t index) V *CMC_(PFX, _get_ref)(struct SNAME *_list_, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -286,6 +342,10 @@ V *CMC_(PFX, _get_ref)(struct SNAME *_list_, size_t index) V CMC_(PFX, _back)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -301,6 +361,10 @@ V CMC_(PFX, _back)(struct SNAME *_list_) size_t CMC_(PFX, _index_of)(struct SNAME *_list_, V value, bool from_start) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _list_->flag = CMC_FLAG_OK; size_t result = _list_->count; @@ -335,6 +399,10 @@ size_t CMC_(PFX, _index_of)(struct SNAME *_list_, V value, bool from_start) bool CMC_(PFX, _contains)(struct SNAME *_list_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _list_->flag = CMC_FLAG_OK; bool result = false; @@ -355,36 +423,64 @@ bool CMC_(PFX, _contains)(struct SNAME *_list_, V value) bool CMC_(PFX, _empty)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->count == 0; } bool CMC_(PFX, _full)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->count >= _list_->capacity; } size_t CMC_(PFX, _count)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->count; } bool CMC_(PFX, _fits)(struct SNAME *_list_, size_t size) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->count + size <= _list_->capacity; } size_t CMC_(PFX, _capacity)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->capacity; } int CMC_(PFX, _flag)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->flag; } bool CMC_(PFX, _resize)(struct SNAME *_list_, size_t capacity) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _list_->flag = CMC_FLAG_OK; if (_list_->capacity == capacity) @@ -416,6 +512,10 @@ bool CMC_(PFX, _resize)(struct SNAME *_list_, size_t capacity) struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *result = CMC_(PFX, _new_custom)(_list_->capacity, _list_->f_val, _list_->alloc, NULL); if (!result) @@ -443,6 +543,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_list_) bool CMC_(PFX, _equals)(struct SNAME *_list1_, struct SNAME *_list2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _list1_->flag = CMC_FLAG_OK; _list2_->flag = CMC_FLAG_OK; diff --git a/src/cmc/cmc/list/ext/code.h b/src/cmc/cmc/list/ext/code.h index 182a6b5..e801405 100644 --- a/src/cmc/cmc/list/ext/code.h +++ b/src/cmc/cmc/list/ext/code.h @@ -32,12 +32,20 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _init_custom)(capacity, f_val, NULL, NULL); } struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); struct SNAME _list_ = { 0 }; @@ -68,6 +76,10 @@ struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) void CMC_(PFX, _release)(struct SNAME _list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_list_.f_val->free) { for (size_t i = 0; i < _list_.count; i++) @@ -88,6 +100,10 @@ void CMC_(PFX, _release)(struct SNAME _list_) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -100,6 +116,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -115,16 +135,28 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) bool CMC_(PFX, _iter_at_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_at_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = 0; @@ -139,6 +171,10 @@ bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->start = CMC_(PFX, _empty)(iter->target); @@ -153,6 +189,10 @@ bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -171,6 +211,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -190,6 +234,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -212,6 +260,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -235,6 +287,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -248,6 +304,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (V){ 0 }; @@ -256,6 +316,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return NULL; @@ -264,6 +328,10 @@ V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->cursor; } @@ -278,6 +346,10 @@ size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _seq_push_front)(struct SNAME *_list_, V *values, size_t size) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (size == 0) { _list_->flag = CMC_FLAG_INVALID; @@ -304,6 +376,10 @@ bool CMC_(PFX, _seq_push_front)(struct SNAME *_list_, V *values, size_t size) bool CMC_(PFX, _seq_push_at)(struct SNAME *_list_, V *values, size_t size, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (size == 0) { _list_->flag = CMC_FLAG_INVALID; @@ -341,6 +417,10 @@ bool CMC_(PFX, _seq_push_at)(struct SNAME *_list_, V *values, size_t size, size_ bool CMC_(PFX, _seq_push_back)(struct SNAME *_list_, V *values, size_t size) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (size == 0) { _list_->flag = CMC_FLAG_INVALID; @@ -365,6 +445,10 @@ bool CMC_(PFX, _seq_push_back)(struct SNAME *_list_, V *values, size_t size) bool CMC_(PFX, _seq_pop_at)(struct SNAME *_list_, size_t from, size_t to) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (from > to) { _list_->flag = CMC_FLAG_INVALID; @@ -393,6 +477,10 @@ bool CMC_(PFX, _seq_pop_at)(struct SNAME *_list_, size_t from, size_t to) struct SNAME *CMC_(PFX, _seq_sublist)(struct SNAME *_list_, size_t from, size_t to) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (from > to) { _list_->flag = CMC_FLAG_INVALID; @@ -442,6 +530,10 @@ struct SNAME *CMC_(PFX, _seq_sublist)(struct SNAME *_list_, size_t from, size_t bool CMC_(PFX, _to_string)(struct SNAME *_list_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *l_ = _list_; return 0 <= fprintf(fptr, @@ -460,6 +552,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_list_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_list_, FILE *fptr, const char *start, const char *separator, const char *end) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + fprintf(fptr, "%s", start); for (size_t i = 0; i < _list_->count; i++) diff --git a/src/cmc/cmc/queue/code.h b/src/cmc/cmc/queue/code.h index 9f93f7d..78a90b3 100644 --- a/src/cmc/cmc/queue/code.h +++ b/src/cmc/cmc/queue/code.h @@ -27,12 +27,20 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL); } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (capacity < 1) @@ -71,6 +79,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) void CMC_(PFX, _clear)(struct SNAME *_queue_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_queue_->f_val->free) { for (size_t i = _queue_->front, j = 0; j < _queue_->count; j++) @@ -91,6 +103,10 @@ void CMC_(PFX, _clear)(struct SNAME *_queue_) void CMC_(PFX, _free)(struct SNAME *_queue_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_queue_->f_val->free) { for (size_t i = _queue_->front, j = 0; j < _queue_->count; j++) @@ -108,6 +124,10 @@ void CMC_(PFX, _free)(struct SNAME *_queue_) void CMC_(PFX, _customize)(struct SNAME *_queue_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -122,6 +142,10 @@ void CMC_(PFX, _customize)(struct SNAME *_queue_, struct CMC_ALLOC_NODE_NAME *al bool CMC_(PFX, _enqueue)(struct SNAME *_queue_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _full)(_queue_)) { if (!CMC_(PFX, _resize)(_queue_, _queue_->capacity * 2)) @@ -141,6 +165,10 @@ bool CMC_(PFX, _enqueue)(struct SNAME *_queue_, V value) bool CMC_(PFX, _dequeue)(struct SNAME *_queue_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_queue_)) { _queue_->flag = CMC_FLAG_EMPTY; @@ -160,6 +188,10 @@ bool CMC_(PFX, _dequeue)(struct SNAME *_queue_) V CMC_(PFX, _peek)(struct SNAME *_queue_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_queue_)) { _queue_->flag = CMC_FLAG_EMPTY; @@ -175,6 +207,10 @@ V CMC_(PFX, _peek)(struct SNAME *_queue_) bool CMC_(PFX, _contains)(struct SNAME *_queue_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _queue_->flag = CMC_FLAG_OK; bool result = false; @@ -197,31 +233,55 @@ bool CMC_(PFX, _contains)(struct SNAME *_queue_, V value) bool CMC_(PFX, _empty)(struct SNAME *_queue_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _queue_->count == 0; } bool CMC_(PFX, _full)(struct SNAME *_queue_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _queue_->count >= _queue_->capacity; } size_t CMC_(PFX, _count)(struct SNAME *_queue_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _queue_->count; } size_t CMC_(PFX, _capacity)(struct SNAME *_queue_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _queue_->capacity; } int CMC_(PFX, _flag)(struct SNAME *_queue_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _queue_->flag; } bool CMC_(PFX, _resize)(struct SNAME *_queue_, size_t capacity) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_queue_->capacity == capacity) goto success; @@ -264,6 +324,10 @@ success: struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_queue_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *result = CMC_(PFX, _new_custom)(_queue_->capacity, _queue_->f_val, _queue_->alloc, NULL); if (!result) @@ -304,6 +368,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_queue_) bool CMC_(PFX, _equals)(struct SNAME *_queue1_, struct SNAME *_queue2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _queue1_->flag = CMC_FLAG_OK; _queue2_->flag = CMC_FLAG_OK; diff --git a/src/cmc/cmc/queue/ext/code.h b/src/cmc/cmc/queue/ext/code.h index 95f53c4..33fc523 100644 --- a/src/cmc/cmc/queue/ext/code.h +++ b/src/cmc/cmc/queue/ext/code.h @@ -32,12 +32,20 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _init_custom)(capacity, f_val, NULL, NULL); } struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); struct SNAME _queue_ = { 0 }; @@ -70,6 +78,10 @@ struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) void CMC_(PFX, _release)(struct SNAME _queue_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_queue_.f_val->free) { for (size_t i = _queue_.front, j = 0; j < _queue_.count; j++) @@ -94,6 +106,10 @@ void CMC_(PFX, _release)(struct SNAME _queue_) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -107,6 +123,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -134,16 +154,28 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) bool CMC_(PFX, _iter_at_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_at_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->target->front; @@ -159,6 +191,10 @@ bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { if (iter->target->back == 0) @@ -179,6 +215,10 @@ bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -198,6 +238,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -218,6 +262,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -241,6 +289,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -270,6 +322,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -283,6 +339,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (V){ 0 }; @@ -291,6 +351,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return NULL; @@ -299,6 +363,10 @@ V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->index; } @@ -313,6 +381,10 @@ size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _to_string)(struct SNAME *_queue_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *q_ = _queue_; return 0 <= fprintf(fptr, @@ -333,6 +405,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_queue_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_queue_, FILE *fptr, const char *start, const char *separator, const char *end) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + fprintf(fptr, "%s", start); for (size_t i = _queue_->front, j = 0; j < _queue_->count; j++) diff --git a/src/cmc/cmc/sortedlist/code.h b/src/cmc/cmc/sortedlist/code.h index 483e346..b8f00fa 100644 --- a/src/cmc/cmc/sortedlist/code.h +++ b/src/cmc/cmc/sortedlist/code.h @@ -30,12 +30,20 @@ void CMC_(PFX, _impl_sort_insertion)(V *array, int (*cmp)(V, V), size_t low, siz struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL); } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (capacity < 1) @@ -70,6 +78,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) void CMC_(PFX, _clear)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_list_->f_val->free) { for (size_t i = 0; i < _list_->count; i++) @@ -84,6 +96,10 @@ void CMC_(PFX, _clear)(struct SNAME *_list_) void CMC_(PFX, _free)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_list_->f_val->free) { for (size_t i = 0; i < _list_->count; i++) @@ -97,6 +113,10 @@ void CMC_(PFX, _free)(struct SNAME *_list_) void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -111,6 +131,10 @@ void CMC_(PFX, _customize)(struct SNAME *_list_, struct CMC_ALLOC_NODE_NAME *all bool CMC_(PFX, _insert)(struct SNAME *_list_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _full)(_list_)) { if (!CMC_(PFX, _resize)(_list_, _list_->capacity * 2)) @@ -129,6 +153,10 @@ bool CMC_(PFX, _insert)(struct SNAME *_list_, V value) bool CMC_(PFX, _remove)(struct SNAME *_list_, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -154,6 +182,10 @@ bool CMC_(PFX, _remove)(struct SNAME *_list_, size_t index) V CMC_(PFX, _max)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -171,6 +203,10 @@ V CMC_(PFX, _max)(struct SNAME *_list_) V CMC_(PFX, _min)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -188,6 +224,10 @@ V CMC_(PFX, _min)(struct SNAME *_list_) V CMC_(PFX, _get)(struct SNAME *_list_, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) { _list_->flag = CMC_FLAG_EMPTY; @@ -211,6 +251,10 @@ V CMC_(PFX, _get)(struct SNAME *_list_, size_t index) size_t CMC_(PFX, _index_of)(struct SNAME *_list_, V value, bool from_start) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _list_->flag = CMC_FLAG_OK; CMC_(PFX, _sort)(_list_); @@ -227,6 +271,10 @@ size_t CMC_(PFX, _index_of)(struct SNAME *_list_, V value, bool from_start) bool CMC_(PFX, _contains)(struct SNAME *_list_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _list_->flag = CMC_FLAG_OK; if (CMC_(PFX, _empty)(_list_)) @@ -241,31 +289,55 @@ bool CMC_(PFX, _contains)(struct SNAME *_list_, V value) bool CMC_(PFX, _empty)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->count == 0; } bool CMC_(PFX, _full)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->count >= _list_->capacity; } size_t CMC_(PFX, _count)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->count; } size_t CMC_(PFX, _capacity)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->capacity; } int CMC_(PFX, _flag)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _list_->flag; } bool CMC_(PFX, _resize)(struct SNAME *_list_, size_t capacity) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_list_->capacity == capacity) goto success; @@ -299,6 +371,10 @@ success: void CMC_(PFX, _sort)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _list_->flag = CMC_FLAG_OK; if (!_list_->is_sorted && _list_->count > 1) @@ -312,6 +388,10 @@ void CMC_(PFX, _sort)(struct SNAME *_list_) struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_list_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *result = CMC_(PFX, _new_custom)(_list_->capacity, _list_->f_val, _list_->alloc, NULL); if (!result) @@ -339,6 +419,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_list_) bool CMC_(PFX, _equals)(struct SNAME *_list1_, struct SNAME *_list2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_list1_->count != _list2_->count) return false; @@ -356,6 +440,10 @@ bool CMC_(PFX, _equals)(struct SNAME *_list1_, struct SNAME *_list2_) static size_t CMC_(PFX, _impl_binary_search_first)(struct SNAME *_list_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) return 1; @@ -381,6 +469,10 @@ static size_t CMC_(PFX, _impl_binary_search_first)(struct SNAME *_list_, V value static size_t CMC_(PFX, _impl_binary_search_last)(struct SNAME *_list_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_list_)) return 1; @@ -410,6 +502,10 @@ static size_t CMC_(PFX, _impl_binary_search_last)(struct SNAME *_list_, V value) /* - Tail recursion: minimize recursion depth */ void CMC_(PFX, _impl_sort_quicksort)(V *array, int (*cmp)(V, V), size_t low, size_t high) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + while (low < high) { /* Quicksort performs poorly for smaller arrays so let */ @@ -463,6 +559,10 @@ void CMC_(PFX, _impl_sort_quicksort)(V *array, int (*cmp)(V, V), size_t low, siz void CMC_(PFX, _impl_sort_insertion)(V *array, int (*cmp)(V, V), size_t low, size_t high) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + for (size_t i = low + 1; i <= high; i++) { V _tmp_ = array[i]; diff --git a/src/cmc/cmc/sortedlist/ext/code.h b/src/cmc/cmc/sortedlist/ext/code.h index 8427190..cc5f30f 100644 --- a/src/cmc/cmc/sortedlist/ext/code.h +++ b/src/cmc/cmc/sortedlist/ext/code.h @@ -41,6 +41,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_(PFX, _sort)(target); struct CMC_DEF_ITER(SNAME) iter; @@ -55,6 +59,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_(PFX, _sort)(target); struct CMC_DEF_ITER(SNAME) iter; @@ -72,16 +80,28 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) bool CMC_(PFX, _iter_at_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_at_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = 0; @@ -96,6 +116,10 @@ bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->start = CMC_(PFX, _empty)(iter->target); @@ -110,6 +134,10 @@ bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -128,6 +156,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -147,6 +179,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -169,6 +205,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -192,6 +232,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -205,6 +249,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (V){ 0 }; @@ -213,6 +261,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->cursor; } @@ -227,6 +279,10 @@ size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _to_string)(struct SNAME *_list_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *l_ = _list_; return 0 <= fprintf(fptr, @@ -246,6 +302,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_list_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_list_, FILE *fptr, const char *start, const char *separator, const char *end) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_(PFX, _sort)(_list_); fprintf(fptr, "%s", start); diff --git a/src/cmc/cmc/stack/code.h b/src/cmc/cmc/stack/code.h index f34ed6d..5c52095 100644 --- a/src/cmc/cmc/stack/code.h +++ b/src/cmc/cmc/stack/code.h @@ -27,12 +27,20 @@ struct SNAME *CMC_(PFX, _new)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(capacity, f_val, NULL, NULL); } struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (capacity < 1) @@ -68,6 +76,10 @@ struct SNAME *CMC_(PFX, _new_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) void CMC_(PFX, _clear)(struct SNAME *_stack_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_stack_->f_val->free) { for (size_t i = 0; i < _stack_->count; i++) @@ -82,6 +94,10 @@ void CMC_(PFX, _clear)(struct SNAME *_stack_) void CMC_(PFX, _free)(struct SNAME *_stack_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_stack_->f_val->free) { for (size_t i = 0; i < _stack_->count; i++) @@ -95,6 +111,10 @@ void CMC_(PFX, _free)(struct SNAME *_stack_) void CMC_(PFX, _customize)(struct SNAME *_stack_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -109,6 +129,10 @@ void CMC_(PFX, _customize)(struct SNAME *_stack_, struct CMC_ALLOC_NODE_NAME *al bool CMC_(PFX, _push)(struct SNAME *_stack_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _full)(_stack_)) { if (!CMC_(PFX, _resize)(_stack_, _stack_->capacity * 2)) @@ -126,6 +150,10 @@ bool CMC_(PFX, _push)(struct SNAME *_stack_, V value) bool CMC_(PFX, _pop)(struct SNAME *_stack_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_stack_)) { _stack_->flag = CMC_FLAG_EMPTY; @@ -143,6 +171,10 @@ bool CMC_(PFX, _pop)(struct SNAME *_stack_) V CMC_(PFX, _top)(struct SNAME *_stack_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_stack_)) { _stack_->flag = CMC_FLAG_EMPTY; @@ -158,6 +190,10 @@ V CMC_(PFX, _top)(struct SNAME *_stack_) bool CMC_(PFX, _contains)(struct SNAME *_stack_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _stack_->flag = CMC_FLAG_OK; bool result = false; @@ -178,31 +214,55 @@ bool CMC_(PFX, _contains)(struct SNAME *_stack_, V value) bool CMC_(PFX, _empty)(struct SNAME *_stack_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _stack_->count == 0; } bool CMC_(PFX, _full)(struct SNAME *_stack_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _stack_->count >= _stack_->capacity; } size_t CMC_(PFX, _count)(struct SNAME *_stack_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _stack_->count; } size_t CMC_(PFX, _capacity)(struct SNAME *_stack_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _stack_->capacity; } int CMC_(PFX, _flag)(struct SNAME *_stack_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _stack_->flag; } bool CMC_(PFX, _resize)(struct SNAME *_stack_, size_t capacity) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_stack_->capacity == capacity) goto success; @@ -236,6 +296,10 @@ success: struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_stack_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *result = CMC_(PFX, _new_custom)(_stack_->capacity, _stack_->f_val, _stack_->alloc, NULL); if (!result) @@ -263,6 +327,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_stack_) bool CMC_(PFX, _equals)(struct SNAME *_stack1_, struct SNAME *_stack2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _stack1_->flag = CMC_FLAG_OK; _stack2_->flag = CMC_FLAG_OK; diff --git a/src/cmc/cmc/stack/ext/code.h b/src/cmc/cmc/stack/ext/code.h index 6b179b9..b72a470 100644 --- a/src/cmc/cmc/stack/ext/code.h +++ b/src/cmc/cmc/stack/ext/code.h @@ -32,12 +32,20 @@ struct SNAME CMC_(PFX, _init)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _init_custom)(capacity, f_val, NULL, NULL); } struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); struct SNAME _stack_ = { 0 }; @@ -68,6 +76,10 @@ struct SNAME CMC_(PFX, _init_custom)(size_t capacity, struct CMC_DEF_FVAL(SNAME) void CMC_(PFX, _release)(struct SNAME _stack_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (_stack_.f_val->free) { for (size_t i = 0; i < _stack_.count; i++) @@ -88,6 +100,10 @@ void CMC_(PFX, _release)(struct SNAME _stack_) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -103,6 +119,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -115,16 +135,28 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) bool CMC_(PFX, _iter_at_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_at_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = iter->target->count - 1; @@ -139,6 +171,10 @@ bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->cursor = 0; @@ -153,6 +189,10 @@ bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -171,6 +211,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -190,6 +234,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -212,6 +260,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -235,6 +287,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -248,6 +304,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (V){ 0 }; @@ -256,6 +316,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return NULL; @@ -264,6 +328,10 @@ V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return 0; @@ -281,6 +349,10 @@ size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _to_string)(struct SNAME *_stack_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *s_ = _stack_; return 0 <= fprintf(fptr, @@ -299,6 +371,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_stack_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_stack_, FILE *fptr, const char *start, const char *separator, const char *end) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + fprintf(fptr, "%s", start); for (size_t i = _stack_->count; i > 0; i--) diff --git a/src/cmc/cmc/treemap/code.h b/src/cmc/cmc/treemap/code.h index 7697dbe..24981a7 100644 --- a/src/cmc/cmc/treemap/code.h +++ b/src/cmc/cmc/treemap/code.h @@ -33,12 +33,20 @@ static void CMC_(PFX, _impl_rebalance)(struct SNAME *_map_, struct CMC_DEF_NODE( struct SNAME *CMC_(PFX, _new)(struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(f_key, f_val, NULL, NULL); } struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FKEY(SNAME) * f_key, struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!f_key || !f_val) @@ -65,6 +73,10 @@ struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FKEY(SNAME) * f_key, struct void CMC_(PFX, _clear)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *scan = _map_->root; struct CMC_DEF_NODE(SNAME) *up = NULL; @@ -131,6 +143,10 @@ void CMC_(PFX, _clear)(struct SNAME *_map_) void CMC_(PFX, _free)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_(PFX, _clear)(_map_); _map_->alloc->free(_map_); @@ -138,6 +154,10 @@ void CMC_(PFX, _free)(struct SNAME *_map_) void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -152,6 +172,10 @@ void CMC_(PFX, _customize)(struct SNAME *_map_, struct CMC_ALLOC_NODE_NAME *allo bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->root = CMC_(PFX, _impl_new_node)(_map_, key, value); @@ -224,6 +248,10 @@ bool CMC_(PFX, _insert)(struct SNAME *_map_, K key, V value) bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *node = CMC_(PFX, _impl_get_node)(_map_, key); if (!node) @@ -246,6 +274,10 @@ bool CMC_(PFX, _update)(struct SNAME *_map_, K key, V new_value, V *old_value) bool CMC_(PFX, _remove)(struct SNAME *_map_, K key, V *out_value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -384,6 +416,10 @@ bool CMC_(PFX, _remove)(struct SNAME *_map_, K key, V *out_value) bool CMC_(PFX, _max)(struct SNAME *_map_, K *key, V *value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -409,6 +445,10 @@ bool CMC_(PFX, _max)(struct SNAME *_map_, K *key, V *value) bool CMC_(PFX, _min)(struct SNAME *_map_, K *key, V *value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -434,6 +474,10 @@ bool CMC_(PFX, _min)(struct SNAME *_map_, K *key, V *value) V CMC_(PFX, _get)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -457,6 +501,10 @@ V CMC_(PFX, _get)(struct SNAME *_map_, K key) V *CMC_(PFX, _get_ref)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_map_)) { _map_->flag = CMC_FLAG_EMPTY; @@ -480,6 +528,10 @@ V *CMC_(PFX, _get_ref)(struct SNAME *_map_, K key) bool CMC_(PFX, _contains)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + bool result = CMC_(PFX, _impl_get_node)(_map_, key) != NULL; CMC_CALLBACKS_CALL(_map_, read); @@ -489,21 +541,37 @@ bool CMC_(PFX, _contains)(struct SNAME *_map_, K key) bool CMC_(PFX, _empty)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->count == 0; } size_t CMC_(PFX, _count)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->count; } int CMC_(PFX, _flag)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _map_->flag; } struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_map_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Callback will be added later */ struct SNAME *result = CMC_(PFX, _new_custom)(_map_->f_key, _map_->f_val, _map_->alloc, NULL); @@ -570,6 +638,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_map_) bool CMC_(PFX, _equals)(struct SNAME *_map1_, struct SNAME *_map2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _map1_->flag = CMC_FLAG_OK; _map2_->flag = CMC_FLAG_OK; @@ -623,6 +695,10 @@ bool CMC_(PFX, _equals)(struct SNAME *_map1_, struct SNAME *_map2_) static struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _impl_new_node)(struct SNAME *_map_, K key, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *node = _map_->alloc->malloc(sizeof(struct CMC_DEF_NODE(SNAME))); if (!node) @@ -640,6 +716,10 @@ static struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _impl_new_node)(struct SNAME *_map static struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _impl_get_node)(struct SNAME *_map_, K key) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *scan = _map_->root; while (scan != NULL) @@ -657,6 +737,10 @@ static struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _impl_get_node)(struct SNAME *_map static unsigned char CMC_(PFX, _impl_h)(struct CMC_DEF_NODE(SNAME) * node) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (node == NULL) return 0; @@ -665,6 +749,10 @@ static unsigned char CMC_(PFX, _impl_h)(struct CMC_DEF_NODE(SNAME) * node) static unsigned char CMC_(PFX, _impl_hupdate)(struct CMC_DEF_NODE(SNAME) * node) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (node == NULL) return 0; @@ -676,6 +764,10 @@ static unsigned char CMC_(PFX, _impl_hupdate)(struct CMC_DEF_NODE(SNAME) * node) static void CMC_(PFX, _impl_rotate_right)(struct CMC_DEF_NODE(SNAME) * *Z) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *root = *Z; struct CMC_DEF_NODE(SNAME) *new_root = root->left; @@ -705,6 +797,10 @@ static void CMC_(PFX, _impl_rotate_right)(struct CMC_DEF_NODE(SNAME) * *Z) static void CMC_(PFX, _impl_rotate_left)(struct CMC_DEF_NODE(SNAME) * *Z) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *root = *Z; struct CMC_DEF_NODE(SNAME) *new_root = root->right; @@ -734,6 +830,10 @@ static void CMC_(PFX, _impl_rotate_left)(struct CMC_DEF_NODE(SNAME) * *Z) static void CMC_(PFX, _impl_rebalance)(struct SNAME *_map_, struct CMC_DEF_NODE(SNAME) * node) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *scan = node, *child = NULL; int balance; diff --git a/src/cmc/cmc/treemap/ext/code.h b/src/cmc/cmc/treemap/ext/code.h index a100226..1fcd452 100644 --- a/src/cmc/cmc/treemap/ext/code.h +++ b/src/cmc/cmc/treemap/ext/code.h @@ -41,6 +41,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -68,6 +72,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -97,16 +105,28 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) bool CMC_(PFX, _iter_at_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_at_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->index = 0; @@ -122,6 +142,10 @@ bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->index = iter->target->count - 1; @@ -137,6 +161,10 @@ bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -177,6 +205,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -218,6 +250,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -239,6 +275,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -261,6 +301,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -274,6 +318,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) K CMC_(PFX, _iter_key)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (K){ 0 }; @@ -282,6 +330,10 @@ K CMC_(PFX, _iter_key)(struct CMC_DEF_ITER(SNAME) * iter) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (V){ 0 }; @@ -290,6 +342,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return NULL; @@ -298,6 +354,10 @@ V *CMC_(PFX, _iter_rvalue)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->index; } @@ -312,6 +372,10 @@ size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _to_string)(struct SNAME *_map_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *m_ = _map_; return 0 <= fprintf(fptr, @@ -331,6 +395,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_map_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_map_, FILE *fptr, const char *start, const char *separator, const char *end, const char *key_val_sep) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + fprintf(fptr, "%s", start); struct CMC_DEF_NODE(SNAME) *root = _map_->root; diff --git a/src/cmc/cmc/treeset/code.h b/src/cmc/cmc/treeset/code.h index a444938..c011fd9 100644 --- a/src/cmc/cmc/treeset/code.h +++ b/src/cmc/cmc/treeset/code.h @@ -33,12 +33,20 @@ static void CMC_(PFX, _impl_rebalance)(struct SNAME *_set_, struct CMC_DEF_NODE( struct SNAME *CMC_(PFX, _new)(struct CMC_DEF_FVAL(SNAME) * f_val) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _new_custom)(f_val, NULL, NULL); } struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!f_val) @@ -64,6 +72,10 @@ struct SNAME *CMC_(PFX, _new_custom)(struct CMC_DEF_FVAL(SNAME) * f_val, struct void CMC_(PFX, _clear)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *scan = _set_->root; struct CMC_DEF_NODE(SNAME) *up = NULL; @@ -126,6 +138,10 @@ void CMC_(PFX, _clear)(struct SNAME *_set_) void CMC_(PFX, _free)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_(PFX, _clear)(_set_); _set_->alloc->free(_set_); @@ -133,6 +149,10 @@ void CMC_(PFX, _free)(struct SNAME *_set_) void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *alloc, struct CMC_CALLBACKS_NAME *callbacks) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + CMC_CALLBACKS_MAYBE_UNUSED(callbacks); if (!alloc) @@ -147,6 +167,10 @@ void CMC_(PFX, _customize)(struct SNAME *_set_, struct CMC_ALLOC_NODE_NAME *allo bool CMC_(PFX, _insert)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_set_)) { _set_->root = CMC_(PFX, _impl_new_node)(_set_, value); @@ -219,6 +243,10 @@ bool CMC_(PFX, _insert)(struct SNAME *_set_, V value) bool CMC_(PFX, _remove)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_set_)) { _set_->flag = CMC_FLAG_EMPTY; @@ -352,6 +380,10 @@ bool CMC_(PFX, _remove)(struct SNAME *_set_, V value) bool CMC_(PFX, _max)(struct SNAME *_set_, V *value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_set_)) { _set_->flag = CMC_FLAG_EMPTY; @@ -375,6 +407,10 @@ bool CMC_(PFX, _max)(struct SNAME *_set_, V *value) bool CMC_(PFX, _min)(struct SNAME *_set_, V *value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(_set_)) { _set_->flag = CMC_FLAG_EMPTY; @@ -398,6 +434,10 @@ bool CMC_(PFX, _min)(struct SNAME *_set_, V *value) bool CMC_(PFX, _contains)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + bool result = CMC_(PFX, _impl_get_node)(_set_, value) != NULL; CMC_CALLBACKS_CALL(_set_, read); @@ -407,21 +447,37 @@ bool CMC_(PFX, _contains)(struct SNAME *_set_, V value) bool CMC_(PFX, _empty)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _set_->count == 0; } size_t CMC_(PFX, _count)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _set_->count; } int CMC_(PFX, _flag)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return _set_->flag; } struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_set_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* Callback will be added later */ struct SNAME *result = CMC_(PFX, _new_custom)(_set_->f_val, _set_->alloc, NULL); @@ -483,6 +539,10 @@ struct SNAME *CMC_(PFX, _copy_of)(struct SNAME *_set_) bool CMC_(PFX, _equals)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + _set1_->flag = CMC_FLAG_OK; _set2_->flag = CMC_FLAG_OK; @@ -533,6 +593,10 @@ bool CMC_(PFX, _equals)(struct SNAME *_set1_, struct SNAME *_set2_) static struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _impl_new_node)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *node = _set_->alloc->malloc(sizeof(struct CMC_DEF_NODE(SNAME))); if (!node) @@ -549,6 +613,10 @@ static struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _impl_new_node)(struct SNAME *_set static struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _impl_get_node)(struct SNAME *_set_, V value) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *scan = _set_->root; while (scan != NULL) @@ -566,6 +634,10 @@ static struct CMC_DEF_NODE(SNAME) * CMC_(PFX, _impl_get_node)(struct SNAME *_set static unsigned char CMC_(PFX, _impl_h)(struct CMC_DEF_NODE(SNAME) * node) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (node == NULL) return 0; @@ -574,6 +646,10 @@ static unsigned char CMC_(PFX, _impl_h)(struct CMC_DEF_NODE(SNAME) * node) static unsigned char CMC_(PFX, _impl_hupdate)(struct CMC_DEF_NODE(SNAME) * node) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (node == NULL) return 0; @@ -585,6 +661,10 @@ static unsigned char CMC_(PFX, _impl_hupdate)(struct CMC_DEF_NODE(SNAME) * node) static void CMC_(PFX, _impl_rotate_right)(struct CMC_DEF_NODE(SNAME) * *Z) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *root = *Z; struct CMC_DEF_NODE(SNAME) *new_root = root->left; @@ -614,6 +694,10 @@ static void CMC_(PFX, _impl_rotate_right)(struct CMC_DEF_NODE(SNAME) * *Z) static void CMC_(PFX, _impl_rotate_left)(struct CMC_DEF_NODE(SNAME) * *Z) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *root = *Z; struct CMC_DEF_NODE(SNAME) *new_root = root->right; @@ -643,6 +727,10 @@ static void CMC_(PFX, _impl_rotate_left)(struct CMC_DEF_NODE(SNAME) * *Z) static void CMC_(PFX, _impl_rebalance)(struct SNAME *_set_, struct CMC_DEF_NODE(SNAME) * node) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_NODE(SNAME) *scan = node, *child = NULL; int balance; diff --git a/src/cmc/cmc/treeset/ext/code.h b/src/cmc/cmc/treeset/ext/code.h index 8a33411..151cb3a 100644 --- a/src/cmc/cmc/treeset/ext/code.h +++ b/src/cmc/cmc/treeset/ext/code.h @@ -41,6 +41,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -68,6 +72,10 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_start)(struct SNAME *target) struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct CMC_DEF_ITER(SNAME) iter; iter.target = target; @@ -97,16 +105,28 @@ struct CMC_DEF_ITER(SNAME) CMC_(PFX, _iter_end)(struct SNAME *target) bool CMC_(PFX, _iter_at_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->start; } bool CMC_(PFX, _iter_at_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _empty)(iter->target) || iter->end; } bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->index = 0; @@ -122,6 +142,10 @@ bool CMC_(PFX, _iter_to_start)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (!CMC_(PFX, _empty)(iter->target)) { iter->index = iter->target->count - 1; @@ -137,6 +161,10 @@ bool CMC_(PFX, _iter_to_end)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -177,6 +205,10 @@ bool CMC_(PFX, _iter_next)(struct CMC_DEF_ITER(SNAME) * iter) bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -218,6 +250,10 @@ bool CMC_(PFX, _iter_prev)(struct CMC_DEF_ITER(SNAME) * iter) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->end) return false; @@ -239,6 +275,10 @@ bool CMC_(PFX, _iter_advance)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* Returns true only if the iterator moved */ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (iter->start) return false; @@ -261,6 +301,10 @@ bool CMC_(PFX, _iter_rewind)(struct CMC_DEF_ITER(SNAME) * iter, size_t steps) /* given index */ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (index >= iter->target->count) return false; @@ -274,6 +318,10 @@ bool CMC_(PFX, _iter_go_to)(struct CMC_DEF_ITER(SNAME) * iter, size_t index) V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + if (CMC_(PFX, _empty)(iter->target)) return (V){ 0 }; @@ -282,6 +330,10 @@ V CMC_(PFX, _iter_value)(struct CMC_DEF_ITER(SNAME) * iter) size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return iter->index; } @@ -296,6 +348,10 @@ size_t CMC_(PFX, _iter_index)(struct CMC_DEF_ITER(SNAME) * iter) struct SNAME *CMC_(PFX, _union)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *_set_r_ = CMC_(PFX, _new_custom)(_set1_->f_val, _set1_->alloc, NULL); if (!_set_r_) @@ -321,6 +377,10 @@ struct SNAME *CMC_(PFX, _union)(struct SNAME *_set1_, struct SNAME *_set2_) struct SNAME *CMC_(PFX, _intersection)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *_set_r_ = CMC_(PFX, _new_custom)(_set1_->f_val, _set1_->alloc, NULL); if (!_set_r_) @@ -347,6 +407,10 @@ struct SNAME *CMC_(PFX, _intersection)(struct SNAME *_set1_, struct SNAME *_set2 struct SNAME *CMC_(PFX, _difference)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *_set_r_ = CMC_(PFX, _new_custom)(_set1_->f_val, _set1_->alloc, NULL); if (!_set_r_) @@ -369,6 +433,10 @@ struct SNAME *CMC_(PFX, _difference)(struct SNAME *_set1_, struct SNAME *_set2_) struct SNAME *CMC_(PFX, _symmetric_difference)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *_set_r_ = CMC_(PFX, _new_custom)(_set1_->f_val, _set1_->alloc, NULL); if (!_set_r_) @@ -403,6 +471,10 @@ struct SNAME *CMC_(PFX, _symmetric_difference)(struct SNAME *_set1_, struct SNAM /* If X is a subset of Y, then Y is a superset of X */ bool CMC_(PFX, _is_subset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* If the cardinality of _set1_ is greater than that of _set2_ */ /* then it is safe to say that _set1_ can't be a subset of _set2_ */ if (_set1_->count > _set2_->count) @@ -430,6 +502,10 @@ bool CMC_(PFX, _is_subset)(struct SNAME *_set1_, struct SNAME *_set2_) /* If X is a superset of Y, then Y is a subset of X */ bool CMC_(PFX, _is_superset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _is_subset)(_set2_, _set1_); } @@ -438,6 +514,10 @@ bool CMC_(PFX, _is_superset)(struct SNAME *_set1_, struct SNAME *_set2_) /* If X is a proper subset of Y, then Y is a proper superset of X */ bool CMC_(PFX, _is_proper_subset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* If the cardinality of _set1_ is greater than or equal to that */ /* of _set2_, then it is safe to say that _set1_ can't be a proper */ /* subset of _set2_ */ @@ -473,6 +553,10 @@ bool CMC_(PFX, _is_proper_subset)(struct SNAME *_set1_, struct SNAME *_set2_) /* If X is a proper superset of Y, then Y is a proper subset of X */ bool CMC_(PFX, _is_proper_superset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + return CMC_(PFX, _is_proper_subset)(_set2_, _set1_); } @@ -481,6 +565,10 @@ bool CMC_(PFX, _is_proper_superset)(struct SNAME *_set1_, struct SNAME *_set2_) /* that is, if there are no elements in common between the two */ bool CMC_(PFX, _is_disjointset)(struct SNAME *_set1_, struct SNAME *_set2_) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + /* The intersection of an empty set with any other set will result */ /* in an empty set */ if (CMC_(PFX, _empty)(_set1_)) @@ -510,6 +598,10 @@ bool CMC_(PFX, _is_disjointset)(struct SNAME *_set1_, struct SNAME *_set2_) bool CMC_(PFX, _to_string)(struct SNAME *_set_, FILE *fptr) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + struct SNAME *s_ = _set_; return 0 <= fprintf(fptr, @@ -527,6 +619,10 @@ bool CMC_(PFX, _to_string)(struct SNAME *_set_, FILE *fptr) bool CMC_(PFX, _print)(struct SNAME *_set_, FILE *fptr, const char *start, const char *separator, const char *end) { +#ifdef CMC_DEV + CMC_DEV_FCALL; +#endif + fprintf(fptr, "%s", start); struct CMC_DEF_NODE(SNAME) *root = _set_->root; diff --git a/src/cmc/cor/core.h b/src/cmc/cor/core.h index 5308da5..ef6bc2f 100644 --- a/src/cmc/cor/core.h +++ b/src/cmc/cor/core.h @@ -71,6 +71,7 @@ #include "alloc.h" #include "callbacks.h" +#include "dev.h" #include "flags.h" #include "ftable.h" diff --git a/src/cmc/cor/dev.h b/src/cmc/cor/dev.h new file mode 100644 index 0000000..3e5958d --- /dev/null +++ b/src/cmc/cor/dev.h @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2019 Leonardo Vencovsky + * + * This file is part of the C Macro Collections Libray. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/** + * dev.h + * + * Creation Date: 24/05/2020 + * + * Authors: + * Leonardo Vencovsky (https://github.com/LeoVen) + * + */ + +#ifndef CMC_COR_DEV_H +#define CMC_COR_DEV_H + +/** + * Macros for tracing and debugging data structures when CMC_DEV is enabled + */ + +#define CMC_DEV_FCALL cmc_log_trace("fcall") + +#endif /* CMC_COR_DEV_H */ diff --git a/src/cmc/cor/undef.h b/src/cmc/cor/undef.h index ebe8447..4478856 100644 --- a/src/cmc/cor/undef.h +++ b/src/cmc/cor/undef.h @@ -42,6 +42,9 @@ #ifndef CMC_ARGS_FALLTHROUGH +#undef CMC_DEV +#undef CMC_SAC + #ifndef CMC_ARGS_KEY_FALLTHROUGH #undef K #endif diff --git a/src/cmc/deque.h b/src/cmc/deque.h index 82a4911..ef48a19 100644 --- a/src/cmc/deque.h +++ b/src/cmc/deque.h @@ -54,6 +54,10 @@ #include "cor/core.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * V - deque data type diff --git a/src/cmc/hashbidimap.h b/src/cmc/hashbidimap.h index 9a9a57b..c1e6359 100644 --- a/src/cmc/hashbidimap.h +++ b/src/cmc/hashbidimap.h @@ -50,6 +50,10 @@ #include "cor/core.h" #include "cor/hashtable.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * K - hashbidimap key data type diff --git a/src/cmc/hashmap.h b/src/cmc/hashmap.h index 9ef082e..46b3be7 100644 --- a/src/cmc/hashmap.h +++ b/src/cmc/hashmap.h @@ -43,6 +43,10 @@ #include "cor/core.h" #include "cor/hashtable.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * K - hashmap key data type diff --git a/src/cmc/hashmultimap.h b/src/cmc/hashmultimap.h index 2b63c08..9578219 100644 --- a/src/cmc/hashmultimap.h +++ b/src/cmc/hashmultimap.h @@ -68,6 +68,10 @@ #include "cor/core.h" #include "cor/hashtable.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * K - hashmultimap key data type diff --git a/src/cmc/hashmultiset.h b/src/cmc/hashmultiset.h index d5e1018..ab70052 100644 --- a/src/cmc/hashmultiset.h +++ b/src/cmc/hashmultiset.h @@ -50,6 +50,10 @@ #include "cor/core.h" #include "cor/hashtable.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * V - hashmultiset value data type diff --git a/src/cmc/hashset.h b/src/cmc/hashset.h index 25b7617..69d844b 100644 --- a/src/cmc/hashset.h +++ b/src/cmc/hashset.h @@ -43,6 +43,10 @@ #include "cor/core.h" #include "cor/hashtable.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * V - hashset value data type diff --git a/src/cmc/heap.h b/src/cmc/heap.h index b82886f..e860152 100644 --- a/src/cmc/heap.h +++ b/src/cmc/heap.h @@ -54,6 +54,10 @@ #include "cor/core.h" #include "cor/heap.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * V - heap value data type diff --git a/src/cmc/intervalheap.h b/src/cmc/intervalheap.h index 72adb71..d4731f1 100644 --- a/src/cmc/intervalheap.h +++ b/src/cmc/intervalheap.h @@ -46,6 +46,10 @@ #include "cor/core.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * V - intervalheap value data type diff --git a/src/cmc/linkedlist.h b/src/cmc/linkedlist.h index 9e401c6..61e26de 100644 --- a/src/cmc/linkedlist.h +++ b/src/cmc/linkedlist.h @@ -51,6 +51,10 @@ #include "cor/core.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * V - linkedlist data type diff --git a/src/cmc/list.h b/src/cmc/list.h index ebb1b4e..ed513b7 100644 --- a/src/cmc/list.h +++ b/src/cmc/list.h @@ -66,6 +66,10 @@ #include "cor/core.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * V - list data type diff --git a/src/cmc/queue.h b/src/cmc/queue.h index c16c3da..3c3af1e 100644 --- a/src/cmc/queue.h +++ b/src/cmc/queue.h @@ -66,6 +66,10 @@ #include "cor/core.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * V - queue data type diff --git a/src/cmc/sortedlist.h b/src/cmc/sortedlist.h index 386578a..154d883 100644 --- a/src/cmc/sortedlist.h +++ b/src/cmc/sortedlist.h @@ -45,6 +45,10 @@ #include "cor/core.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * V - sortedlist data type diff --git a/src/cmc/stack.h b/src/cmc/stack.h index f6ae4e0..df04f5c 100644 --- a/src/cmc/stack.h +++ b/src/cmc/stack.h @@ -51,6 +51,10 @@ #include "cor/core.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * V - stack data type diff --git a/src/cmc/treemap.h b/src/cmc/treemap.h index 35a7a64..c6d449d 100644 --- a/src/cmc/treemap.h +++ b/src/cmc/treemap.h @@ -42,6 +42,10 @@ #include "cor/core.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * K - treemap key data type diff --git a/src/cmc/treeset.h b/src/cmc/treeset.h index 2862bc7..1022075 100644 --- a/src/cmc/treeset.h +++ b/src/cmc/treeset.h @@ -42,6 +42,10 @@ #include "cor/core.h" +#ifdef CMC_DEV +#include "utl/log.h" +#endif + /** * Used values * V - treeset value data type