diff --git a/m-array.h b/m-array.h index c8c5b28c..2163203d 100644 --- a/m-array.h +++ b/m-array.h @@ -80,6 +80,7 @@ /* OPLIST definition of a dynamic array */ /* FIXME: Do we want to export some methods as they are slow and are not fit to be used for building other methods (like _it_remove)? */ +//TODO: ARRAY_POOL_OPLIST #define M_ARRA4_OPLIST_P3(name, oplist) \ (INIT(M_F(name, _init)) \ ,M_IF_METHOD2(INIT_SET,SET, oplist)(INIT_SET(M_F(name, _init_set)),) \ diff --git a/m-buffer.h b/m-buffer.h index 16c23780..66a6563e 100644 --- a/m-buffer.h +++ b/m-buffer.h @@ -258,7 +258,7 @@ m_buff3r_number_dec(m_buff3r_number_ct n, unsigned int policy) M_BUFF3R_DEF_TYPE(name, type, m_size, policy, oplist, buffer_t) \ M_CHECK_COMPATIBLE_OPLIST(name, 1, type, oplist) \ M_BUFF3R_DEF_CORE(name, type, m_size, policy, oplist, buffer_t) \ - M_EMPLACE_QUEUE_DEF(name, buffer_t, M_F(name, _emplace), oplist, M_EMPLACE_QUEUE_GENE) + M_EMPLACE_QUEUE_DEF(name, buffer_t, _emplace, oplist, M_EMPLACE_QUEUE_GENE) /* Define the type of a buffer */ #define M_BUFF3R_DEF_TYPE(name, type, m_size, policy, oplist, buffer_t) \ @@ -798,7 +798,7 @@ M_F(name, _init)(buffer_t v, size_t size) \ M_QU3UE_MPMC_DEF_TYPE(name, type, policy, oplist, buffer_t) \ M_CHECK_COMPATIBLE_OPLIST(name, 1, type, oplist) \ M_QU3UE_MPMC_DEF_CORE(name, type, policy, oplist, buffer_t) \ - M_EMPLACE_QUEUE_DEF(name, buffer_t, M_F(name, _emplace), oplist, M_EMPLACE_QUEUE_GENE) + M_EMPLACE_QUEUE_DEF(name, buffer_t, _emplace, oplist, M_EMPLACE_QUEUE_GENE) /* Define the type of a MPMC queue */ #define M_QU3UE_MPMC_DEF_TYPE(name, type, policy, oplist, buffer_t) \ @@ -1033,7 +1033,7 @@ M_F(name, _init)(buffer_t v, size_t size) \ M_QU3UE_SPSC_DEF_TYPE(name, type, policy, oplist, buffer_t) \ M_CHECK_COMPATIBLE_OPLIST(name, 1, type, oplist) \ M_QU3UE_SPSC_DEF_CORE(name, type, policy, oplist, buffer_t) \ - M_EMPLACE_QUEUE_DEF(name, buffer_t, M_F(name, _emplace), oplist, M_EMPLACE_QUEUE_GENE) + M_EMPLACE_QUEUE_DEF(name, buffer_t, _emplace, oplist, M_EMPLACE_QUEUE_GENE) /* Define the type of a SPSC queue */ #define M_QU3UE_SPSC_DEF_TYPE(name, type, policy, oplist, buffer_t) \ diff --git a/m-concurrent.h b/m-concurrent.h index 7e2f715c..af0b2704 100644 --- a/m-concurrent.h +++ b/m-concurrent.h @@ -522,7 +522,7 @@ M_F(name, _write_unlock)(out); \ } \ \ - M_EMPLACE_QUEUE_DEF(name, concurrent_t, M_F(name, _emplace), M_GET_OPLIST oplist, M_EMPLACE_QUEUE_GENE) \ + M_EMPLACE_QUEUE_DEF(name, concurrent_t, _emplace, M_GET_OPLIST oplist, M_EMPLACE_QUEUE_GENE) \ ,) \ \ M_IF_METHOD(POP, oplist)( \ diff --git a/m-core.h b/m-core.h index 547b5e4f..de836a1b 100644 --- a/m-core.h +++ b/m-core.h @@ -5081,10 +5081,10 @@ m_core_parse2_enum (const char str[], const char **endptr) M_ID( M_C(M_EMPLACE_ASS_ARRAY_OR_QUEUE_DEF, isSet)(name, name_t, key_oplist, val_oplist) ) #define M_EMPLACE_ASS_ARRAY_OR_QUEUE_DEF0(name, name_t, key_oplist, val_oplist) \ M_EMPLACE_ASS_ARRAY_DEF(name, name_t, M_F(name, _emplace), key_oplist, val_oplist, M_EMPLACE_ASS_ARRA1_BOTH_GENE, M_EMPLACE_ASS_ARRA1_KEY_GENE, M_EMPLACE_ASS_ARRA1_VAL_GENE) \ - M_EMPLACE_QUEUE_DEF(name, name_t, M_F(name, _get_emplace), key_oplist, M_EMPLACE_GET_GENE) + M_EMPLACE_QUEUE_DEF(name, name_t, _get_emplace, key_oplist, M_EMPLACE_GET_GENE) #define M_EMPLACE_ASS_ARRAY_OR_QUEUE_DEF1(name, name_t, key_oplist, val_oplist) \ - M_EMPLACE_QUEUE_DEF(name, name_t, M_F(name, _emplace), key_oplist, M_EMPLACE_QUEUE_GENE) \ - M_EMPLACE_QUEUE_DEF(name, name_t, M_F(name, _get_emplace), key_oplist, M_EMPLACE_GET_GENE) + M_EMPLACE_QUEUE_DEF(name, name_t, _emplace, key_oplist, M_EMPLACE_QUEUE_GENE) \ + M_EMPLACE_QUEUE_DEF(name, name_t, _get_emplace, key_oplist, M_EMPLACE_GET_GENE) /* Definition of the emplace_back function for associative arrays. @@ -5138,13 +5138,13 @@ m_core_parse2_enum (const char str[], const char **endptr) This definition is far from being efficient but works for the current interface. */ #define M_EMPLACE_QUEUE_GENE(name, name_t, function_name, oplist, init_func, exp_emplace_type) \ - M_INLINE void \ - function_name(name_t v \ + M_P(void, name, function_name, name_t v \ M_EMPLACE_LIST_TYPE_VAR(a, exp_emplace_type) ) \ { \ M_GET_TYPE oplist data; \ M_EMPLACE_CALL_FUNC(a, init_func, oplist, data, exp_emplace_type); \ - M_F(name, _push)(v, data); \ + /* FIXME: Why name##_push and not M_CALL_PUSH? */ \ + M_F(name, _push) M_R(v, data); \ M_CALL_CLEAR(oplist, data); \ } @@ -5155,7 +5155,7 @@ m_core_parse2_enum (const char str[], const char **endptr) */ #define M_EMPLACE_GET_GENE(name, name_t, function_name, oplist, init_func, exp_emplace_type) \ M_INLINE M_F(name, _value_ct) * \ - function_name(name_t const v \ + M_F(name, function_name)(name_t const v \ M_EMPLACE_LIST_TYPE_VAR(a, exp_emplace_type) ) \ { \ M_GET_TYPE oplist data; \ diff --git a/m-prioqueue.h b/m-prioqueue.h index 8c8fa829..6366e185 100644 --- a/m-prioqueue.h +++ b/m-prioqueue.h @@ -25,7 +25,6 @@ #ifndef MSTARLIB_PRIOQUEUE_H #define MSTARLIB_PRIOQUEUE_H -#include "m-core.h" #include "m-array.h" /* Priority queue are built upon array */ /* Priority queue based on binary heap implementation */ @@ -137,7 +136,7 @@ M_PR1OQUEUE_DEF_CORE(name, type, oplist, prioqueue_t, it_t) \ M_PR1OQUEUE_DEF_IT(name, type, oplist, prioqueue_t, it_t) \ M_PR1OQUEUE_DEF_IO(name, type, oplist, prioqueue_t, it_t) \ - M_EMPLACE_QUEUE_DEF(name, prioqueue_t, M_F(name, _emplace), oplist, M_EMPLACE_QUEUE_GENE) + M_EMPLACE_QUEUE_DEF(name, prioqueue_t, _emplace, oplist, M_EMPLACE_QUEUE_GENE) /* Define the types */ #define M_PR1OQUEUE_DEF_TYPE(name, type, oplist, prioqueue_t, it_t) \ @@ -167,22 +166,19 @@ M_F(name, _array_init)(p->array); \ } \ \ - M_INLINE void \ - M_F(name, _init_set)(prioqueue_t p, prioqueue_t const o) \ + M_P(void, name, _init_set, prioqueue_t p, prioqueue_t const o) \ { \ - M_F(name, _array_init_set)(p->array, o->array); \ + M_F(name, _array_init_set) M_R(p->array, o->array); \ } \ \ - M_INLINE void \ - M_F(name, _set)(prioqueue_t p, prioqueue_t const o) \ + M_P(void, name, _set, prioqueue_t p, prioqueue_t const o) \ { \ - M_F(name, _array_set)(p->array, o->array); \ + M_F(name, _array_set) M_R(p->array, o->array); \ } \ \ - M_INLINE void \ - M_F(name, _clear)(prioqueue_t p) \ + M_P(void, name, _clear, prioqueue_t p) \ { \ - M_F(name, _array_clear)(p->array); \ + M_F(name, _array_clear) M_R(p->array); \ } \ \ M_INLINE void \ @@ -191,10 +187,9 @@ M_F(name, _array_init_move)(p->array, o->array); \ } \ \ - M_INLINE void \ - M_F(name, _move)(prioqueue_t p, prioqueue_t o) \ + M_P(void, name, _move, prioqueue_t p, prioqueue_t o) \ { \ - M_F(name, _array_move)(p->array, o->array); \ + M_F(name, _array_move) M_R(p->array, o->array); \ } \ \ M_INLINE void \ @@ -203,10 +198,9 @@ M_F(name, _array_swap)(p->array, o->array); \ } \ \ - M_INLINE void \ - M_F(name, _reset)(prioqueue_t p) \ + M_P(void, name, _reset, prioqueue_t p) \ { \ - M_F(name, _array_reset)(p->array); \ + M_F(name, _array_reset)M_R(p->array); \ } \ \ M_INLINE size_t \ @@ -249,11 +243,10 @@ return M_F(name, _array_size)(p->array); \ } \ \ - M_INLINE void \ - M_F(name, _push)(prioqueue_t p, type const x) \ + M_P(void, name, _push, prioqueue_t p, type const x) \ { \ /* Push back the new element at the end of the array */ \ - M_F(name, _array_push_back)(p->array, x); \ + M_F(name, _array_push_back) M_R(p->array, x); \ \ /* Reorder the array by swapping with its parent \ * until it reaches the right position */ \ @@ -273,14 +266,13 @@ return M_F(name, _array_cget)(p->array, 0); \ } \ \ - M_INLINE void \ - M_F(name, _pop)(type *x, prioqueue_t p) \ + M_P(void, name, _pop, type *x, prioqueue_t p) \ { \ /* Swap the front element with the last element */ \ size_t size = M_F(name, _array_size)(p->array)-1; \ M_F(name, _array_swap_at) (p->array, 0, size); \ /* Swap the new last element */ \ - M_F(name, _array_pop_back)(x, p->array); \ + M_F(name, _array_pop_back) M_R(x, p->array); \ \ /* Reorder the heap */ \ size_t i = 0; \ @@ -323,8 +315,7 @@ return i; \ } \ \ - M_INLINE bool \ - M_F(name, _erase)(prioqueue_t p, type const x) \ + M_P(bool, name, _erase, prioqueue_t p, type const x) \ { \ /* First pass: search for an item EQUAL to x */ \ size_t size = M_F(name, _array_size)(p->array); \ @@ -335,7 +326,7 @@ /* Swap the found item and the last element */ \ size--; \ M_F(name, _array_swap_at) (p->array, i, size); \ - M_F(name, _array_pop_back)(NULL, p->array); \ + M_F(name, _array_pop_back) M_R(NULL, p->array); \ /* Move back the last swapped element to its right position in the heap */ \ while (true) { \ size_t child = M_F(name, _i_lchild)(i); \ @@ -352,8 +343,7 @@ return true; \ } \ \ - M_INLINE void \ - M_F(name, _update)(prioqueue_t p, type const xold, type const xnew) \ + M_P(void, name, _update, prioqueue_t p, type const xold, type const xnew) \ { \ /* NOTE: xold can be the same pointer than xnew */ \ /* First pass: search for an item EQUAL to x */ \ @@ -364,7 +354,7 @@ /* Test if the position of the old data is further or nearer than the new */ \ int cmp = M_CALL_CMP(oplist, *M_F(name, _array_cget)(p->array, i), xnew); \ /* Set the found item to the new element */ \ - M_F(name, _array_set_at) (p->array, i, xnew); \ + M_F(name, _array_set_at) M_R(p->array, i, xnew); \ if (cmp < 0) { \ /* Move back the updated element to its new position, further in the heap */ \ while (true) { \ @@ -467,26 +457,23 @@ ,/* No OUT_STR */) \ \ M_IF_METHOD(IN_STR, oplist)( \ - M_INLINE bool \ - M_F(name, _in_str)(prioqueue_t p, FILE *file) \ + M_P(bool, name, _in_str, prioqueue_t p, FILE *file) \ { \ - return M_F(name, _array_in_str)(p->array, file); \ + return M_F(name, _array_in_str)M_R(p->array, file); \ } \ ,/* No IN_STR */) \ \ M_IF_METHOD(GET_STR, oplist)( \ - M_INLINE void \ - M_F(name, _get_str)(m_string_t str, const prioqueue_t p, bool append) \ + M_P(void, name, _get_str, m_string_t str, const prioqueue_t p, bool append) \ { \ - M_F(name, _array_get_str)(str, p->array, append); \ + M_F(name, _array_get_str)M_R(str, p->array, append); \ } \ ,/* No GET_STR */) \ \ M_IF_METHOD(PARSE_STR, oplist)( \ - M_INLINE bool \ - M_F(name, _parse_str)(prioqueue_t p, const char str[], const char **endp) \ + M_P(bool, name, _parse_str, prioqueue_t p, const char str[], const char **endp) \ { \ - return M_F(name, _array_parse_str)(p->array, str, endp); \ + return M_F(name, _array_parse_str)M_R(p->array, str, endp); \ } \ ,/* No PARSE_STR */) \ \ @@ -499,10 +486,9 @@ ,/* No OUT_SERIAL */) \ \ M_IF_METHOD2(IN_SERIAL, INIT, oplist)( \ - M_INLINE m_serial_return_code_t \ - M_F(name, _in_serial)(prioqueue_t p, m_serial_read_t f) \ + M_P(m_serial_return_code_t, name, _in_serial, prioqueue_t p, m_serial_read_t f) \ { \ - return M_F(name, _array_in_serial)(p->array, f); \ + return M_F(name, _array_in_serial)M_R(p->array, f); \ } \ ,/* No in_SERIAL */) \ diff --git a/m-rbtree.h b/m-rbtree.h index d07e6173..75614df5 100644 --- a/m-rbtree.h +++ b/m-rbtree.h @@ -180,7 +180,7 @@ typedef enum { M_CHECK_COMPATIBLE_OPLIST(name, 1, type, oplist) \ M_RBTR33_DEF_CORE(name, type, oplist, tree_t, node_t, it_t) \ M_RBTR33_DEF_IO(name, type, oplist, tree_t, node_t, it_t) \ - M_EMPLACE_QUEUE_DEF(name, tree_t, M_F(name, _emplace), oplist, M_EMPLACE_QUEUE_GENE) + M_EMPLACE_QUEUE_DEF(name, tree_t, _emplace, oplist, M_EMPLACE_QUEUE_GENE) /* Define the types associated to a R/B Tree */ #define M_RBTR33_DEF_TYPE(name, type, oplist, tree_t, node_t, it_t) \