Skip to content

Commit

Permalink
Fixing some things, tests resumed
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoVen committed Jun 9, 2020
1 parent aec7efd commit 2b8f778
Show file tree
Hide file tree
Showing 26 changed files with 2,689 additions and 1,990 deletions.
4 changes: 2 additions & 2 deletions autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@

file.write(
f'''
#include {data['h']}
#include "macro_collections.h"
{UNIQUE_FLAG}
CMC_{data['LIB']}_{data['COLLECTION']}_CORE(({', '.join([data['PFX'], data['SNAME'], data['SIZE'], data['K'], data['V']])}))
C_MACRO_COLLECTIONS_ALL({data['LIB']}, {data['COLLECTION']}, ({', '.join([data['PFX'], data['SNAME'], data['SIZE'], data['K'], data['V']])}))
{UNIQUE_FLAG}
''')
Expand Down
10 changes: 5 additions & 5 deletions src/cmc/hashmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@
{ \
if (_map_->f_key->cmp(_map_->buffer[i].key, max_key) > 0) \
{ \
max_key = _map_->buffer[first].key; \
max_val = _map_->buffer[first].value; \
max_key = _map_->buffer[i].key; \
max_val = _map_->buffer[i].value; \
} \
} \
} \
Expand Down Expand Up @@ -495,10 +495,10 @@
{ \
if (_map_->buffer[i].state == CMC_ES_FILLED) \
{ \
if (_map_->f_key->cmp(_map_->buffer[i].key, min_key) > 0) \
if (_map_->f_key->cmp(_map_->buffer[i].key, min_key) < 0) \
{ \
min_key = _map_->buffer[first].key; \
min_val = _map_->buffer[first].value; \
min_key = _map_->buffer[i].key; \
min_val = _map_->buffer[i].value; \
} \
} \
} \
Expand Down
11 changes: 10 additions & 1 deletion src/ext/cmc/bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
/**
* All the EXT parts of CMC BitSet.
*/
#define CMC_EXT_CMC_BITSET_PARTS
#define CMC_EXT_CMC_BITSET_PARTS PLACEHOLDER

#define CMC_EXT_CMC_BITSET_PLACEHOLDER(PARAMS)

#define CMC_EXT_CMC_BITSET_PLACEHOLDER_HEADER(PARAMS)

#define CMC_EXT_CMC_BITSET_PLACEHOLDER_SOURCE(PARAMS)

#define CMC_EXT_CMC_BITSET_PLACEHOLDER_HEADER_(PFX, SNAME, V)
#define CMC_EXT_CMC_BITSET_PLACEHOLDER_SOURCE_(PFX, SNAME, V)

#endif /* CMC_EXT_CMC_BITSET_H */
15 changes: 0 additions & 15 deletions src/utl/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,6 @@ CMC_UNUSED static void cmc_test_log(const char *unit_name, const char *current_t
BODY; \
\
cmc_timer_stop(timer); \
\
unittest_abort: \
if (tinfo.aborted) \
{ \
cmc_test_log(unit_name, current_test, true, false); \
} \
\
tinfo.assert_total = cmc_assert_total - tinfo.assert_total; \
tinfo.assert_failed = cmc_assert_failed - tinfo.assert_failed; \
Expand Down Expand Up @@ -225,13 +219,4 @@ CMC_UNUSED static void cmc_test_log(const char *unit_name, const char *current_t
\
} while (0)

#define CMC_TEST_ABORT() \
do \
{ \
tinfo.aborted = true; \
tinfo.total -= 1; \
goto unittest_abort; \
\
} while (0)

#endif /* CMC_UTL_TEST_H */
2 changes: 1 addition & 1 deletion tests/main/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CC = gcc
CFLAGS = -std=c11 -Wall -Wextra
CFLAGS += -Wno-unused -Wno-missing-braces
CFLAGS += -Wno-missing-braces
DBFLAGS = -g3
CVFLAGS = --coverage -O0
INCLUDE = ../../src/
Expand Down
63 changes: 38 additions & 25 deletions tests/main/src/bitset.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct bitset
struct bitset_iter
{
struct bitset *target;
cmc_bitset_word cursor;
size_t cursor;
_Bool start;
_Bool end;
};
Expand Down Expand Up @@ -70,15 +70,17 @@ struct bitset *bs_new_custom(size_t n_bits, struct cmc_alloc_node *alloc, struct
_bitset_->capacity = capacity;
_bitset_->flag = CMC_FLAG_OK;
_bitset_->alloc = alloc;
_bitset_->callbacks = callbacks;
(_bitset_)->callbacks = callbacks;
return _bitset_;
}
struct bitset bs_init(size_t n_bits)
{
return bs_init_custom(n_bits, ((void *)0), ((void *)0));
}
struct bitset bs_init_custom(size_t n_bits, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks)
struct bitset bs_init_custom(size_t n_bits, struct cmc_alloc_node *alloc,
struct cmc_callbacks *__attribute__((__unused__)) (callbacks))
{
;
struct bitset _bitset_ = { 0 };
if (n_bits < 1)
return _bitset_;
Expand All @@ -91,7 +93,7 @@ struct bitset bs_init_custom(size_t n_bits, struct cmc_alloc_node *alloc, struct
_bitset_.capacity = capacity;
_bitset_.flag = CMC_FLAG_OK;
_bitset_.alloc = alloc;
_bitset_.callbacks = callbacks;
(&_bitset_)->callbacks = callbacks;
return _bitset_;
}
void bs_free(struct bitset *_bitset_)
Expand All @@ -105,11 +107,12 @@ void bs_release(struct bitset _bitset_)
}
void bs_customize(struct bitset *_bitset_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks)
{
;
if (!alloc)
_bitset_->alloc = &cmc_alloc_node_default;
else
_bitset_->alloc = alloc;
_bitset_->callbacks = callbacks;
(_bitset_)->callbacks = callbacks;
_bitset_->flag = CMC_FLAG_OK;
}
_Bool bs_set(struct bitset *_bitset_, size_t bit_index)
Expand All @@ -120,8 +123,9 @@ _Bool bs_set(struct bitset *_bitset_, size_t bit_index)
size_t i = bs_bit_to_index(bit_index);
_bitset_->buffer[i] |= ((cmc_bitset_word)1) << (bit_index % bits);
_bitset_->flag = CMC_FLAG_OK;
if (_bitset_->callbacks && _bitset_->callbacks->create)
_bitset_->callbacks->create();
if ((_bitset_)->callbacks && (_bitset_)->callbacks->create)
(_bitset_)->callbacks->create();
;
return 1;
}
_Bool bs_set_range(struct bitset *_bitset_, size_t from, size_t to)
Expand Down Expand Up @@ -153,8 +157,9 @@ _Bool bs_set_range(struct bitset *_bitset_, size_t from, size_t to)
_bitset_->buffer[end_index] |= end_mask;
}
_bitset_->flag = CMC_FLAG_OK;
if (_bitset_->callbacks && _bitset_->callbacks->create)
_bitset_->callbacks->create();
if ((_bitset_)->callbacks && (_bitset_)->callbacks->create)
(_bitset_)->callbacks->create();
;
return 1;
}
_Bool bs_clear(struct bitset *_bitset_, size_t bit_index)
Expand All @@ -165,8 +170,9 @@ _Bool bs_clear(struct bitset *_bitset_, size_t bit_index)
size_t i = bs_bit_to_index(bit_index);
_bitset_->buffer[i] &= ~(((cmc_bitset_word)1) << (bit_index % bits));
_bitset_->flag = CMC_FLAG_OK;
if (_bitset_->callbacks && _bitset_->callbacks->delete)
_bitset_->callbacks->delete ();
if ((_bitset_)->callbacks && (_bitset_)->callbacks->delete)
(_bitset_)->callbacks->delete ();
;
return 1;
}
_Bool bs_clear_range(struct bitset *_bitset_, size_t from, size_t to)
Expand Down Expand Up @@ -198,8 +204,9 @@ _Bool bs_clear_range(struct bitset *_bitset_, size_t from, size_t to)
_bitset_->buffer[end_index] &= ~end_mask;
}
_bitset_->flag = CMC_FLAG_OK;
if (_bitset_->callbacks && _bitset_->callbacks->delete)
_bitset_->callbacks->delete ();
if ((_bitset_)->callbacks && (_bitset_)->callbacks->delete)
(_bitset_)->callbacks->delete ();
;
return 1;
}
_Bool bs_flip(struct bitset *_bitset_, size_t bit_index)
Expand All @@ -210,8 +217,9 @@ _Bool bs_flip(struct bitset *_bitset_, size_t bit_index)
size_t i = bs_bit_to_index(bit_index);
_bitset_->buffer[i] ^= ((cmc_bitset_word)1) << (bit_index % bits);
_bitset_->flag = CMC_FLAG_OK;
if (_bitset_->callbacks && _bitset_->callbacks->update)
_bitset_->callbacks->update();
if ((_bitset_)->callbacks && (_bitset_)->callbacks->update)
(_bitset_)->callbacks->update();
;
return 1;
}
_Bool bs_flip_range(struct bitset *_bitset_, size_t from, size_t to)
Expand Down Expand Up @@ -243,8 +251,9 @@ _Bool bs_flip_range(struct bitset *_bitset_, size_t from, size_t to)
_bitset_->buffer[end_index] ^= end_mask;
}
_bitset_->flag = CMC_FLAG_OK;
if (_bitset_->callbacks && _bitset_->callbacks->update)
_bitset_->callbacks->update();
if ((_bitset_)->callbacks && (_bitset_)->callbacks->update)
(_bitset_)->callbacks->update();
;
return 1;
}
_Bool bs_put(struct bitset *_bitset_, size_t bit_index, _Bool state)
Expand All @@ -266,26 +275,29 @@ _Bool bs_set_all(struct bitset *_bitset_)
for (size_t i = 0; i < _bitset_->capacity; i++)
_bitset_->buffer[i] = ~((cmc_bitset_word)0);
_bitset_->flag = CMC_FLAG_OK;
if (_bitset_->callbacks && _bitset_->callbacks->create)
_bitset_->callbacks->create();
if ((_bitset_)->callbacks && (_bitset_)->callbacks->create)
(_bitset_)->callbacks->create();
;
return 1;
}
_Bool bs_clear_all(struct bitset *_bitset_)
{
for (size_t i = 0; i < _bitset_->capacity; i++)
_bitset_->buffer[i] = 0;
_bitset_->flag = CMC_FLAG_OK;
if (_bitset_->callbacks && _bitset_->callbacks->delete)
_bitset_->callbacks->delete ();
if ((_bitset_)->callbacks && (_bitset_)->callbacks->delete)
(_bitset_)->callbacks->delete ();
;
return 1;
}
_Bool bs_flip_all(struct bitset *_bitset_)
{
for (size_t i = 0; i < _bitset_->capacity; i++)
_bitset_->buffer[i] ^= ~((cmc_bitset_word)0);
_bitset_->flag = CMC_FLAG_OK;
if (_bitset_->callbacks && _bitset_->callbacks->create)
_bitset_->callbacks->create();
if ((_bitset_)->callbacks && (_bitset_)->callbacks->create)
(_bitset_)->callbacks->create();
;
return 1;
}
_Bool bs_get(struct bitset *_bitset_, size_t bit_index)
Expand Down Expand Up @@ -318,8 +330,9 @@ _Bool bs_impl_resize(struct bitset *_bitset_, size_t n_bits, _Bool do_resize)
if (_bitset_->capacity < words)
memset(_bitset_->buffer + _bitset_->capacity, 0, (words - _bitset_->capacity) * sizeof(cmc_bitset_word));
_bitset_->capacity = words;
if (_bitset_->callbacks && _bitset_->callbacks->resize)
_bitset_->callbacks->resize();
if ((_bitset_)->callbacks && (_bitset_)->callbacks->resize)
(_bitset_)->callbacks->resize();
;
_bitset_->flag = CMC_FLAG_OK;
return 1;
}
Expand Down
Loading

0 comments on commit 2b8f778

Please sign in to comment.