Rename parameter pool to context

This commit is contained in:
Patrick Pelissier committed 2025-05-07 21:02:24 +02:00
1 parent 692c0487af
commit 93a1be616d
24 files changed
+206 -200

No files matched your search

+1 -1
View File
@@ -9178,7 +9178,7 @@ _________________
### M-MEMPOOL ### M-MEMPOOL
> [!NOTE] > [!NOTE]
> This header is obsolete: `M_USE_POOL` should be used instead to pass custom memory context to containers. > This header is obsolete: `M_USE_CONTEXT` should be used instead to pass custom memory context to containers.
This header is for generating specialized and optimized memory pools: This header is for generating specialized and optimized memory pools:
it will generate specialized functions to allocate and free only one kind of an object. it will generate specialized functions to allocate and free only one kind of an object.
+1 -1
View File
@@ -98,7 +98,7 @@ V0.8.0 : * The prototypes of REALLOC / FREE operators are incompatible:
* m-buffer: Remove buffer blocking policy BUFFER_BLOCKING (default policy is now forced) and thread safe (_push / _pop returns now void) * m-buffer: Remove buffer blocking policy BUFFER_BLOCKING (default policy is now forced) and thread safe (_push / _pop returns now void)
* m-buffer push / pop no longer return a bool (it was undocumented) * m-buffer push / pop no longer return a bool (it was undocumented)
* Remove MEMPOOL support from list & R/B tree * Remove MEMPOOL support from list & R/B tree
* m-mempool: Header is obsolete (and no longer useful at all as lists & RB Tree no longer can use it. To remove?). Use new M_USE_POOL interface to pass local pool context. * m-mempool: Header is obsolete (and no longer useful at all as lists & RB Tree no longer can use it. To remove?). Use new M_USE_CONTEXT interface to pass local pool context.
* M*LIB becomes stricter for INIT_MOVE: Emulation layer using CLEAR+INIT_SET when missing INIT_MOVE operator has been removed: either default INIT_MOVE operator (operator '=') is working, or a method is provided for INIT_MOVE or it is disabled. * M*LIB becomes stricter for INIT_MOVE: Emulation layer using CLEAR+INIT_SET when missing INIT_MOVE operator has been removed: either default INIT_MOVE operator (operator '=') is working, or a method is provided for INIT_MOVE or it is disabled.
If it is an array of size 1, you can use M_COPY_A1_DEFAULT as a default method. If it is an array of size 1, you can use M_COPY_A1_DEFAULT as a default method.
(It's because supporting emulation layer with new memory context parameter was complicated) (It's because supporting emulation layer with new memory context parameter was complicated)
+12 -5
View File
@@ -1,7 +1,9 @@
#include <stdlib.h> #include <stdlib.h>
// Define the memory context.
typedef int *context_t; typedef int *context_t;
// Define the realloc / free that accepts the memory context.
static void *my_realloc(void *ptr, size_t old, size_t new, size_t base, context_t context) static void *my_realloc(void *ptr, size_t old, size_t new, size_t base, context_t context)
{ {
(void) context; (void) context;
@@ -17,13 +19,18 @@ static void my_free(void *ptr, size_t old, size_t base, context_t context)
free(ptr); free(ptr);
} }
# define M_USE_POOL context_t // Request M*LIB to generate functions accepting a memory context parameter that will be passed to the memory functions
# define M_MEMORY_REALLOC(type, ptr, o, n) my_realloc(ptr, o, n, sizeof (type), m_pool) # define M_USE_CONTEXT context_t
# define M_MEMORY_FREE(type, ptr, o) my_free(ptr, o, sizeof (*ptr), m_pool)
# define M_MEMORY_ALLOC(type) my_realloc(NULL, 0, 1, sizeof (type), m_pool) // Overloaded memory functions to use the custom ones.
# define M_MEMORY_DEL(ptr) my_free(ptr, 1, sizeof (*ptr), m_pool) // m_context is the name of the memory context parameter
# define M_MEMORY_REALLOC(type, ptr, o, n) my_realloc(ptr, o, n, sizeof (type), m_context)
# define M_MEMORY_FREE(type, ptr, o) my_free(ptr, o, sizeof (*ptr), m_context)
# define M_MEMORY_ALLOC(type) my_realloc(NULL, 0, 1, sizeof (type), m_context)
# define M_MEMORY_DEL(ptr) my_free(ptr, 1, sizeof (*ptr), m_context)
// Now we can include M*LIB functions.
#include "m-string.h" #include "m-string.h"
#include "m-bitset.h" #include "m-bitset.h"
#include "m-bstring.h" #include "m-bstring.h"
+6 -6
View File
@@ -80,7 +80,7 @@
/* OPLIST definition of a dynamic array */ /* OPLIST definition of a dynamic array */
/* FIXME: Do we want to export some methods as they are slow and /* 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)? */ are not fit to be used for building other methods (like _it_remove)? */
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
#define M_ARRA4_OPLIST_P3(name, oplist) \ #define M_ARRA4_OPLIST_P3(name, oplist) \
(INIT(M_F(name, _init)) \ (INIT(M_F(name, _init)) \
,M_IF_METHOD2(INIT_SET,SET, oplist)(INIT_SET(M_F(name, _init_set)),) \ ,M_IF_METHOD2(INIT_SET,SET, oplist)(INIT_SET(M_F(name, _init_set)),) \
@@ -270,7 +270,7 @@
M_P(void, name, _reset, array_t v) \ M_P(void, name, _reset, array_t v) \
{ \ { \
M_ARRA4_CONTRACT(v); \ M_ARRA4_CONTRACT(v); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
for(size_t i = 0; i < v->size; i++) \ for(size_t i = 0; i < v->size; i++) \
M_CALL_CLEAR(oplist, v->ptr[i]); \ M_CALL_CLEAR(oplist, v->ptr[i]); \
v->size = 0; \ v->size = 0; \
@@ -351,7 +351,7 @@
M_P(void, name, _set_at, array_t v, size_t i, type const x) \ M_P(void, name, _set_at, array_t v, size_t i, type const x) \
{ \ { \
M_ARRA4_CONTRACT(v); \ M_ARRA4_CONTRACT(v); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_ASSERT(v->size > 0 && v->ptr != NULL); \ M_ASSERT(v->size > 0 && v->ptr != NULL); \
M_ASSERT_INDEX(i, v->size); \ M_ASSERT_INDEX(i, v->size); \
M_CALL_SET(oplist, v->ptr[i], x); \ M_CALL_SET(oplist, v->ptr[i], x); \
@@ -543,7 +543,7 @@
M_P(void, name, _pop_back, type *dest, array_t v) \ M_P(void, name, _pop_back, type *dest, array_t v) \
{ \ { \
M_ARRA4_CONTRACT(v); \ M_ARRA4_CONTRACT(v); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_ASSERT (v->ptr != NULL); \ M_ASSERT (v->ptr != NULL); \
M_ASSERT_INDEX(0, v->size); \ M_ASSERT_INDEX(0, v->size); \
v->size--; \ v->size--; \
@@ -602,7 +602,7 @@
M_P(void, name, _pop_at, type *dest, array_t v, size_t i) \ M_P(void, name, _pop_at, type *dest, array_t v, size_t i) \
{ \ { \
M_ARRA4_CONTRACT(v); \ M_ARRA4_CONTRACT(v); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_ASSERT (v->size > 0 && v->ptr != NULL); \ M_ASSERT (v->size > 0 && v->ptr != NULL); \
M_ASSERT_INDEX(i, v->size); \ M_ASSERT_INDEX(i, v->size); \
if (dest) \ if (dest) \
@@ -661,7 +661,7 @@
M_P(void, name, _remove_v, array_t v, size_t i, size_t j) \ M_P(void, name, _remove_v, array_t v, size_t i, size_t j) \
{ \ { \
M_ARRA4_CONTRACT(v); \ M_ARRA4_CONTRACT(v); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_ASSERT(i < j && v->ptr != NULL); \ M_ASSERT(i < j && v->ptr != NULL); \
M_ASSERT_INDEX(i, v->size); \ M_ASSERT_INDEX(i, v->size); \
M_ASSERT_INDEX(j, v->size+1); \ M_ASSERT_INDEX(j, v->size+1); \
+2 -2
View File
@@ -834,7 +834,7 @@ m_bitset_popcount(const m_bitset_t set)
} }
/* Oplist for a bitset */ /* Oplist for a bitset */
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
#define M_BITSET_OPLIST \ #define M_BITSET_OPLIST \
(INIT(m_bitset_init) \ (INIT(m_bitset_init) \
,INIT_SET(m_bitset_init_set) \ ,INIT_SET(m_bitset_init_set) \
@@ -907,7 +907,7 @@ m_bitset_popcount(const m_bitset_t set)
#endif #endif
/* Register the OPLIST as a global one */ /* Register the OPLIST as a global one */
#ifdef M_USE_POOL #ifdef M_USE_CONTEXT
#define M_OPL_m_bitset_t() M_BITSET_POOL_OPLIST #define M_OPL_m_bitset_t() M_BITSET_POOL_OPLIST
#else #else
#define M_OPL_m_bitset_t() M_BITSET_OPLIST #define M_OPL_m_bitset_t() M_BITSET_OPLIST
+7 -7
View File
@@ -156,7 +156,7 @@
((M_LIB_ERROR(ARGUMENT_OF_BPTREE_OPLIST_IS_NOT_AN_OPLIST, name, oplist))) ((M_LIB_ERROR(ARGUMENT_OF_BPTREE_OPLIST_IS_NOT_AN_OPLIST, name, oplist)))
/* OPLIST definition of a b+tree (global tree) */ /* OPLIST definition of a b+tree (global tree) */
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
#define M_BPTR33_KEY_OPLIST_P3(name, oplist) \ #define M_BPTR33_KEY_OPLIST_P3(name, oplist) \
(INIT(M_F(name, _init)), \ (INIT(M_F(name, _init)), \
INIT_SET(M_F(name, _init_set)), \ INIT_SET(M_F(name, _init_set)), \
@@ -239,7 +239,7 @@
((M_LIB_ERROR(ARGUMENT_OF_BPTREE_OPLIST_IS_NOT_AN_OPLIST, name, key_oplist, value_oplist))) ((M_LIB_ERROR(ARGUMENT_OF_BPTREE_OPLIST_IS_NOT_AN_OPLIST, name, key_oplist, value_oplist)))
/* Final definition of the oplist (associative array) */ /* Final definition of the oplist (associative array) */
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
#define M_BPTR33_OPLIST2_P4(name, key_oplist, value_oplist) \ #define M_BPTR33_OPLIST2_P4(name, key_oplist, value_oplist) \
(INIT(M_F(name, _init)), \ (INIT(M_F(name, _init)), \
INIT_SET(M_F(name, _init_set)), \ INIT_SET(M_F(name, _init_set)), \
@@ -706,7 +706,7 @@
M_IF(isMap)( M_DEFERRED_COMMA value_t const value,) ) \ M_IF(isMap)( M_DEFERRED_COMMA value_t const value,) ) \
{ \ { \
M_ASSERT (M_F(name, _is_leaf)(n)); \ M_ASSERT (M_F(name, _is_leaf)(n)); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
int i, num = M_F(name, _get_num)(n); \ int i, num = M_F(name, _get_num)(n); \
M_ASSERT (num <= N); \ M_ASSERT (num <= N); \
/* Search for the key in the node n (a leaf) for insertion */ \ /* Search for the key in the node n (a leaf) for insertion */ \
@@ -737,7 +737,7 @@
M_P(int, name, _i_search_and_insert_in_node, node_t n, node_t l, key_t key) \ M_P(int, name, _i_search_and_insert_in_node, node_t n, node_t l, key_t key) \
{ \ { \
M_ASSERT (!M_F(name, _is_leaf)(n)); \ M_ASSERT (!M_F(name, _is_leaf)(n)); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
int i, num = M_F(name, _get_num)(n); \ int i, num = M_F(name, _get_num)(n); \
M_ASSERT (num <= N); \ M_ASSERT (num <= N); \
/* Search for the key in the node n (not a leaf) for insertion */ \ /* Search for the key in the node n (not a leaf) for insertion */ \
@@ -869,7 +869,7 @@
M_P(int, name, _i_search_and_remove_in_leaf, node_t n, key_t const key) \ M_P(int, name, _i_search_and_remove_in_leaf, node_t n, key_t const key) \
{ \ { \
M_ASSERT(M_F(name, _is_leaf)(n)); \ M_ASSERT(M_F(name, _is_leaf)(n)); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
const int num = M_F(name, _get_num)(n); \ const int num = M_F(name, _get_num)(n); \
for(int i = 0; i < num; i++) { \ for(int i = 0; i < num; i++) { \
const int cmp = M_CALL_CMP(key_oplist, key, n->key[i]); \ const int cmp = M_CALL_CMP(key_oplist, key, n->key[i]); \
@@ -890,7 +890,7 @@
{ \ { \
M_ASSERT (parent != NULL && !M_F(name, _is_leaf)(parent)); \ M_ASSERT (parent != NULL && !M_F(name, _is_leaf)(parent)); \
M_ASSERT (0 <= k && k < M_F(name, _get_num)(parent)); \ M_ASSERT (0 <= k && k < M_F(name, _get_num)(parent)); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
node_t left = parent->kind.node[k]; \ node_t left = parent->kind.node[k]; \
node_t right = parent->kind.node[k+1]; \ node_t right = parent->kind.node[k+1]; \
M_ASSERT (left != NULL && right != NULL); \ M_ASSERT (left != NULL && right != NULL); \
@@ -926,7 +926,7 @@
{ \ { \
M_ASSERT (parent != NULL && !M_F(name, _is_leaf)(parent)); \ M_ASSERT (parent != NULL && !M_F(name, _is_leaf)(parent)); \
M_ASSERT (0 <= k && k < M_F(name, _get_num)(parent)); \ M_ASSERT (0 <= k && k < M_F(name, _get_num)(parent)); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
node_t left = parent->kind.node[k]; \ node_t left = parent->kind.node[k]; \
node_t right = parent->kind.node[k+1]; \ node_t right = parent->kind.node[k+1]; \
M_ASSERT (left != NULL && right != NULL); \ M_ASSERT (left != NULL && right != NULL); \
+1 -1
View File
@@ -534,7 +534,7 @@ M_P(m_serial_return_code_t, m_bstring, _in_serial, m_bstring_t v, m_serial_read_
} }
/* Define the OPLIST of a BYTE STRING */ /* Define the OPLIST of a BYTE STRING */
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
#define M_BSTRING_OPLIST \ #define M_BSTRING_OPLIST \
(INIT(m_bstring_init),INIT_SET(m_bstring_init_set), SET(m_bstring_set), \ (INIT(m_bstring_init),INIT_SET(m_bstring_init_set), SET(m_bstring_set), \
INIT_MOVE(m_bstring_init_move), MOVE(m_bstring_move), \ INIT_MOVE(m_bstring_init_move), MOVE(m_bstring_move), \
+22 -22
View File
@@ -221,7 +221,7 @@ typedef enum {
M_N(void, name, _init, buffer_t v, size_t size) \ M_N(void, name, _init, buffer_t v, size_t size) \
{ \ { \
M_ASSERT(size <= UINT_MAX); \ M_ASSERT(size <= UINT_MAX); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_BUFF3R_IF_CTE_SIZE(m_size)(M_ASSERT(size == m_size), v->capacity = size); \ M_BUFF3R_IF_CTE_SIZE(m_size)(M_ASSERT(size == m_size), v->capacity = size); \
v->idx_prod = v->idx_cons = v->overwrite = 0; \ v->idx_prod = v->idx_cons = v->overwrite = 0; \
atomic_init (&v->number[0], 0U); \ atomic_init (&v->number[0], 0U); \
@@ -256,7 +256,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
M_N(void, name, _i_clear_obj, buffer_t v) \ M_N(void, name, _i_clear_obj, buffer_t v) \
{ \ { \
M_BUFF3R_CONTRACT(v,m_size); \ M_BUFF3R_CONTRACT(v,m_size); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
if (!M_BUFF3R_POLICY_P((policy), M_BUFFER_PUSH_INIT_POP_MOVE)) { \ if (!M_BUFF3R_POLICY_P((policy), M_BUFFER_PUSH_INIT_POP_MOVE)) { \
for(size_t i = 0; i < M_BUFF3R_SIZE(m_size); i++) { \ for(size_t i = 0; i < M_BUFF3R_SIZE(m_size); i++) { \
M_CALL_CLEAR(oplist, v->data[i].x); \ M_CALL_CLEAR(oplist, v->data[i].x); \
@@ -280,7 +280,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
M_N(void, name, _clear, buffer_t v) \ M_N(void, name, _clear, buffer_t v) \
{ \ { \
M_BUFF3R_CONTRACT(v,m_size); \ M_BUFF3R_CONTRACT(v,m_size); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name,_i_clear_obj)(v); \ M_F(name,_i_clear_obj)(v); \
M_BUFF3R_IF_CTE_SIZE(m_size)( , \ M_BUFF3R_IF_CTE_SIZE(m_size)( , \
M_CALL_FREE(oplist, M_F(name, _el_ct), v->data, M_BUFF3R_SIZE(m_size)); \ M_CALL_FREE(oplist, M_F(name, _el_ct), v->data, M_BUFF3R_SIZE(m_size)); \
@@ -296,7 +296,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
M_N(void, name, _reset, buffer_t v) \ M_N(void, name, _reset, buffer_t v) \
{ \ { \
M_BUFF3R_CONTRACT(v,m_size); \ M_BUFF3R_CONTRACT(v,m_size); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
m_mutex_lock(v->mutexPush); \ m_mutex_lock(v->mutexPush); \
m_mutex_lock(v->mutexPop); \ m_mutex_lock(v->mutexPop); \
M_BUFF3R_PROTECTED_CONTRACT(policy, v, m_size); \ M_BUFF3R_PROTECTED_CONTRACT(policy, v, m_size); \
@@ -314,7 +314,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
\ \
M_N(void, name, _init_set, buffer_t dest, const buffer_t src) \ M_N(void, name, _init_set, buffer_t dest, const buffer_t src) \
{ \ { \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
/* un-const 'src', so that we can lock it (semantically it is const) */ \ /* un-const 'src', so that we can lock it (semantically it is const) */ \
M_F(name, _uptr_ct) vu; \ M_F(name, _uptr_ct) vu; \
vu.cptr = src; \ vu.cptr = src; \
@@ -354,7 +354,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
\ \
M_N(void, name, _set, buffer_t dest, const buffer_t src) \ M_N(void, name, _set, buffer_t dest, const buffer_t src) \
{ \ { \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
/* un-const 'src', so that we can lock it (semantically it is const) */ \ /* un-const 'src', so that we can lock it (semantically it is const) */ \
M_F(name, _uptr_ct) vu; \ M_F(name, _uptr_ct) vu; \
vu.cptr = src; \ vu.cptr = src; \
@@ -449,7 +449,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
M_N(bool, name, _push_blocking, buffer_t v, type const data, bool blocking) \ M_N(bool, name, _push_blocking, buffer_t v, type const data, bool blocking) \
{ \ { \
M_BUFF3R_CONTRACT(v,m_size); \ M_BUFF3R_CONTRACT(v,m_size); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
/* Producer Mutex lock (mutex lock performs an acquire memory barrier) */ \ /* Producer Mutex lock (mutex lock performs an acquire memory barrier) */ \
m_mutex_lock(v->mutexPush); \ m_mutex_lock(v->mutexPush); \
while (!M_BUFF3R_POLICY_P((policy), M_BUFFER_PUSH_OVERWRITE) \ while (!M_BUFF3R_POLICY_P((policy), M_BUFFER_PUSH_OVERWRITE) \
@@ -523,7 +523,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
{ \ { \
M_BUFF3R_CONTRACT(v,m_size); \ M_BUFF3R_CONTRACT(v,m_size); \
M_ASSERT (data != NULL); \ M_ASSERT (data != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
/* consumer lock (mutex lock performs an acquire memory barrier) */ \ /* consumer lock (mutex lock performs an acquire memory barrier) */ \
m_mutex_lock(v->mutexPop); \ m_mutex_lock(v->mutexPop); \
while (M_F(name, _empty_p)(v)) { \ while (M_F(name, _empty_p)(v)) { \
@@ -714,7 +714,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
M_N(bool, name, _push, buffer_t table, type const x) \ M_N(bool, name, _push, buffer_t table, type const x) \
{ \ { \
M_QU3UE_MPMC_CONTRACT(table); \ M_QU3UE_MPMC_CONTRACT(table); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
unsigned int idx = atomic_load_explicit(&table->ProdIdx, \ unsigned int idx = atomic_load_explicit(&table->ProdIdx, \
memory_order_relaxed); \ memory_order_relaxed); \
const unsigned int i = idx & (table->size -1); \ const unsigned int i = idx & (table->size -1); \
@@ -749,7 +749,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
{ \ { \
M_QU3UE_MPMC_CONTRACT(table); \ M_QU3UE_MPMC_CONTRACT(table); \
M_ASSERT (ptr != NULL); \ M_ASSERT (ptr != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
unsigned int iC = atomic_load_explicit(&table->ConsoIdx, \ unsigned int iC = atomic_load_explicit(&table->ConsoIdx, \
memory_order_relaxed); \ memory_order_relaxed); \
const unsigned int i = (iC & (table->size -1)); \ const unsigned int i = (iC & (table->size -1)); \
@@ -779,7 +779,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
M_ASSERT (buffer != NULL); \ M_ASSERT (buffer != NULL); \
M_ASSERT( M_POWEROF2_P(size) && 0 < size && size <= UINT_MAX); \ M_ASSERT( M_POWEROF2_P(size) && 0 < size && size <= UINT_MAX); \
M_ASSERT(((policy) & (M_BUFFER_STACK|M_BUFFER_PUSH_OVERWRITE)) == 0); \ M_ASSERT(((policy) & (M_BUFFER_STACK|M_BUFFER_PUSH_OVERWRITE)) == 0); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
atomic_init(&buffer->ProdIdx, (unsigned int) size); \ atomic_init(&buffer->ProdIdx, (unsigned int) size); \
atomic_init(&buffer->ConsoIdx, (unsigned int) size); \ atomic_init(&buffer->ConsoIdx, (unsigned int) size); \
buffer->size = (unsigned int) size; \ buffer->size = (unsigned int) size; \
@@ -799,7 +799,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
M_N(void, name, _clear, buffer_t buffer) \ M_N(void, name, _clear, buffer_t buffer) \
{ \ { \
M_QU3UE_MPMC_CONTRACT(buffer); \ M_QU3UE_MPMC_CONTRACT(buffer); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
if (!M_BUFF3R_POLICY_P((policy), M_BUFFER_PUSH_INIT_POP_MOVE)) { \ if (!M_BUFF3R_POLICY_P((policy), M_BUFFER_PUSH_INIT_POP_MOVE)) { \
for(unsigned int j = 0; j < buffer->size; j++) { \ for(unsigned int j = 0; j < buffer->size; j++) { \
M_CALL_CLEAR(oplist, buffer->Tab[j].x); \ M_CALL_CLEAR(oplist, buffer->Tab[j].x); \
@@ -939,7 +939,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
M_N(bool, name, _push, buffer_t table, type const x) \ M_N(bool, name, _push, buffer_t table, type const x) \
{ \ { \
M_QU3UE_SPSC_CONTRACT(table); \ M_QU3UE_SPSC_CONTRACT(table); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
unsigned int r = atomic_load_explicit(&table->consoIdx, \ unsigned int r = atomic_load_explicit(&table->consoIdx, \
memory_order_relaxed); \ memory_order_relaxed); \
unsigned int w = atomic_load_explicit(&table->prodIdx, \ unsigned int w = atomic_load_explicit(&table->prodIdx, \
@@ -960,7 +960,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
M_N(bool, name, _push_move, buffer_t table, type *x) \ M_N(bool, name, _push_move, buffer_t table, type *x) \
{ \ { \
M_QU3UE_SPSC_CONTRACT(table); \ M_QU3UE_SPSC_CONTRACT(table); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
unsigned int r = atomic_load_explicit(&table->consoIdx, \ unsigned int r = atomic_load_explicit(&table->consoIdx, \
memory_order_relaxed); \ memory_order_relaxed); \
unsigned int w = atomic_load_explicit(&table->prodIdx, \ unsigned int w = atomic_load_explicit(&table->prodIdx, \
@@ -982,7 +982,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
{ \ { \
M_QU3UE_SPSC_CONTRACT(table); \ M_QU3UE_SPSC_CONTRACT(table); \
M_ASSERT (ptr != NULL); \ M_ASSERT (ptr != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
unsigned int w = atomic_load_explicit(&table->prodIdx, \ unsigned int w = atomic_load_explicit(&table->prodIdx, \
memory_order_relaxed); \ memory_order_relaxed); \
unsigned int r = atomic_load_explicit(&table->consoIdx, \ unsigned int r = atomic_load_explicit(&table->consoIdx, \
@@ -1005,7 +1005,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
M_QU3UE_SPSC_CONTRACT(table); \ M_QU3UE_SPSC_CONTRACT(table); \
M_ASSERT (x != NULL); \ M_ASSERT (x != NULL); \
M_ASSERT (n <= table->size); \ M_ASSERT (n <= table->size); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
unsigned int r = atomic_load_explicit(&table->consoIdx, \ unsigned int r = atomic_load_explicit(&table->consoIdx, \
memory_order_relaxed); \ memory_order_relaxed); \
unsigned int w = atomic_load_explicit(&table->prodIdx, \ unsigned int w = atomic_load_explicit(&table->prodIdx, \
@@ -1031,7 +1031,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
M_QU3UE_SPSC_CONTRACT(table); \ M_QU3UE_SPSC_CONTRACT(table); \
M_ASSERT (ptr != NULL); \ M_ASSERT (ptr != NULL); \
M_ASSERT (n <= table->size); \ M_ASSERT (n <= table->size); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
unsigned int w = atomic_load_explicit(&table->prodIdx, \ unsigned int w = atomic_load_explicit(&table->prodIdx, \
memory_order_relaxed); \ memory_order_relaxed); \
unsigned int r = atomic_load_explicit(&table->consoIdx, \ unsigned int r = atomic_load_explicit(&table->consoIdx, \
@@ -1055,7 +1055,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
M_N(void, name, _push_force, buffer_t table, type const x) \ M_N(void, name, _push_force, buffer_t table, type const x) \
{ \ { \
M_QU3UE_SPSC_CONTRACT(table); \ M_QU3UE_SPSC_CONTRACT(table); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
unsigned int r = atomic_load_explicit(&table->consoIdx, \ unsigned int r = atomic_load_explicit(&table->consoIdx, \
memory_order_relaxed); \ memory_order_relaxed); \
unsigned int w = atomic_load_explicit(&table->prodIdx, \ unsigned int w = atomic_load_explicit(&table->prodIdx, \
@@ -1119,7 +1119,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
M_ASSERT (buffer != NULL); \ M_ASSERT (buffer != NULL); \
M_ASSERT( M_POWEROF2_P(size) && 0 < size && size <= UINT_MAX); \ M_ASSERT( M_POWEROF2_P(size) && 0 < size && size <= UINT_MAX); \
M_ASSERT(((policy) & (M_BUFFER_STACK|M_BUFFER_PUSH_OVERWRITE)) == 0); \ M_ASSERT(((policy) & (M_BUFFER_STACK|M_BUFFER_PUSH_OVERWRITE)) == 0); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
atomic_init(&buffer->prodIdx, (unsigned int) size); \ atomic_init(&buffer->prodIdx, (unsigned int) size); \
atomic_init(&buffer->consoIdx, (unsigned int) size); \ atomic_init(&buffer->consoIdx, (unsigned int) size); \
buffer->size = (unsigned int) size; \ buffer->size = (unsigned int) size; \
@@ -1138,7 +1138,7 @@ M_N(void, name, _init, buffer_t v, size_t size) \
M_N(void, name, _clear, buffer_t buffer) \ M_N(void, name, _clear, buffer_t buffer) \
{ \ { \
M_QU3UE_SPSC_CONTRACT(buffer); \ M_QU3UE_SPSC_CONTRACT(buffer); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
if (!M_BUFF3R_POLICY_P((policy), M_BUFFER_PUSH_INIT_POP_MOVE)) { \ if (!M_BUFF3R_POLICY_P((policy), M_BUFFER_PUSH_INIT_POP_MOVE)) { \
for(unsigned int j = 0; j < buffer->size; j++) { \ for(unsigned int j = 0; j < buffer->size; j++) { \
M_CALL_CLEAR(oplist, buffer->Tab[j].x); \ M_CALL_CLEAR(oplist, buffer->Tab[j].x); \
@@ -1193,12 +1193,12 @@ M_N(void, name, _init, buffer_t v, size_t size) \
,GET_SIZE(M_F(name, _size)) \ ,GET_SIZE(M_F(name, _size)) \
) )
/* Same as M_EMPLACE_QUEUE_GENE but use M_GLOBAL_POOL */ /* Same as M_EMPLACE_QUEUE_GENE but use M_GLOBAL_CONTEXT */
#define M_BUFF3R_EMPLACE_QUEUE_GENE(name, name_t, function_name, oplist, init_func, exp_emplace_type) \ #define M_BUFF3R_EMPLACE_QUEUE_GENE(name, name_t, function_name, oplist, init_func, exp_emplace_type) \
M_N(void, name, function_name, name_t v M_EMPLACE_LIST_TYPE_VAR(a, exp_emplace_type) ) \ M_N(void, name, function_name, name_t v M_EMPLACE_LIST_TYPE_VAR(a, exp_emplace_type) ) \
{ \ { \
M_GET_TYPE oplist data; \ M_GET_TYPE oplist data; \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_EMPLACE_CALL_FUNC(a, init_func, oplist, data, exp_emplace_type); \ M_EMPLACE_CALL_FUNC(a, init_func, oplist, data, exp_emplace_type); \
M_F(name, _push)(v, data); \ M_F(name, _push)(v, data); \
M_CALL_CLEAR(oplist, data); \ M_CALL_CLEAR(oplist, data); \
+38 -39
View File
@@ -385,7 +385,7 @@ M_BEGIN_PROTECTED_CODE
* It returns NULL in case of memory allocation failure. * It returns NULL in case of memory allocation failure.
* void M_MEMORY_FREE(type, ptr, o): Free the object associated to the array of type 'type' at base 'ptr' of size 'o'. * void M_MEMORY_FREE(type, ptr, o): Free the object associated to the array of type 'type' at base 'ptr' of size 'o'.
* By default, old size do nothing. * By default, old size do nothing.
* Can use local optional named parameter "m_pool" which is defined by the called of the macro if M_USE_POOL is defined. * Can use local optional named parameter "m_context" which is defined by the called of the macro if M_USE_CONTEXT is defined.
*/ */
#ifndef M_MEMORY_REALLOC #ifndef M_MEMORY_REALLOC
#ifdef __cplusplus #ifdef __cplusplus
@@ -412,59 +412,60 @@ M_BEGIN_PROTECTED_CODE
#endif #endif
// Default global memory context is to consider the global context as '0' if it is not defined.
#ifndef M_USE_GLOBAL_CONTEXT
#define M_USE_GLOBAL_CONTEXT(varname) M_USE_CONTEXT varname = { 0 }
#endif
/* In order to support local context for memory functions, the prototypes and usages of some functions are modified /* In order to support local context for memory functions, the prototypes and usages of some functions are modified
* so that they can accept a first argument 'm_pool' which is the memory context parameter. * so that they can accept a first argument 'm_context' which is the memory context parameter.
* *
* For some functions, there is no meaning of a local memory context parameter: * For some functions, there is no meaning of a local memory context parameter:
* for all data shared between threads, only a global memory context has any meaning. * for all data shared between threads, only a global memory context has any meaning.
* For such cases, the memory context parameter is globally requested to the user through M_USE_GLOBAL_POOL or set to 0. * For such cases, the memory context parameter is globally requested to the user through M_USE_GLOBAL_POOL or set to 0.
* *
* This is controlled through M_USE_POOL parameter that define the type of the memory context parameter * This is controlled through M_USE_CONTEXT parameter that define the type of the memory context parameter
* to be used globally for all M*LIB. There is no possibility to support only some containers and not others. * to be used globally for all M*LIB. There is no possibility to support only some containers and not others.
* *
* Several macros are defined **globally** to support such features and being internally used by M*LIB containers. * Several macros are defined **globally** to support such features and being internally used by M*LIB containers.
* They expand to nothing if the memory context parameter is not requested: * They expand to nothing if the memory context parameter is not requested:
* * M_P_EXPAND: expand to the first parameter 'm_pool' of type M_USE_POOL for a function that may use memory context. * * M_P_EXPAND: expand to the first parameter 'm_context' of type M_USE_CONTEXT for a function that may use memory context.
* * M_P_EXPAND_void: same but assume that there is no argument in the initial function. * * M_P_EXPAND_void: same but assume that there is no argument in the initial function.
* * M_R_EXPAND: expand to the first parameter 'm_pool' (followed by a comma) * * M_R_EXPAND: expand to the first parameter 'm_context' (followed by a comma)
* * M_R_EXPAND_void: same but assume that there is no argument * * M_R_EXPAND_void: same but assume that there is no argument
* * M_R: add the parameter m_pool to the function call if needed, * * M_R: add the parameter m_context to the function call if needed,
* * M_P: define the prototype of a function that may have the parameter m_pool. * * M_P: define the prototype of a function that may have the parameter m_context.
* * M_N: define the prototype of a function that don't need the parameter m_pool. * * M_N: define the prototype of a function that don't need the parameter m_context.
* * M_ASSERT_POOL: avoid warning of unused m_pool argument * * M_UNUSED_CONTEXT: avoid warning of unused m_context argument
* * M_GLOBAL_POOL: define m_pool to zero, meaning it is a global memory context. * * M_GLOBAL_CONTEXT: define m_context to zero, meaning it is a global memory context.
*/ */
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
// Memory pool parameter not used for memory function. Stub it with 0 as it won't be used (global definition). // Memory context parameter not used for memory function.
# define M_P_EXPAND # define M_P_EXPAND
# define M_P_EXPAND_void void # define M_P_EXPAND_void void
# define M_R_EXPAND # define M_R_EXPAND
# define M_R_EXPAND_void # define M_R_EXPAND_void
# define M_R # define M_R
# define M_ASSERT_POOL() # define M_UNUSED_CONTEXT()
# define M_GLOBAL_POOL() # define M_GLOBAL_CONTEXT()
#else #else
// Default global value is to set to 0 the global pool. // Memory context parameter is used for function using memory. (local definition to the function).
#ifndef M_USE_GLOBAL_POOL
#define M_USE_GLOBAL_POOL(x) M_USE_POOL x = { 0 }
#endif
// Memory pool parameter is used for function using memory. (local definition to the function).
// Expand to a prototype to a function that may not trigger exception // Expand to a prototype to a function that may not trigger exception
# define M_P_EXPAND M_USE_POOL m_pool, # define M_P_EXPAND M_USE_CONTEXT m_context,
# define M_P_EXPAND_void M_USE_POOL m_pool # define M_P_EXPAND_void M_USE_CONTEXT m_context
# define M_R_EXPAND m_pool , # define M_R_EXPAND m_context ,
# define M_R_EXPAND_void m_pool # define M_R_EXPAND_void m_context
# define M_R(...) (m_pool, __VA_ARGS__) # define M_R(...) (m_context, __VA_ARGS__)
# define M_ASSERT_POOL() (void) m_pool # define M_UNUSED_CONTEXT() (void) m_context
# define M_GLOBAL_POOL() M_USE_GLOBAL_POOL(m_pool); (void) m_pool # define M_GLOBAL_CONTEXT() M_USE_GLOBAL_CONTEXT(m_context); (void) m_context
#endif #endif
// M_P: Expand to a prototype of a function that may trigger exception / accept memory context // M_P: Expand to a prototype of a function that may trigger exception / accept memory context
// M_N: Expand to a prototype of a function that may not trigger exception or accept memory context // M_N: Expand to a prototype of a function that may not trigger exception or accept memory context
// If not user M_F, no overloaded M_INLINE and no M_P_EXPAND, // If not user defined M_F or memory context, no overloaded M_INLINE,
// simplify definition of M_P/M_N to provide faster compile time. // simplify the definition of M_P/M_N to provide faster compile time.
// (faster build: 0.54s instead of 0.80s in extreme expanding) // (faster build: 0.54s instead of 0.80s in extreme expanding)
#if !defined(M_USE_POOL) && !defined(M_F) && !defined(M_USE_FINE_GRAINED_LINKAGE) && !defined(M_USE_DEF) && !defined(M_USE_DECL) #if !defined(M_USE_CONTEXT) && !defined(M_F) && !defined(M_USE_FINE_GRAINED_LINKAGE) && !defined(M_USE_DEF) && !defined(M_USE_DECL)
# define M_P(rettype, name, suffix, ...) static inline rettype name ## suffix(__VA_ARGS__) # define M_P(rettype, name, suffix, ...) static inline rettype name ## suffix(__VA_ARGS__)
# define M_N(rettype, name, suffix, ...) static inline rettype name ## suffix(__VA_ARGS__) # define M_N(rettype, name, suffix, ...) static inline rettype name ## suffix(__VA_ARGS__)
#else #else
@@ -472,8 +473,6 @@ M_BEGIN_PROTECTED_CODE
# define M_N(rettype, name, suffix, ...) M_INLINE rettype M_F(name, suffix)(__VA_ARGS__) # define M_N(rettype, name, suffix, ...) M_INLINE rettype M_F(name, suffix)(__VA_ARGS__)
#endif #endif
// TODO: 'pool' seems not the right term. Rename 'pool' into 'localmem' ? 'arena'? memcontext? context?
// Rename to M_USE_MEMORY_CONTEXT? M_USE_MEMCONTEXT
/************************************************************/ /************************************************************/
/********************* ERROR handling **********************/ /********************* ERROR handling **********************/
@@ -3730,14 +3729,14 @@ M_INLINE size_t m_core_cstr_hash(const char str[])
#define M_OPLAPI_5(method, oplist, x, ...) , x = M_DELAY3(method)(oplist, __VA_ARGS__) #define M_OPLAPI_5(method, oplist, x, ...) , x = M_DELAY3(method)(oplist, __VA_ARGS__)
#define M_OPLAPI_6(method, oplist, x, ...) , M_DELAY3(method)(&x, &__VA_ARGS__) #define M_OPLAPI_6(method, oplist, x, ...) , M_DELAY3(method)(&x, &__VA_ARGS__)
#define M_OPLAPI_7(method, oplist, x, ...) , M_DELAY3(method)(oplist, &x, &__VA_ARGS__) #define M_OPLAPI_7(method, oplist, x, ...) , M_DELAY3(method)(oplist, &x, &__VA_ARGS__)
#define M_OPLAPI_0P(method, oplist, ...) , M_DELAY3(method)(m_pool, __VA_ARGS__) #define M_OPLAPI_0P(method, oplist, ...) , M_DELAY3(method)(m_context, __VA_ARGS__)
#define M_OPLAPI_1P(method, oplist, ...) , M_DELAY3(method)(oplist, m_pool, __VA_ARGS__) #define M_OPLAPI_1P(method, oplist, ...) , M_DELAY3(method)(oplist, m_context, __VA_ARGS__)
#define M_OPLAPI_2P(method, oplist, ...) , M_DELAY3(method)(m_pool, & __VA_ARGS__) #define M_OPLAPI_2P(method, oplist, ...) , M_DELAY3(method)(m_context, & __VA_ARGS__)
#define M_OPLAPI_3P(method, oplist, ...) , M_DELAY3(method)(oplist, m_pool, &__VA_ARGS__) #define M_OPLAPI_3P(method, oplist, ...) , M_DELAY3(method)(oplist, m_context, &__VA_ARGS__)
#define M_OPLAPI_4P(method, oplist, x, ...) , x = M_DELAY3(method)(m_pool, __VA_ARGS__) #define M_OPLAPI_4P(method, oplist, x, ...) , x = M_DELAY3(method)(m_context, __VA_ARGS__)
#define M_OPLAPI_5P(method, oplist, x, ...) , x = M_DELAY3(method)(oplist, m_pool, __VA_ARGS__) #define M_OPLAPI_5P(method, oplist, x, ...) , x = M_DELAY3(method)(oplist, m_context, __VA_ARGS__)
#define M_OPLAPI_6P(method, oplist, x, ...) , M_DELAY3(method)(m_pool, &x, &__VA_ARGS__) #define M_OPLAPI_6P(method, oplist, x, ...) , M_DELAY3(method)(m_context, &x, &__VA_ARGS__)
#define M_OPLAPI_7P(method, oplist, x, ...) , M_DELAY3(method)(oplist, m_pool, &x, &__VA_ARGS__) #define M_OPLAPI_7P(method, oplist, x, ...) , M_DELAY3(method)(oplist, m_context, &x, &__VA_ARGS__)
/* API transformation support for indirection */ /* API transformation support for indirection */
#define M_OPLAPI_INDIRECT_0 M_OPLAPI_ERROR #define M_OPLAPI_INDIRECT_0 M_OPLAPI_ERROR
#define M_OPLAPI_INDIRECT_API_0(...) M_OPLAPI_0 #define M_OPLAPI_INDIRECT_API_0(...) M_OPLAPI_0
+6 -6
View File
@@ -103,7 +103,7 @@
M_EMPLACE_QUEUE_DEF(name, deque_t, _emplace_front, oplist, M_D3QUE_EMPLACE_FRONT_DEF) M_EMPLACE_QUEUE_DEF(name, deque_t, _emplace_front, oplist, M_D3QUE_EMPLACE_FRONT_DEF)
// OPLIST for the node deletion // OPLIST for the node deletion
#ifdef M_USE_POOL #ifdef M_USE_CONTEXT
#define M_D3QU3_NODE_DEL_OPLIST(name) (DEL(API_0P(M_F(name, _node_list_i_del)))) #define M_D3QU3_NODE_DEL_OPLIST(name) (DEL(API_0P(M_F(name, _node_list_i_del))))
#else #else
#define M_D3QU3_NODE_DEL_OPLIST(name) (DEL(M_F(name, _node_list_i_del))) #define M_D3QU3_NODE_DEL_OPLIST(name) (DEL(M_F(name, _node_list_i_del)))
@@ -222,7 +222,7 @@
M_P(void, name, _reset, deque_t d) \ M_P(void, name, _reset, deque_t d) \
{ \ { \
M_D3QU3_CONTRACT(d); \ M_D3QU3_CONTRACT(d); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
node_t *min_node = NULL; \ node_t *min_node = NULL; \
for(node_t *n = d->front->node; \ for(node_t *n = d->front->node; \
n != NULL ; \ n != NULL ; \
@@ -365,7 +365,7 @@
{ \ { \
M_D3QU3_CONTRACT(d); \ M_D3QU3_CONTRACT(d); \
M_ASSERT(d->count > 0); \ M_ASSERT(d->count > 0); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
node_t *n = d->back->node; \ node_t *n = d->back->node; \
size_t index = d->back->index; \ size_t index = d->back->index; \
index --; \ index --; \
@@ -407,7 +407,7 @@
{ \ { \
M_D3QU3_CONTRACT(d); \ M_D3QU3_CONTRACT(d); \
M_ASSERT(d->count > 0); \ M_ASSERT(d->count > 0); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
node_t *n = d->front->node; \ node_t *n = d->front->node; \
size_t index = d->front->index; \ size_t index = d->front->index; \
if (ptr != NULL) \ if (ptr != NULL) \
@@ -825,7 +825,7 @@
M_P(void, name, _set_at, deque_t d, size_t key, type const x) \ M_P(void, name, _set_at, deque_t d, size_t key, type const x) \
{ \ { \
M_D3QU3_CONTRACT(d); \ M_D3QU3_CONTRACT(d); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_ASSERT_INDEX (key, d->count); \ M_ASSERT_INDEX (key, d->count); \
type *p = M_F(name, _get)(d, key); \ type *p = M_F(name, _get)(d, key); \
M_CALL_SET(oplist, *p, x); \ M_CALL_SET(oplist, *p, x); \
@@ -1057,7 +1057,7 @@
((M_LIB_ERROR(ARGUMENT_OF_DEQUE_OPLIST_IS_NOT_AN_OPLIST, name, oplist))) ((M_LIB_ERROR(ARGUMENT_OF_DEQUE_OPLIST_IS_NOT_AN_OPLIST, name, oplist)))
/* OPLIST definition of a deque */ /* OPLIST definition of a deque */
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
#define M_D3QU3_OPLIST_P3(name, oplist) \ #define M_D3QU3_OPLIST_P3(name, oplist) \
(INIT(M_F(name, _init)) \ (INIT(M_F(name, _init)) \
,INIT_SET(M_F(name, _init_set)) \ ,INIT_SET(M_F(name, _init_set)) \
+3 -3
View File
@@ -1253,7 +1253,7 @@ M_ARRAY_DEF(m_array_index, m_indexhash_t, M_POD_OPLIST)
/* Define the oplist of a dictionary /* Define the oplist of a dictionary
NOTE: IT_REF is not exported so that the contained appears as not modifiable NOTE: IT_REF is not exported so that the contained appears as not modifiable
by algorithm.*/ by algorithm.*/
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
#define M_D1CT_OPLIST_P4(name, key_oplist, value_oplist) \ #define M_D1CT_OPLIST_P4(name, key_oplist, value_oplist) \
(INIT(M_F(name, _init)), \ (INIT(M_F(name, _init)), \
INIT_SET(M_F(name, _init_set)), \ INIT_SET(M_F(name, _init_set)), \
@@ -1349,7 +1349,7 @@ M_ARRAY_DEF(m_array_index, m_indexhash_t, M_POD_OPLIST)
/* Define the oplist of a set /* Define the oplist of a set
Note: IT_REF is not exported so that the contained appears as not modifiable Note: IT_REF is not exported so that the contained appears as not modifiable
*/ */
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
#define M_D1CT_SET_OPLIST_P3(name, oplist) \ #define M_D1CT_SET_OPLIST_P3(name, oplist) \
(INIT(M_F(name, _init)), \ (INIT(M_F(name, _init)), \
INIT_SET(M_F(name, _init_set)), \ INIT_SET(M_F(name, _init_set)), \
@@ -2078,7 +2078,7 @@ enum m_d1ct_oa_element_e {
M_P(void, name, _bulk_get, unsigned n, value_type val[M_VLA(n)], dict_t dict, key_type const key[M_VLA(n)], value_type def) \ M_P(void, name, _bulk_get, unsigned n, value_type val[M_VLA(n)], dict_t dict, key_type const key[M_VLA(n)], value_type def) \
{ \ { \
M_D1CT_OA_CONTRACT (dict); \ M_D1CT_OA_CONTRACT (dict); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
size_t h[M_USE_MAX_PREFETCH]; \ size_t h[M_USE_MAX_PREFETCH]; \
M_F(name, _pair_ct) *data = dict->data; \ M_F(name, _pair_ct) *data = dict->data; \
const size_t mask = dict->mask; \ const size_t mask = dict->mask; \
+1 -1
View File
@@ -101,7 +101,7 @@
((M_LIB_ERROR(ARGUMENT_OF_LIST_OPLIST_IS_NOT_AN_OPLIST, name, oplist))) ((M_LIB_ERROR(ARGUMENT_OF_LIST_OPLIST_IS_NOT_AN_OPLIST, name, oplist)))
/* OPLIST definition of a list and list_dual_push */ /* OPLIST definition of a list and list_dual_push */
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
#define M_L1ST_OPLIST_P3(name, oplist) \ #define M_L1ST_OPLIST_P3(name, oplist) \
(INIT(M_F(name, _init)), \ (INIT(M_F(name, _init)), \
INIT_SET(M_F(name, _init_set)), \ INIT_SET(M_F(name, _init_set)), \
+1 -1
View File
@@ -71,7 +71,7 @@
((M_LIB_ERROR(ARGUMENT_OF_PRIOQUEUE_OPLIST_IS_NOT_AN_OPLIST, name, oplist))) ((M_LIB_ERROR(ARGUMENT_OF_PRIOQUEUE_OPLIST_IS_NOT_AN_OPLIST, name, oplist)))
/* Define oplist of a priority queue */ /* Define oplist of a priority queue */
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
#define M_PR1OQUEUE_OPLIST_P3(name, oplist) \ #define M_PR1OQUEUE_OPLIST_P3(name, oplist) \
(INIT(M_F(name, _init)) \ (INIT(M_F(name, _init)) \
,INIT_SET(M_F(name, _init_set)) \ ,INIT_SET(M_F(name, _init_set)) \
+5 -5
View File
@@ -168,7 +168,7 @@
M_P(void, name, _init, queue_t v, size_t size) \ M_P(void, name, _init, queue_t v, size_t size) \
{ \ { \
M_ASSERT(size <= UINT_MAX); \ M_ASSERT(size <= UINT_MAX); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_QUEU3_IF_CTE_SIZE(m_size)(M_ASSERT(size == m_size), v->capacity = (unsigned) size); \ M_QUEU3_IF_CTE_SIZE(m_size)(M_ASSERT(size == m_size), v->capacity = (unsigned) size); \
v->idx_prod = v->idx_cons = v->number = 0; \ v->idx_prod = v->idx_cons = v->number = 0; \
\ \
@@ -194,7 +194,7 @@ M_QUEU3_IF_CTE_SIZE(m_size)( \
M_P(void, name, _i_clear_obj, queue_t v) \ M_P(void, name, _i_clear_obj, queue_t v) \
{ \ { \
M_QUEU3_CONTRACT(v,m_size); \ M_QUEU3_CONTRACT(v,m_size); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
for(size_t i = 0; i < M_QUEU3_SIZE(v, m_size); i++) { \ for(size_t i = 0; i < M_QUEU3_SIZE(v, m_size); i++) { \
M_CALL_CLEAR(oplist, v->data[i]); \ M_CALL_CLEAR(oplist, v->data[i]); \
} \ } \
@@ -205,7 +205,7 @@ M_QUEU3_IF_CTE_SIZE(m_size)( \
M_P(void, name, _clear, queue_t v) \ M_P(void, name, _clear, queue_t v) \
{ \ { \
M_QUEU3_CONTRACT(v,m_size); \ M_QUEU3_CONTRACT(v,m_size); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_F(name,_i_clear_obj)M_R(v); \ M_F(name,_i_clear_obj)M_R(v); \
M_QUEU3_IF_CTE_SIZE(m_size)( , \ M_QUEU3_IF_CTE_SIZE(m_size)( , \
M_CALL_FREE(oplist, type, v->data, M_QUEU3_SIZE(v, m_size)); \ M_CALL_FREE(oplist, type, v->data, M_QUEU3_SIZE(v, m_size)); \
@@ -264,7 +264,7 @@ M_QUEU3_IF_CTE_SIZE(m_size)( \
M_P(bool, name, _push, queue_t v, type const data) \ M_P(bool, name, _push, queue_t v, type const data) \
{ \ { \
M_QUEU3_CONTRACT(v,m_size); \ M_QUEU3_CONTRACT(v,m_size); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
if (M_F(name, _full_p)(v)) \ if (M_F(name, _full_p)(v)) \
return false; \ return false; \
\ \
@@ -284,7 +284,7 @@ M_QUEU3_IF_CTE_SIZE(m_size)( \
{ \ { \
M_QUEU3_CONTRACT(v,m_size); \ M_QUEU3_CONTRACT(v,m_size); \
M_ASSERT (data != NULL); \ M_ASSERT (data != NULL); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
if (M_F(name, _empty_p)(v)) \ if (M_F(name, _empty_p)(v)) \
return false; \ return false; \
\ \
+1 -1
View File
@@ -71,7 +71,7 @@
/* OPLIST definition of a rbtree /* OPLIST definition of a rbtree
NOTE: IT_REF is not exported so that the container appears as not modifiable NOTE: IT_REF is not exported so that the container appears as not modifiable
by algorithm.*/ by algorithm.*/
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
#define M_RBTR33_OPLIST_P3(name, oplist) \ #define M_RBTR33_OPLIST_P3(name, oplist) \
(INIT(M_F(name, _init)), \ (INIT(M_F(name, _init)), \
INIT_SET(M_F(name, _init_set)), \ INIT_SET(M_F(name, _init_set)), \
+13 -13
View File
@@ -113,7 +113,7 @@ m_ser1al_bin_read_size(FILE *f, size_t *size)
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_bin, _write_boolean, m_serial_write_t serial, const bool data) M_P(m_serial_return_code_t, m_ser1al_bin, _write_boolean, m_serial_write_t serial, const bool data)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
size_t n = fwrite (M_ASSIGN_CAST(const void*, &data), sizeof (bool), 1, f); size_t n = fwrite (M_ASSIGN_CAST(const void*, &data), sizeof (bool), 1, f);
return n == 1 ? M_SERIAL_OK_DONE : m_core_serial_fail(); return n == 1 ? M_SERIAL_OK_DONE : m_core_serial_fail();
@@ -123,7 +123,7 @@ M_P(m_serial_return_code_t, m_ser1al_bin, _write_boolean, m_serial_write_t seria
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_bin, _write_integer, m_serial_write_t serial,const long long data, const size_t size_of_type) M_P(m_serial_return_code_t, m_ser1al_bin, _write_integer, m_serial_write_t serial,const long long data, const size_t size_of_type)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
size_t n; size_t n;
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
@@ -148,7 +148,7 @@ M_P(m_serial_return_code_t, m_ser1al_bin, _write_integer, m_serial_write_t seria
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_bin, _write_float, m_serial_write_t serial, const long double data, const size_t size_of_type) M_P(m_serial_return_code_t, m_ser1al_bin, _write_float, m_serial_write_t serial, const long double data, const size_t size_of_type)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
size_t n; size_t n;
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
@@ -170,7 +170,7 @@ M_P(m_serial_return_code_t, m_ser1al_bin, _write_float, m_serial_write_t serial,
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_bin, _write_string, m_serial_write_t serial, const char data[], size_t length) M_P(m_serial_return_code_t, m_ser1al_bin, _write_string, m_serial_write_t serial, const char data[], size_t length)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
M_ASSERT_SLOW(length == strlen(data) ); M_ASSERT_SLOW(length == strlen(data) );
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
M_ASSERT(f != NULL && data != NULL); M_ASSERT(f != NULL && data != NULL);
@@ -190,7 +190,7 @@ M_P(m_serial_return_code_t, m_ser1al_bin, _write_string, m_serial_write_t serial
Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_bin, _write_array_start, m_serial_local_t local, m_serial_write_t serial, const size_t number_of_elements) M_P(m_serial_return_code_t, m_ser1al_bin, _write_array_start, m_serial_local_t local, m_serial_write_t serial, const size_t number_of_elements)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; //Unused (void) local; //Unused
if (number_of_elements == (size_t)-1) return M_SERIAL_FAIL_RETRY; if (number_of_elements == (size_t)-1) return M_SERIAL_FAIL_RETRY;
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
@@ -202,7 +202,7 @@ M_P(m_serial_return_code_t, m_ser1al_bin, _write_array_start, m_serial_local_t l
Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_bin, _write_array_next, m_serial_local_t local, m_serial_write_t serial) M_P(m_serial_return_code_t, m_ser1al_bin, _write_array_next, m_serial_local_t local, m_serial_write_t serial)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // Unused (void) local; // Unused
(void) serial; // Unused (void) serial; // Unused
return M_SERIAL_OK_CONTINUE; return M_SERIAL_OK_CONTINUE;
@@ -212,7 +212,7 @@ M_P(m_serial_return_code_t, m_ser1al_bin, _write_array_next, m_serial_local_t lo
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_bin, _write_array_end, m_serial_local_t local, m_serial_write_t serial) M_P(m_serial_return_code_t, m_ser1al_bin, _write_array_end, m_serial_local_t local, m_serial_write_t serial)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // Unused (void) local; // Unused
(void) serial; // Unused (void) serial; // Unused
return M_SERIAL_OK_CONTINUE; return M_SERIAL_OK_CONTINUE;
@@ -222,7 +222,7 @@ M_P(m_serial_return_code_t, m_ser1al_bin, _write_array_end, m_serial_local_t loc
Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_bin, _write_map_value, m_serial_local_t local, m_serial_write_t serial) M_P(m_serial_return_code_t, m_ser1al_bin, _write_map_value, m_serial_local_t local, m_serial_write_t serial)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
(void) serial; (void) serial;
return M_SERIAL_OK_CONTINUE; return M_SERIAL_OK_CONTINUE;
@@ -234,7 +234,7 @@ M_P(m_serial_return_code_t, m_ser1al_bin, _write_map_value, m_serial_local_t loc
Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_bin, _write_tuple_start, m_serial_local_t local, m_serial_write_t serial) M_P(m_serial_return_code_t, m_ser1al_bin, _write_tuple_start, m_serial_local_t local, m_serial_write_t serial)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
(void) serial; (void) serial;
return M_SERIAL_OK_CONTINUE; return M_SERIAL_OK_CONTINUE;
@@ -244,7 +244,7 @@ M_P(m_serial_return_code_t, m_ser1al_bin, _write_tuple_start, m_serial_local_t l
Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_bin, _write_tuple_id, m_serial_local_t local, m_serial_write_t serial, const char *const field_name[], const int max, const int index) M_P(m_serial_return_code_t, m_ser1al_bin, _write_tuple_id, m_serial_local_t local, m_serial_write_t serial, const char *const field_name[], const int max, const int index)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
(void) serial; (void) serial;
(void) field_name; (void) field_name;
@@ -257,7 +257,7 @@ M_P(m_serial_return_code_t, m_ser1al_bin, _write_tuple_id, m_serial_local_t loca
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_bin, _write_tuple_end, m_serial_local_t local, m_serial_write_t serial) M_P(m_serial_return_code_t, m_ser1al_bin, _write_tuple_end, m_serial_local_t local, m_serial_write_t serial)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
(void) serial; (void) serial;
return M_SERIAL_OK_DONE; return M_SERIAL_OK_DONE;
@@ -270,7 +270,7 @@ M_P(m_serial_return_code_t, m_ser1al_bin, _write_tuple_end, m_serial_local_t loc
Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_bin, _write_variant_start, m_serial_local_t local, m_serial_write_t serial, const char *const field_name[], const int max, const int index) M_P(m_serial_return_code_t, m_ser1al_bin, _write_variant_start, m_serial_local_t local, m_serial_write_t serial, const char *const field_name[], const int max, const int index)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) field_name; (void) field_name;
(void) max; (void) max;
(void) local; (void) local;
@@ -283,7 +283,7 @@ M_P(m_serial_return_code_t, m_ser1al_bin, _write_variant_start, m_serial_local_t
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_bin, _write_variant_end, m_serial_local_t local, m_serial_write_t serial) M_P(m_serial_return_code_t, m_ser1al_bin, _write_variant_end, m_serial_local_t local, m_serial_write_t serial)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
(void) serial; (void) serial;
return M_SERIAL_OK_DONE; return M_SERIAL_OK_DONE;
+16 -16
View File
@@ -38,7 +38,7 @@ M_BEGIN_PROTECTED_CODE
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_boolean, m_serial_write_t serial, const bool data) M_P(m_serial_return_code_t, m_ser1al_json, _write_boolean, m_serial_write_t serial, const bool data)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
int n = fprintf(f, "%s", data ? "true" : "false"); int n = fprintf(f, "%s", data ? "true" : "false");
return n > 0 ? M_SERIAL_OK_DONE : m_core_serial_fail(); return n > 0 ? M_SERIAL_OK_DONE : m_core_serial_fail();
@@ -48,7 +48,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_boolean, m_serial_write_t seri
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_integer, m_serial_write_t serial,const long long data, const size_t size_of_type) M_P(m_serial_return_code_t, m_ser1al_json, _write_integer, m_serial_write_t serial,const long long data, const size_t size_of_type)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) size_of_type; // Ignored (void) size_of_type; // Ignored
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
int n = fprintf(f, "%lld", data); int n = fprintf(f, "%lld", data);
@@ -59,7 +59,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_integer, m_serial_write_t seri
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_float, m_serial_write_t serial, const long double data, const size_t size_of_type) M_P(m_serial_return_code_t, m_ser1al_json, _write_float, m_serial_write_t serial, const long double data, const size_t size_of_type)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) size_of_type; // Ignored (void) size_of_type; // Ignored
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
int n = fprintf(f, "%Lf", data); int n = fprintf(f, "%Lf", data);
@@ -70,7 +70,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_float, m_serial_write_t serial
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_string, m_serial_write_t serial, const char data[], size_t length) M_P(m_serial_return_code_t, m_ser1al_json, _write_string, m_serial_write_t serial, const char data[], size_t length)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
M_ASSERT(length == (m_str1ng_size_t) length); M_ASSERT(length == (m_str1ng_size_t) length);
M_ASSERT_SLOW(length == strlen(data) ); M_ASSERT_SLOW(length == strlen(data) );
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
@@ -94,7 +94,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_string, m_serial_write_t seria
Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_array_start, m_serial_local_t local, m_serial_write_t serial, const size_t number_of_elements) M_P(m_serial_return_code_t, m_ser1al_json, _write_array_start, m_serial_local_t local, m_serial_write_t serial, const size_t number_of_elements)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
(void) number_of_elements; // Ignored (void) number_of_elements; // Ignored
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
@@ -106,7 +106,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_array_start, m_serial_local_t
Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_array_next, m_serial_local_t local, m_serial_write_t serial) M_P(m_serial_return_code_t, m_ser1al_json, _write_array_next, m_serial_local_t local, m_serial_write_t serial)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
int n = fprintf(f, ","); int n = fprintf(f, ",");
@@ -117,7 +117,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_array_next, m_serial_local_t l
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_array_end, m_serial_local_t local, m_serial_write_t serial) M_P(m_serial_return_code_t, m_ser1al_json, _write_array_end, m_serial_local_t local, m_serial_write_t serial)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
int n = fprintf(f, "]"); int n = fprintf(f, "]");
@@ -132,7 +132,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_array_end, m_serial_local_t lo
Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_map_start, m_serial_local_t local, m_serial_write_t serial, const size_t number_of_elements) M_P(m_serial_return_code_t, m_ser1al_json, _write_map_start, m_serial_local_t local, m_serial_write_t serial, const size_t number_of_elements)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
(void) number_of_elements; // Ignored (void) number_of_elements; // Ignored
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
@@ -144,7 +144,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_map_start, m_serial_local_t lo
Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_map_value, m_serial_local_t local, m_serial_write_t serial) M_P(m_serial_return_code_t, m_ser1al_json, _write_map_value, m_serial_local_t local, m_serial_write_t serial)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
int n = fprintf(f, ":"); int n = fprintf(f, ":");
@@ -155,7 +155,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_map_value, m_serial_local_t lo
Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_map_next, m_serial_local_t local, m_serial_write_t serial) M_P(m_serial_return_code_t, m_ser1al_json, _write_map_next, m_serial_local_t local, m_serial_write_t serial)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
int n = fprintf(f, ","); int n = fprintf(f, ",");
@@ -166,7 +166,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_map_next, m_serial_local_t loc
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_map_end, m_serial_local_t local, m_serial_write_t serial) M_P(m_serial_return_code_t, m_ser1al_json, _write_map_end, m_serial_local_t local, m_serial_write_t serial)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
int n = fprintf(f, "}"); int n = fprintf(f, "}");
@@ -179,7 +179,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_map_end, m_serial_local_t loca
Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_tuple_start, m_serial_local_t local, m_serial_write_t serial) M_P(m_serial_return_code_t, m_ser1al_json, _write_tuple_start, m_serial_local_t local, m_serial_write_t serial)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
int n = fprintf(f, "{"); int n = fprintf(f, "{");
@@ -190,7 +190,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_tuple_start, m_serial_local_t
Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_tuple_id, m_serial_local_t local, m_serial_write_t serial, const char *const field_name[], const int max, const int index) M_P(m_serial_return_code_t, m_ser1al_json, _write_tuple_id, m_serial_local_t local, m_serial_write_t serial, const char *const field_name[], const int max, const int index)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
(void) max; // Ignored (void) max; // Ignored
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
@@ -202,7 +202,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_tuple_id, m_serial_local_t loc
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_tuple_end, m_serial_local_t local, m_serial_write_t serial) M_P(m_serial_return_code_t, m_ser1al_json, _write_tuple_end, m_serial_local_t local, m_serial_write_t serial)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
int n = fprintf(f, "}"); int n = fprintf(f, "}");
@@ -216,7 +216,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_tuple_end, m_serial_local_t lo
Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_CONTINUE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_variant_start, m_serial_local_t local, m_serial_write_t serial, const char *const field_name[], const int max, const int index) M_P(m_serial_return_code_t, m_ser1al_json, _write_variant_start, m_serial_local_t local, m_serial_write_t serial, const char *const field_name[], const int max, const int index)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
(void) max; // argument not used (void) max; // argument not used
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
@@ -235,7 +235,7 @@ M_P(m_serial_return_code_t, m_ser1al_json, _write_variant_start, m_serial_local_
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */ Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
M_P(m_serial_return_code_t, m_ser1al_json, _write_variant_end, m_serial_local_t local, m_serial_write_t serial) M_P(m_serial_return_code_t, m_ser1al_json, _write_variant_end, m_serial_local_t local, m_serial_write_t serial)
{ {
M_ASSERT_POOL(); M_UNUSED_CONTEXT();
(void) local; // argument not used (void) local; // argument not used
FILE *f = (FILE *)serial->data[0].p; FILE *f = (FILE *)serial->data[0].p;
int n = fprintf(f, "}"); int n = fprintf(f, "}");
+30 -30
View File
@@ -613,7 +613,7 @@ extern shared_t *function_name(M_EMPLACE_LIST_TYPE_VAR_ALTER(a, exp_emplace_type
M_IF_METHOD(INIT, oplist)( \ M_IF_METHOD(INIT, oplist)( \
fattr shared_t *M_F(name, _new)(void) \ fattr shared_t *M_F(name, _new)(void) \
{ \ { \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
shared_t *out = M_CALL_NEW(oplist, shared_t); \ shared_t *out = M_CALL_NEW(oplist, shared_t); \
if (M_UNLIKELY_NOMEM( out == NULL)) { \ if (M_UNLIKELY_NOMEM( out == NULL)) { \
M_MEMORY_FULL(shared_t, 1); \ M_MEMORY_FULL(shared_t, 1); \
@@ -629,7 +629,7 @@ M_IF_METHOD(INIT_SET, oplist)( \
fattr shared_t *M_F(name, _clone)(const shared_t *src) \ fattr shared_t *M_F(name, _clone)(const shared_t *src) \
{ \ { \
M_ASSERT(src != NULL); \ M_ASSERT(src != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
shared_t *out = M_CALL_NEW(oplist, shared_t); \ shared_t *out = M_CALL_NEW(oplist, shared_t); \
if (M_UNLIKELY_NOMEM( out == NULL)) { \ if (M_UNLIKELY_NOMEM( out == NULL)) { \
M_MEMORY_FULL(shared_t, 1); \ M_MEMORY_FULL(shared_t, 1); \
@@ -646,7 +646,7 @@ M_IF_METHOD(INIT_SET, oplist)( \
fattr shared_t *M_F(name, _new_from)(type const src); ) \ fattr shared_t *M_F(name, _new_from)(type const src); ) \
fattr shared_t *M_F(name, _new_from)(type const src) \ fattr shared_t *M_F(name, _new_from)(type const src) \
{ \ { \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
shared_t *out = M_CALL_NEW(oplist, shared_t); \ shared_t *out = M_CALL_NEW(oplist, shared_t); \
if (M_UNLIKELY_NOMEM( out == NULL)) { \ if (M_UNLIKELY_NOMEM( out == NULL)) { \
M_MEMORY_FULL(shared_t, 1); \ M_MEMORY_FULL(shared_t, 1); \
@@ -663,7 +663,7 @@ M_IF_METHOD(SET, oplist)( \
{ \ { \
M_ASSERT(out != NULL); \ M_ASSERT(out != NULL); \
M_ASSERT(src != NULL); \ M_ASSERT(src != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
if (M_UNLIKELY (out == src)) return; \ if (M_UNLIKELY (out == src)) return; \
M_F(name, _write_read_lock)(out, src); \ M_F(name, _write_read_lock)(out, src); \
M_ON_EXCEPTION( M_F(name, _write_read_unlock)(out, src) ) \ M_ON_EXCEPTION( M_F(name, _write_read_unlock)(out, src) ) \
@@ -682,7 +682,7 @@ fattr shared_t *M_F(name, _acquire)(shared_t *out) \
\ \
fattr void M_F(name, _release)(shared_t *out) \ fattr void M_F(name, _release)(shared_t *out) \
{ \ { \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
if (out != NULL && M_C3(m_shar3d_, name, _dec_owner)(out)) { \ if (out != NULL && M_C3(m_shar3d_, name, _dec_owner)(out)) { \
M_CALL_CLEAR(oplist, out->data); \ M_CALL_CLEAR(oplist, out->data); \
M_F(name, _clear_lock)(out); \ M_F(name, _clear_lock)(out); \
@@ -706,7 +706,7 @@ M_EMPLACE_QUEUE_DEF( (name, fattr), shared_t, M_F(name, _make), oplist, M_SHAR3D
#define M_SHAR3D_PTR_DEF_BASIC_MAKE(name_attr, shared_t, function_name, oplist, init_func, exp_emplace_type) \ #define M_SHAR3D_PTR_DEF_BASIC_MAKE(name_attr, shared_t, function_name, oplist, init_func, exp_emplace_type) \
M_PAIR_2 name_attr shared_t *function_name(M_EMPLACE_LIST_TYPE_VAR_ALTER(a, exp_emplace_type)) \ M_PAIR_2 name_attr shared_t *function_name(M_EMPLACE_LIST_TYPE_VAR_ALTER(a, exp_emplace_type)) \
{ \ { \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
shared_t *out = M_CALL_NEW(oplist, shared_t); \ shared_t *out = M_CALL_NEW(oplist, shared_t); \
if (M_UNLIKELY_NOMEM( out == NULL)) { \ if (M_UNLIKELY_NOMEM( out == NULL)) { \
M_MEMORY_FULL(shared_t, 1); \ M_MEMORY_FULL(shared_t, 1); \
@@ -753,7 +753,7 @@ M_IF_METHOD(RESET, oplist)( \
fattr void M_F(name, _reset)(shared_t *out) \ fattr void M_F(name, _reset)(shared_t *out) \
{ \ { \
M_ASSERT(out != NULL); \ M_ASSERT(out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
/* RESET cannot throw exception */ \ /* RESET cannot throw exception */ \
M_CALL_RESET(oplist, out->data); \ M_CALL_RESET(oplist, out->data); \
@@ -866,7 +866,7 @@ M_IF_METHOD(ADD, oplist)( \
fattr void M_F(name, _add)(shared_t *out, const shared_t *src1, const shared_t *src2) \ fattr void M_F(name, _add)(shared_t *out, const shared_t *src1, const shared_t *src2) \
{ \ { \
M_ASSERT(out != NULL && src1 != NULL && src2 != NULL); \ M_ASSERT(out != NULL && src1 != NULL && src2 != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_read2_lock)(out, src1, src2); \ M_F(name, _write_read2_lock)(out, src1, src2); \
M_ON_EXCEPTION( M_F(name, _write_read2_unlock)(out, src1, src2) ) \ M_ON_EXCEPTION( M_F(name, _write_read2_unlock)(out, src1, src2) ) \
M_CALL_ADD(oplist, out->data, src1->data, src2->data); \ M_CALL_ADD(oplist, out->data, src1->data, src2->data); \
@@ -878,7 +878,7 @@ M_IF_METHOD(SUB, oplist)( \
fattr void M_F(name, _sub)(shared_t *out, const shared_t *src1, const shared_t *src2) \ fattr void M_F(name, _sub)(shared_t *out, const shared_t *src1, const shared_t *src2) \
{ \ { \
M_ASSERT(out != NULL && src1 != NULL && src2 != NULL); \ M_ASSERT(out != NULL && src1 != NULL && src2 != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_read2_lock)(out, src1, src2); \ M_F(name, _write_read2_lock)(out, src1, src2); \
M_ON_EXCEPTION( M_F(name, _write_read2_unlock)(out, src1, src2) ) \ M_ON_EXCEPTION( M_F(name, _write_read2_unlock)(out, src1, src2) ) \
M_CALL_SUB(oplist, out->data, src1->data, src2->data); \ M_CALL_SUB(oplist, out->data, src1->data, src2->data); \
@@ -890,7 +890,7 @@ M_IF_METHOD(MUL, oplist)( \
fattr void M_F(name, _mul)(shared_t *out, const shared_t *src1, const shared_t *src2) \ fattr void M_F(name, _mul)(shared_t *out, const shared_t *src1, const shared_t *src2) \
{ \ { \
M_ASSERT(out != NULL && src1 != NULL && src2 != NULL); \ M_ASSERT(out != NULL && src1 != NULL && src2 != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_read2_lock)(out, src1, src2); \ M_F(name, _write_read2_lock)(out, src1, src2); \
M_ON_EXCEPTION( M_F(name, _write_read2_unlock)(out, src1, src2) ) \ M_ON_EXCEPTION( M_F(name, _write_read2_unlock)(out, src1, src2) ) \
M_CALL_MUL(oplist, out->data, src1->data, src2->data); \ M_CALL_MUL(oplist, out->data, src1->data, src2->data); \
@@ -902,7 +902,7 @@ M_IF_METHOD(DIV, oplist)( \
fattr void M_F(name, _div)(shared_t *out, const shared_t *src1, const shared_t *src2) \ fattr void M_F(name, _div)(shared_t *out, const shared_t *src1, const shared_t *src2) \
{ \ { \
M_ASSERT(out != NULL && src1 != NULL && src2 != NULL); \ M_ASSERT(out != NULL && src1 != NULL && src2 != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_read2_lock)(out, src1, src2); \ M_F(name, _write_read2_lock)(out, src1, src2); \
M_ON_EXCEPTION( M_F(name, _write_read2_unlock)(out, src1, src2) ) \ M_ON_EXCEPTION( M_F(name, _write_read2_unlock)(out, src1, src2) ) \
M_CALL_DIV(oplist, out->data, src1->data, src2->data); \ M_CALL_DIV(oplist, out->data, src1->data, src2->data); \
@@ -914,7 +914,7 @@ M_IF_METHOD(SPLICE, oplist)( \
fattr void M_F(name, _splice)(shared_t *out, shared_t *src) \ fattr void M_F(name, _splice)(shared_t *out, shared_t *src) \
{ \ { \
M_ASSERT(out != NULL && src != NULL); \ M_ASSERT(out != NULL && src != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
if (out < src) { \ if (out < src) { \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
M_F(name, _write_lock)(src); \ M_F(name, _write_lock)(src); \
@@ -944,7 +944,7 @@ M_IF_METHOD(GET_KEY, oplist)( \
{ \ { \
M_ASSERT (out != NULL); \ M_ASSERT (out != NULL); \
M_ASSERT (value != NULL); \ M_ASSERT (value != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _read_lock)(out); \ M_F(name, _read_lock)(out); \
/* No exception */ \ /* No exception */ \
value_type *p = M_CALL_GET_KEY(oplist, out->data, key); \ value_type *p = M_CALL_GET_KEY(oplist, out->data, key); \
@@ -961,7 +961,7 @@ M_IF_METHOD(SAFE_GET_KEY, oplist)( \
{ \ { \
M_ASSERT (out != NULL); \ M_ASSERT (out != NULL); \
M_ASSERT (value != NULL); \ M_ASSERT (value != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
M_ON_EXCEPTION( M_F(name, _write_unlock)(out) ) { \ M_ON_EXCEPTION( M_F(name, _write_unlock)(out) ) { \
value_type *p = M_CALL_SAFE_GET_KEY(oplist, out->data, key); \ value_type *p = M_CALL_SAFE_GET_KEY(oplist, out->data, key); \
@@ -977,7 +977,7 @@ M_IF_METHOD(SET_KEY, oplist)( \
fattr void M_F(name, _set_at)(shared_t *out, key_type const key, value_type const value) \ fattr void M_F(name, _set_at)(shared_t *out, key_type const key, value_type const value) \
{ \ { \
M_ASSERT (out != NULL); \ M_ASSERT (out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
M_ON_EXCEPTION( M_F(name, _write_unlock)(out) ) \ M_ON_EXCEPTION( M_F(name, _write_unlock)(out) ) \
M_CALL_SET_KEY(oplist, out->data, key, value); \ M_CALL_SET_KEY(oplist, out->data, key, value); \
@@ -990,7 +990,7 @@ M_IF_METHOD(ERASE_KEY, oplist)( \
fattr bool M_F(name, _erase)(shared_t *out, key_type const key) \ fattr bool M_F(name, _erase)(shared_t *out, key_type const key) \
{ \ { \
M_ASSERT (out != NULL); \ M_ASSERT (out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
/* No exception */ \ /* No exception */ \
bool r = M_CALL_ERASE_KEY(oplist, out->data, key); \ bool r = M_CALL_ERASE_KEY(oplist, out->data, key); \
@@ -1021,7 +1021,7 @@ M_IF_METHOD(PUSH, oplist)( \
fattr void M_F(name, _push)(shared_t *out, sub_type const value) \ fattr void M_F(name, _push)(shared_t *out, sub_type const value) \
{ \ { \
M_ASSERT(out != NULL); \ M_ASSERT(out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
while (true) { \ while (true) { \
if (M_CALL_FULL_P(oplist, out->data) == false) { \ if (M_CALL_FULL_P(oplist, out->data) == false) { \
@@ -1038,7 +1038,7 @@ M_IF_METHOD(PUSH, oplist)( \
fattr bool M_F(name, _try_push)(shared_t *out, sub_type const value) \ fattr bool M_F(name, _try_push)(shared_t *out, sub_type const value) \
{ \ { \
M_ASSERT(out != NULL); \ M_ASSERT(out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
bool ret = false; \ bool ret = false; \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
if (M_CALL_FULL_P(oplist, out->data) == false) { \ if (M_CALL_FULL_P(oplist, out->data) == false) { \
@@ -1055,7 +1055,7 @@ M_IF_METHOD(PUSH_MOVE, oplist)( \
fattr void M_F(name, _push_move)(shared_t *out, sub_type *value) \ fattr void M_F(name, _push_move)(shared_t *out, sub_type *value) \
{ \ { \
M_ASSERT(out != NULL); \ M_ASSERT(out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
while (true) { \ while (true) { \
if (M_CALL_FULL_P(oplist, out->data) == false) { \ if (M_CALL_FULL_P(oplist, out->data) == false) { \
@@ -1072,7 +1072,7 @@ M_IF_METHOD(PUSH_MOVE, oplist)( \
fattr bool M_F(name, _try_push_move)(shared_t *out, sub_type *value) \ fattr bool M_F(name, _try_push_move)(shared_t *out, sub_type *value) \
{ \ { \
M_ASSERT(out != NULL); \ M_ASSERT(out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
bool ret = false; \ bool ret = false; \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
if (M_CALL_FULL_P(oplist, out->data) == false) { \ if (M_CALL_FULL_P(oplist, out->data) == false) { \
@@ -1094,7 +1094,7 @@ M_IF_METHOD(PUSH_MOVE, oplist)( \
fattr void function_name(shared_t *out M_EMPLACE_LIST_TYPE_VAR(a, exp_emplace_type)) \ fattr void function_name(shared_t *out M_EMPLACE_LIST_TYPE_VAR(a, exp_emplace_type)) \
{ \ { \
M_ASSERT(out != NULL); \ M_ASSERT(out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
while (true) { \ while (true) { \
if (M_CALL_FULL_P(oplist, out->data) == false) { \ if (M_CALL_FULL_P(oplist, out->data) == false) { \
@@ -1117,7 +1117,7 @@ fattr void function_name(shared_t *out M_EMPLACE_LIST_TYPE_VAR(a, exp_emplace_ty
fattr bool function_name(shared_t *out M_EMPLACE_LIST_TYPE_VAR(a, exp_emplace_type)) \ fattr bool function_name(shared_t *out M_EMPLACE_LIST_TYPE_VAR(a, exp_emplace_type)) \
{ \ { \
M_ASSERT(out != NULL); \ M_ASSERT(out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
bool ret = false; \ bool ret = false; \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
if (M_CALL_FULL_P(oplist, out->data) == false) { \ if (M_CALL_FULL_P(oplist, out->data) == false) { \
@@ -1146,7 +1146,7 @@ M_IF_METHOD(POP, oplist)( \
fattr void M_F(name, _pop)(sub_type *value, shared_t *out) \ fattr void M_F(name, _pop)(sub_type *value, shared_t *out) \
{ \ { \
M_ASSERT(out != NULL); \ M_ASSERT(out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
while (true) { \ while (true) { \
if (M_CALL_EMPTY_P(oplist, out->data) == false) { \ if (M_CALL_EMPTY_P(oplist, out->data) == false) { \
@@ -1163,7 +1163,7 @@ M_IF_METHOD(POP, oplist)( \
fattr bool M_F(name, _try_pop)(sub_type *value, shared_t *out) \ fattr bool M_F(name, _try_pop)(sub_type *value, shared_t *out) \
{ \ { \
M_ASSERT(out != NULL); \ M_ASSERT(out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
bool ret = false; \ bool ret = false; \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
if (M_CALL_EMPTY_P(oplist, out->data) == false) { \ if (M_CALL_EMPTY_P(oplist, out->data) == false) { \
@@ -1180,7 +1180,7 @@ M_IF_METHOD(POP_MOVE, oplist)( \
fattr void M_F(name, _pop_move)(sub_type *value, shared_t *out) \ fattr void M_F(name, _pop_move)(sub_type *value, shared_t *out) \
{ \ { \
M_ASSERT(out != NULL); \ M_ASSERT(out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
while (true) { \ while (true) { \
if (M_CALL_EMPTY_P(oplist, out->data) == false) { \ if (M_CALL_EMPTY_P(oplist, out->data) == false) { \
@@ -1197,7 +1197,7 @@ M_IF_METHOD(POP_MOVE, oplist)( \
fattr bool M_F(name, _try_pop_move)(sub_type *value, shared_t *out) \ fattr bool M_F(name, _try_pop_move)(sub_type *value, shared_t *out) \
{ \ { \
M_ASSERT(out != NULL); \ M_ASSERT(out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
bool ret = false; \ bool ret = false; \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
if (M_CALL_EMPTY_P(oplist, out->data) == false) { \ if (M_CALL_EMPTY_P(oplist, out->data) == false) { \
@@ -1326,7 +1326,7 @@ M_IF_METHOD(IN_STR, oplist)( \
fattr bool M_F(name, _in_str)(shared_t *out, FILE *file) \ fattr bool M_F(name, _in_str)(shared_t *out, FILE *file) \
{ \ { \
M_ASSERT (out != NULL && file != NULL); \ M_ASSERT (out != NULL && file != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
m_volatile bool r = false; \ m_volatile bool r = false; \
M_ON_EXCEPTION( M_F(name, _write_unlock)(out) ) \ M_ON_EXCEPTION( M_F(name, _write_unlock)(out) ) \
@@ -1341,7 +1341,7 @@ M_IF_METHOD(GET_STR, oplist)( \
fattr void M_F(name, _get_str)(m_string_t str, const shared_t *out, bool append) \ fattr void M_F(name, _get_str)(m_string_t str, const shared_t *out, bool append) \
{ \ { \
M_ASSERT (out != NULL); \ M_ASSERT (out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _read_lock)(out); \ M_F(name, _read_lock)(out); \
M_ON_EXCEPTION( M_F(name, _read_unlock)(out) ) \ M_ON_EXCEPTION( M_F(name, _read_unlock)(out) ) \
M_CALL_GET_STR(oplist, str, out->data, append); \ M_CALL_GET_STR(oplist, str, out->data, append); \
@@ -1352,7 +1352,7 @@ M_IF_METHOD(PARSE_STR, oplist)( \
fattr bool M_F(name, _parse_str)(shared_t *out, const char str[], const char **endp) \ fattr bool M_F(name, _parse_str)(shared_t *out, const char str[], const char **endp) \
{ \ { \
M_ASSERT (out != NULL); \ M_ASSERT (out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
m_volatile bool r = false; \ m_volatile bool r = false; \
M_ON_EXCEPTION( M_F(name, _write_unlock)(out) ) \ M_ON_EXCEPTION( M_F(name, _write_unlock)(out) ) \
@@ -1379,7 +1379,7 @@ M_IF_METHOD(IN_SERIAL, oplist)( \
fattr m_serial_return_code_t M_F(name, _in_serial)(shared_t *out, m_serial_read_t serial) \ fattr m_serial_return_code_t M_F(name, _in_serial)(shared_t *out, m_serial_read_t serial) \
{ \ { \
M_ASSERT (out != NULL); \ M_ASSERT (out != NULL); \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_F(name, _write_lock)(out); \ M_F(name, _write_lock)(out); \
m_volatile m_serial_return_code_t r = M_SERIAL_FAIL; \ m_volatile m_serial_return_code_t r = M_SERIAL_FAIL; \
M_ON_EXCEPTION( M_F(name, _write_unlock)(out) ) \ M_ON_EXCEPTION( M_F(name, _write_unlock)(out) ) \
+5 -5
View File
@@ -201,7 +201,7 @@ M_BEGIN_PROTECTED_CODE
M_P(void, name, _init, snapshot_t snap) \ M_P(void, name, _init, snapshot_t snap) \
{ \ { \
M_ASSERT(snap != NULL); \ M_ASSERT(snap != NULL); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
for(int i = 0; i < M_SNAPSH0T_SPSC_MAX_BUFFER; i++) { \ for(int i = 0; i < M_SNAPSH0T_SPSC_MAX_BUFFER; i++) { \
M_CALL_INIT(oplist, snap->data[i].x); \ M_CALL_INIT(oplist, snap->data[i].x); \
} \ } \
@@ -212,7 +212,7 @@ M_BEGIN_PROTECTED_CODE
M_P(void, name, _clear, snapshot_t snap) \ M_P(void, name, _clear, snapshot_t snap) \
{ \ { \
M_SNAPSH0T_SPSC_CONTRACT(snap); \ M_SNAPSH0T_SPSC_CONTRACT(snap); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
for(int i = 0; i < M_SNAPSH0T_SPSC_MAX_BUFFER; i++) { \ for(int i = 0; i < M_SNAPSH0T_SPSC_MAX_BUFFER; i++) { \
M_CALL_CLEAR(oplist, snap->data[i].x); \ M_CALL_CLEAR(oplist, snap->data[i].x); \
} \ } \
@@ -222,7 +222,7 @@ M_BEGIN_PROTECTED_CODE
M_P(void, name, _init_set, snapshot_t snap, snapshot_t org) \ M_P(void, name, _init_set, snapshot_t snap, snapshot_t org) \
{ \ { \
M_SNAPSH0T_SPSC_CONTRACT(org); \ M_SNAPSH0T_SPSC_CONTRACT(org); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_ASSERT(snap != NULL && snap != org); \ M_ASSERT(snap != NULL && snap != org); \
for(int i = 0; i < M_SNAPSH0T_SPSC_MAX_BUFFER; i++) { \ for(int i = 0; i < M_SNAPSH0T_SPSC_MAX_BUFFER; i++) { \
M_CALL_INIT_SET(oplist, snap->data[i].x, org->data[i].x); \ M_CALL_INIT_SET(oplist, snap->data[i].x, org->data[i].x); \
@@ -236,7 +236,7 @@ M_BEGIN_PROTECTED_CODE
{ \ { \
M_SNAPSH0T_SPSC_CONTRACT(snap); \ M_SNAPSH0T_SPSC_CONTRACT(snap); \
M_SNAPSH0T_SPSC_CONTRACT(org); \ M_SNAPSH0T_SPSC_CONTRACT(org); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
for(int i = 0; i < M_SNAPSH0T_SPSC_MAX_BUFFER; i++) { \ for(int i = 0; i < M_SNAPSH0T_SPSC_MAX_BUFFER; i++) { \
M_CALL_SET(oplist, snap->data[i].x, org->data[i].x); \ M_CALL_SET(oplist, snap->data[i].x, org->data[i].x); \
} \ } \
@@ -264,7 +264,7 @@ M_BEGIN_PROTECTED_CODE
{ \ { \
M_SNAPSH0T_SPSC_CONTRACT(snap); \ M_SNAPSH0T_SPSC_CONTRACT(snap); \
M_SNAPSH0T_SPSC_CONTRACT(org); \ M_SNAPSH0T_SPSC_CONTRACT(org); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_ASSERT(snap != org); \ M_ASSERT(snap != org); \
for(int i = 0; i < M_SNAPSH0T_SPSC_MAX_BUFFER; i++) { \ for(int i = 0; i < M_SNAPSH0T_SPSC_MAX_BUFFER; i++) { \
M_CALL_MOVE(oplist, snap->data[i].x, org->data[i].x); \ M_CALL_MOVE(oplist, snap->data[i].x, org->data[i].x); \
+4 -4
View File
@@ -2106,7 +2106,7 @@ namespace m_lib {
m_lib::m_aligned_string<sizeof (s)>(s).string m_lib::m_aligned_string<sizeof (s)>(s).string
#endif #endif
#ifdef M_USE_POOL #ifdef M_USE_CONTEXT
/* Initialize and set a string to the given formatted value. */ /* Initialize and set a string to the given formatted value. */
#define m_string_init_printf(pool, v, ...) \ #define m_string_init_printf(pool, v, ...) \
(m_string_printf ( pool, m_str1ng_init_ref(v), __VA_ARGS__) ) (m_string_printf ( pool, m_str1ng_init_ref(v), __VA_ARGS__) )
@@ -2138,7 +2138,7 @@ namespace m_lib {
#endif #endif
/* Define the OPLIST of a STRING */ /* Define the OPLIST of a STRING */
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
#define M_STRING_OPLIST \ #define M_STRING_OPLIST \
(INIT(m_string_init),INIT_SET(m_string_init_set), SET(m_string_set), \ (INIT(m_string_init),INIT_SET(m_string_init_set), SET(m_string_set), \
INIT_WITH(M_STR1NG_INIT_WITH), \ INIT_WITH(M_STR1NG_INIT_WITH), \
@@ -2263,7 +2263,7 @@ namespace m_lib {
)(a,b,c) )(a,b,c)
/* Init & Set the string a to the string (or C string) b (constructor) */ /* Init & Set the string a to the string (or C string) b (constructor) */
#ifdef M_USE_POOL #ifdef M_USE_CONTEXT
#define m_string_init_set(p, a,b) \ #define m_string_init_set(p, a,b) \
_Generic((b)+0, \ _Generic((b)+0, \
char*: m_string_init_set_cstr, \ char*: m_string_init_set_cstr, \
@@ -2275,7 +2275,7 @@ namespace m_lib {
#endif #endif
/* Set the string a to the string (or C string) b */ /* Set the string a to the string (or C string) b */
#ifdef M_USE_POOL #ifdef M_USE_CONTEXT
#define m_string_set(p, a,b) \ #define m_string_set(p, a,b) \
_Generic((b)+0, \ _Generic((b)+0, \
char*: m_string_set_cstr, \ char*: m_string_set_cstr, \
+2 -2
View File
@@ -217,7 +217,7 @@ typedef int32_t m_tr33_index_t;
\ \
M_P(void, name, _reset, tree_t tree) { \ M_P(void, name, _reset, tree_t tree) { \
M_TR33_CONTRACT(tree); \ M_TR33_CONTRACT(tree); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
if (tree->size > 0) { \ if (tree->size > 0) { \
/* We don't scan recursively the node tree, but sequentially */ \ /* We don't scan recursively the node tree, but sequentially */ \
m_tr33_index_t free_index = tree->free_index; \ m_tr33_index_t free_index = tree->free_index; \
@@ -863,7 +863,7 @@ typedef int32_t m_tr33_index_t;
\ \
M_P(bool, name, _remove, it_t it) { \ M_P(bool, name, _remove, it_t it) { \
M_TR33_IT_CONTRACT(it, false); \ M_TR33_IT_CONTRACT(it, false); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
if (M_UNLIKELY(it.index < 0)) { return false; } \ if (M_UNLIKELY(it.index < 0)) { return false; } \
type *ptr = M_F(name, _unlink)(it); \ type *ptr = M_F(name, _unlink)(it); \
M_CALL_CLEAR(oplist, *ptr); \ M_CALL_CLEAR(oplist, *ptr); \
+14 -14
View File
@@ -244,7 +244,7 @@ namespace m_lib {
/* Define the INIT method calling the INIT method for all params */ /* Define the INIT method calling the INIT method for all params */
#define M_TUPL3_DEFINE_INIT(name, ...) \ #define M_TUPL3_DEFINE_INIT(name, ...) \
M_P(void, name, _init, M_F(name,_ct) my) { \ M_P(void, name, _init, M_F(name,_ct) my) { \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_MAP(M_TUPL3_DEFINE_INIT_FUNC , __VA_ARGS__) {} \ M_MAP(M_TUPL3_DEFINE_INIT_FUNC , __VA_ARGS__) {} \
} }
@@ -255,7 +255,7 @@ namespace m_lib {
#define M_TUPL3_DEFINE_INIT_SET(name, ...) \ #define M_TUPL3_DEFINE_INIT_SET(name, ...) \
M_P(void, name, _init_set, M_F(name,_ct) my , M_F(name,_ct) const org) { \ M_P(void, name, _init_set, M_F(name,_ct) my , M_F(name,_ct) const org) { \
M_TUPL3_CONTRACT(org); \ M_TUPL3_CONTRACT(org); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_MAP(M_TUPL3_DEFINE_INIT_SET_FUNC , __VA_ARGS__) {} \ M_MAP(M_TUPL3_DEFINE_INIT_SET_FUNC , __VA_ARGS__) {} \
} }
#define M_TUPL3_DEFINE_INIT_SET_FUNC(a) \ #define M_TUPL3_DEFINE_INIT_SET_FUNC(a) \
@@ -265,7 +265,7 @@ namespace m_lib {
/* Define the INIT_WITH method calling the INIT_SET method for all params. */ /* Define the INIT_WITH method calling the INIT_SET method for all params. */
#define M_TUPL3_DEFINE_INIT_SET2(name, ...) \ #define M_TUPL3_DEFINE_INIT_SET2(name, ...) \
M_P(void, name, _init_emplace, M_F(name,_ct) my M_MAP(M_TUPL3_DEFINE_SET2_PROTO, __VA_ARGS__) ) { \ M_P(void, name, _init_emplace, M_F(name,_ct) my M_MAP(M_TUPL3_DEFINE_SET2_PROTO, __VA_ARGS__) ) { \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_MAP(M_TUPL3_DEFINE_INIT_SET2_FUNC , __VA_ARGS__) {} \ M_MAP(M_TUPL3_DEFINE_INIT_SET2_FUNC , __VA_ARGS__) {} \
} }
@@ -279,7 +279,7 @@ namespace m_lib {
M_P(void, name, _set, M_F(name,_ct) my, M_F(name,_ct) const org) { \ M_P(void, name, _set, M_F(name,_ct) my, M_F(name,_ct) const org) { \
M_TUPL3_CONTRACT(my); \ M_TUPL3_CONTRACT(my); \
M_TUPL3_CONTRACT(org); \ M_TUPL3_CONTRACT(org); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_MAP(M_TUPL3_DEFINE_SET_FUNC , __VA_ARGS__) \ M_MAP(M_TUPL3_DEFINE_SET_FUNC , __VA_ARGS__) \
} }
@@ -291,7 +291,7 @@ namespace m_lib {
#define M_TUPL3_DEFINE_SET2(name, ...) \ #define M_TUPL3_DEFINE_SET2(name, ...) \
M_P(void, name, _emplace, M_F(name,_ct) my M_MAP(M_TUPL3_DEFINE_SET2_PROTO, __VA_ARGS__) ) { \ M_P(void, name, _emplace, M_F(name,_ct) my M_MAP(M_TUPL3_DEFINE_SET2_PROTO, __VA_ARGS__) ) { \
M_TUPL3_CONTRACT(my); \ M_TUPL3_CONTRACT(my); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_MAP(M_TUPL3_DEFINE_SET2_FUNC , __VA_ARGS__) \ M_MAP(M_TUPL3_DEFINE_SET2_FUNC , __VA_ARGS__) \
} }
#define M_TUPL3_DEFINE_SET2_PROTO(a) \ #define M_TUPL3_DEFINE_SET2_PROTO(a) \
@@ -305,7 +305,7 @@ namespace m_lib {
#define M_TUPL3_DEFINE_CLEAR(name, ...) \ #define M_TUPL3_DEFINE_CLEAR(name, ...) \
M_P(void, name, _clear, M_F(name,_ct) my) { \ M_P(void, name, _clear, M_F(name,_ct) my) { \
M_TUPL3_CONTRACT(my); \ M_TUPL3_CONTRACT(my); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_MAP(M_TUPL3_DEFINE_CLEAR_FUNC , __VA_ARGS__) \ M_MAP(M_TUPL3_DEFINE_CLEAR_FUNC , __VA_ARGS__) \
} }
@@ -343,7 +343,7 @@ namespace m_lib {
M_INLINE void M_C3(name, _set_, M_TUPL3_GET_FIELD a) \ M_INLINE void M_C3(name, _set_, M_TUPL3_GET_FIELD a) \
(M_P_EXPAND M_F(name,_ct) my, M_TUPL3_GET_TYPE a const M_TUPL3_GET_FIELD a) { \ (M_P_EXPAND M_F(name,_ct) my, M_TUPL3_GET_TYPE a const M_TUPL3_GET_FIELD a) { \
M_TUPL3_CONTRACT(my); \ M_TUPL3_CONTRACT(my); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_TUPL3_CALL_SET(a, my ->M_TUPL3_GET_FIELD a, M_TUPL3_GET_FIELD a); \ M_TUPL3_CALL_SET(a, my ->M_TUPL3_GET_FIELD a, M_TUPL3_GET_FIELD a); \
} }
@@ -362,7 +362,7 @@ namespace m_lib {
function_name(M_P_EXPAND name_t v \ function_name(M_P_EXPAND name_t v \
M_EMPLACE_LIST_TYPE_VAR(a, exp_emplace_type) ) \ M_EMPLACE_LIST_TYPE_VAR(a, exp_emplace_type) ) \
{ \ { \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_CALL_CLEAR(oplist, v->name); \ M_CALL_CLEAR(oplist, v->name); \
M_EMPLACE_CALL_FUNC(a, init_func, oplist, v->name, exp_emplace_type); \ M_EMPLACE_CALL_FUNC(a, init_func, oplist, v->name, exp_emplace_type); \
} }
@@ -508,7 +508,7 @@ namespace m_lib {
{ \ { \
bool comma = false; \ bool comma = false; \
M_TUPL3_CONTRACT(el); \ M_TUPL3_CONTRACT(el); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_ASSERT (f != NULL); \ M_ASSERT (f != NULL); \
int c = fgetc(f); \ int c = fgetc(f); \
if (c != '(') return false; \ if (c != '(') return false; \
@@ -533,7 +533,7 @@ namespace m_lib {
{ \ { \
M_TUPL3_CONTRACT(el); \ M_TUPL3_CONTRACT(el); \
M_ASSERT (str != NULL); \ M_ASSERT (str != NULL); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
bool success = false; \ bool success = false; \
bool comma = false; \ bool comma = false; \
int c = *str++; \ int c = *str++; \
@@ -592,7 +592,7 @@ namespace m_lib {
M_P(m_serial_return_code_t, name, _in_serial, M_F(name,_ct) el, m_serial_read_t f) \ M_P(m_serial_return_code_t, name, _in_serial, M_F(name,_ct) el, m_serial_read_t f) \
{ \ { \
M_TUPL3_CONTRACT(el); \ M_TUPL3_CONTRACT(el); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_ASSERT (f != NULL && f->m_interface != NULL); \ M_ASSERT (f != NULL && f->m_interface != NULL); \
int index = -1; \ int index = -1; \
const int field_max = M_NARGS(__VA_ARGS__); \ const int field_max = M_NARGS(__VA_ARGS__); \
@@ -637,7 +637,7 @@ namespace m_lib {
#define M_TUPL3_DEFINE_MOVE(name, ...) \ #define M_TUPL3_DEFINE_MOVE(name, ...) \
M_P(void, name, _move, M_F(name,_ct) el, M_F(name,_ct) org) { \ M_P(void, name, _move, M_F(name,_ct) el, M_F(name,_ct) org) { \
M_TUPL3_CONTRACT(el); \ M_TUPL3_CONTRACT(el); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_MAP(M_TUPL3_DEFINE_MOVE_FUNC , __VA_ARGS__) \ M_MAP(M_TUPL3_DEFINE_MOVE_FUNC , __VA_ARGS__) \
} }
@@ -661,7 +661,7 @@ namespace m_lib {
#define M_TUPL3_DEFINE_RESET(name, ...) \ #define M_TUPL3_DEFINE_RESET(name, ...) \
M_P(void, name, _reset, M_F(name,_ct) el1) { \ M_P(void, name, _reset, M_F(name,_ct) el1) { \
M_TUPL3_CONTRACT(el1); \ M_TUPL3_CONTRACT(el1); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
M_MAP(M_TUPL3_DEFINE_RESET_FUNC , __VA_ARGS__) \ M_MAP(M_TUPL3_DEFINE_RESET_FUNC , __VA_ARGS__) \
} \ } \
@@ -746,7 +746,7 @@ namespace m_lib {
((M_LIB_ERROR(ONE_ARGUMENT_OF_M_TUPL3_OPLIST_IS_NOT_AN_OPLIST, name, __VA_ARGS__))) ((M_LIB_ERROR(ONE_ARGUMENT_OF_M_TUPL3_OPLIST_IS_NOT_AN_OPLIST, name, __VA_ARGS__)))
/* Define the TUPLE oplist */ /* Define the TUPLE oplist */
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
#define M_TUPL3_OPLIST_P3(name, ...) \ #define M_TUPL3_OPLIST_P3(name, ...) \
(M_IF_METHOD_ALL(INIT, __VA_ARGS__)(INIT(M_F(name,_init)),), \ (M_IF_METHOD_ALL(INIT, __VA_ARGS__)(INIT(M_F(name,_init)),), \
INIT_SET(M_F(name, _init_set)), \ INIT_SET(M_F(name, _init_set)), \
+6 -6
View File
@@ -227,7 +227,7 @@
M_P(void, name, _init_set, M_F(name,_ct) my, M_F(name,_ct) const org) \ M_P(void, name, _init_set, M_F(name,_ct) my, M_F(name,_ct) const org) \
{ \ { \
M_VAR1ANT_CONTRACT(name, org); \ M_VAR1ANT_CONTRACT(name, org); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
my->type = org->type; \ my->type = org->type; \
switch (org->type) { \ switch (org->type) { \
M_MAP2(M_VAR1ANT_DEFINE_INIT_SET_FUNC, name, __VA_ARGS__) \ M_MAP2(M_VAR1ANT_DEFINE_INIT_SET_FUNC, name, __VA_ARGS__) \
@@ -278,7 +278,7 @@
M_P(void, name, _clear, M_F(name,_ct) my) \ M_P(void, name, _clear, M_F(name,_ct) my) \
{ \ { \
M_VAR1ANT_CONTRACT(name, my); \ M_VAR1ANT_CONTRACT(name, my); \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
switch (my->type) { \ switch (my->type) { \
M_MAP2(M_VAR1ANT_DEFINE_CLEAR_FUNC, name, __VA_ARGS__) \ M_MAP2(M_VAR1ANT_DEFINE_CLEAR_FUNC, name, __VA_ARGS__) \
case M_F(name, _EMPTY): /* fallthrough */ \ case M_F(name, _EMPTY): /* fallthrough */ \
@@ -322,7 +322,7 @@
M_INLINE void \ M_INLINE void \
M_C3(name, _init_, M_VAR1ANT_GET_FIELD a)(M_P_EXPAND M_F(name,_ct) my) \ M_C3(name, _init_, M_VAR1ANT_GET_FIELD a)(M_P_EXPAND M_F(name,_ct) my) \
{ \ { \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
/* Reinit variable with the given value */ \ /* Reinit variable with the given value */ \
my->type = M_C4(name, _, M_VAR1ANT_GET_FIELD a, _value); \ my->type = M_C4(name, _, M_VAR1ANT_GET_FIELD a, _value); \
M_VAR1ANT_CALL_INIT(a, my -> value. M_VAR1ANT_GET_FIELD a); \ M_VAR1ANT_CALL_INIT(a, my -> value. M_VAR1ANT_GET_FIELD a); \
@@ -337,7 +337,7 @@
M_INLINE void \ M_INLINE void \
M_C3(name, _init_set_, M_VAR1ANT_GET_FIELD a)(M_P_EXPAND M_F(name,_ct) my, M_VAR1ANT_GET_TYPE a const M_VAR1ANT_GET_FIELD a) \ M_C3(name, _init_set_, M_VAR1ANT_GET_FIELD a)(M_P_EXPAND M_F(name,_ct) my, M_VAR1ANT_GET_TYPE a const M_VAR1ANT_GET_FIELD a) \
{ \ { \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
my->type = M_C4(name, _, M_VAR1ANT_GET_FIELD a, _value); \ my->type = M_C4(name, _, M_VAR1ANT_GET_FIELD a, _value); \
M_VAR1ANT_CALL_INIT_SET(a, my -> value. M_VAR1ANT_GET_FIELD a, \ M_VAR1ANT_CALL_INIT_SET(a, my -> value. M_VAR1ANT_GET_FIELD a, \
M_VAR1ANT_GET_FIELD a); \ M_VAR1ANT_GET_FIELD a); \
@@ -345,7 +345,7 @@
M_INLINE void \ M_INLINE void \
M_C4(m_var1ant_, name, _init_set_, num)(M_P_EXPAND M_F(name,_ct) my, M_VAR1ANT_GET_TYPE a const M_VAR1ANT_GET_FIELD a) \ M_C4(m_var1ant_, name, _init_set_, num)(M_P_EXPAND M_F(name,_ct) my, M_VAR1ANT_GET_TYPE a const M_VAR1ANT_GET_FIELD a) \
{ \ { \
M_ASSERT_POOL(); \ M_UNUSED_CONTEXT(); \
my->type = M_C4(name, _, M_VAR1ANT_GET_FIELD a, _value); \ my->type = M_C4(name, _, M_VAR1ANT_GET_FIELD a, _value); \
M_VAR1ANT_CALL_INIT_SET(a, my -> value. M_VAR1ANT_GET_FIELD a, \ M_VAR1ANT_CALL_INIT_SET(a, my -> value. M_VAR1ANT_GET_FIELD a, \
M_VAR1ANT_GET_FIELD a); \ M_VAR1ANT_GET_FIELD a); \
@@ -775,7 +775,7 @@ M_INLINE void \
((M_LIB_ERROR(ONE_ARGUMENT_OF_VARIANT_OPLIST_IS_NOT_AN_OPLIST, name, __VA_ARGS__))) ((M_LIB_ERROR(ONE_ARGUMENT_OF_VARIANT_OPLIST_IS_NOT_AN_OPLIST, name, __VA_ARGS__)))
/* Define the oplist */ /* Define the oplist */
#ifndef M_USE_POOL #ifndef M_USE_CONTEXT
#define M_VAR1ANT_OPLIST_P3(name, ...) \ #define M_VAR1ANT_OPLIST_P3(name, ...) \
(INIT(M_F(name,_init)), \ (INIT(M_F(name,_init)), \
INIT_SET(M_F(name, _init_set)), \ INIT_SET(M_F(name, _init_set)), \
+9 -9
View File
@@ -234,7 +234,7 @@ typedef struct m_worker_sync_s {
M_INLINE void \ M_INLINE void \
M_C3(m_work3r_, name, _clear)(struct M_C3(m_worker_, name, _s) *p) \ M_C3(m_work3r_, name, _clear)(struct M_C3(m_worker_, name, _s) *p) \
{ \ { \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
M_MAP3(M_WORK3R_SPAWN_EXTEND_DEF_CALLBACK_CLEAR, data, __VA_ARGS__) \ M_MAP3(M_WORK3R_SPAWN_EXTEND_DEF_CALLBACK_CLEAR, data, __VA_ARGS__) \
/* TODO: Overload */ \ /* TODO: Overload */ \
M_MEMORY_DEL(p); \ M_MEMORY_DEL(p); \
@@ -263,7 +263,7 @@ typedef struct m_worker_sync_s {
M_MAP3_C(M_WORK3R_SPAWN_EXTEND_DEF_EMPLACE_FIELD, data, __VA_ARGS__) \ M_MAP3_C(M_WORK3R_SPAWN_EXTEND_DEF_EMPLACE_FIELD, data, __VA_ARGS__) \
) \ ) \
{ \ { \
M_GLOBAL_POOL(); \ M_GLOBAL_CONTEXT(); \
if (!m_work3r_queue_full_p(block->worker->queue_g)) { \ if (!m_work3r_queue_full_p(block->worker->queue_g)) { \
struct M_C3(m_worker_, name, _s) *p = M_MEMORY_ALLOC ( struct M_C3(m_worker_, name, _s)); \ struct M_C3(m_worker_, name, _s) *p = M_MEMORY_ALLOC ( struct M_C3(m_worker_, name, _s)); \
if (M_UNLIKELY_NOMEM(p == NULL)) { \ if (M_UNLIKELY_NOMEM(p == NULL)) { \
@@ -362,7 +362,7 @@ m_work3r_thread(void *arg)
{ {
// Get back the given argument // Get back the given argument
struct m_worker_s *g = M_ASSIGN_CAST(struct m_worker_s *, arg); struct m_worker_s *g = M_ASSIGN_CAST(struct m_worker_s *, arg);
M_GLOBAL_POOL(); M_GLOBAL_CONTEXT();
while (true) { while (true) {
m_work3r_order_ct w; m_work3r_order_ct w;
// If needed, reset the global state of the worker // If needed, reset the global state of the worker
@@ -411,7 +411,7 @@ m_worker_init(m_worker_t g, int numWorker, unsigned int extraQueue, void (*reset
// numWorker can still be 0 if it is a single core cpu (no worker available) // numWorker can still be 0 if it is a single core cpu (no worker available)
M_ASSERT(numWorker >= 0); M_ASSERT(numWorker >= 0);
size_t numWorker_st = (size_t) numWorker; size_t numWorker_st = (size_t) numWorker;
M_GLOBAL_POOL(); M_GLOBAL_CONTEXT();
g->worker = M_MEMORY_REALLOC(m_work3r_thread_ct, NULL, 0, numWorker_st); g->worker = M_MEMORY_REALLOC(m_work3r_thread_ct, NULL, 0, numWorker_st);
if (M_UNLIKELY_NOMEM (g->worker == NULL)) { if (M_UNLIKELY_NOMEM (g->worker == NULL)) {
M_MEMORY_FULL(m_work3r_thread_ct, numWorker_st); M_MEMORY_FULL(m_work3r_thread_ct, numWorker_st);
@@ -443,7 +443,7 @@ M_INLINE void
m_worker_clear(m_worker_t g) m_worker_clear(m_worker_t g)
{ {
M_ASSERT (m_work3r_queue_empty_p (g->queue_g)); M_ASSERT (m_work3r_queue_empty_p (g->queue_g));
M_GLOBAL_POOL(); M_GLOBAL_CONTEXT();
// Push the terminate order on the queue // Push the terminate order on the queue
for(unsigned int i = 0; i < g->numWorker_g; i++) { for(unsigned int i = 0; i < g->numWorker_g; i++) {
m_work3r_order_ct w = M_WORK3R_EMPTY_ORDER; m_work3r_order_ct w = M_WORK3R_EMPTY_ORDER;
@@ -482,7 +482,7 @@ M_INLINE void
m_worker_spawn(m_worker_sync_t block, void (*func)(void *data), void *data) m_worker_spawn(m_worker_sync_t block, void (*func)(void *data), void *data)
{ {
const m_work3r_order_ct w = { block, data, func M_WORK3R_EXTRA_ORDER }; const m_work3r_order_ct w = { block, data, func M_WORK3R_EXTRA_ORDER };
M_GLOBAL_POOL(); M_GLOBAL_CONTEXT();
if (M_UNLIKELY (!m_work3r_queue_full_p(block->worker->queue_g)) if (M_UNLIKELY (!m_work3r_queue_full_p(block->worker->queue_g))
&& m_work3r_queue_push_blocking (block->worker->queue_g, w, false) == true) { && m_work3r_queue_push_blocking (block->worker->queue_g, w, false) == true) {
M_WORK3R_DEBUG ("Sending data to thread: %p (block: %d / %d)\n", data, block->num_spawn, block->num_terminated_spawn); M_WORK3R_DEBUG ("Sending data to thread: %p (block: %d / %d)\n", data, block->num_spawn, block->num_terminated_spawn);
@@ -501,7 +501,7 @@ M_INLINE void
m_work3r_spawn_block(m_worker_sync_t block, void (^func)(void *data), void *data) m_work3r_spawn_block(m_worker_sync_t block, void (^func)(void *data), void *data)
{ {
const m_work3r_order_ct w = { block, data, NULL, func }; const m_work3r_order_ct w = { block, data, NULL, func };
M_GLOBAL_POOL(); M_GLOBAL_CONTEXT();
if (M_UNLIKELY (!m_work3r_queue_full_p(block->worker->queue_g)) if (M_UNLIKELY (!m_work3r_queue_full_p(block->worker->queue_g))
&& m_work3r_queue_push_blocking (block->worker->queue_g, w, false) == true) { && m_work3r_queue_push_blocking (block->worker->queue_g, w, false) == true) {
M_WORK3R_DEBUG ("Sending data to thread as block: %p (block: %d / %d)\n", data, block->num_spawn, block->num_terminated_spawn); M_WORK3R_DEBUG ("Sending data to thread as block: %p (block: %d / %d)\n", data, block->num_spawn, block->num_terminated_spawn);
@@ -521,7 +521,7 @@ M_INLINE void
m_work3r_spawn_function(m_worker_sync_t block, std::function<void(void *data)> func, void *data) m_work3r_spawn_function(m_worker_sync_t block, std::function<void(void *data)> func, void *data)
{ {
const m_work3r_order_ct w = { block, data, NULL, func }; const m_work3r_order_ct w = { block, data, NULL, func };
M_GLOBAL_POOL(); M_GLOBAL_CONTEXT();
if (M_UNLIKELY (!m_work3r_queue_full_p(block->worker->queue_g)) if (M_UNLIKELY (!m_work3r_queue_full_p(block->worker->queue_g))
&& m_work3r_queue_push_blocking (block->worker->queue_g, w, false) == true) { && m_work3r_queue_push_blocking (block->worker->queue_g, w, false) == true) {
M_WORK3R_DEBUG ("Sending data to thread as block: %p (block: %d / %d)\n", data, block->num_spawn, block->num_terminated_spawn); M_WORK3R_DEBUG ("Sending data to thread as block: %p (block: %d / %d)\n", data, block->num_spawn, block->num_terminated_spawn);
@@ -564,7 +564,7 @@ M_INLINE void
m_worker_flush(m_worker_t g) m_worker_flush(m_worker_t g)
{ {
m_work3r_order_ct w; m_work3r_order_ct w;
M_GLOBAL_POOL(); M_GLOBAL_CONTEXT();
while (m_work3r_queue_pop_blocking (&w, g->queue_g, false) == true) { while (m_work3r_queue_pop_blocking (&w, g->queue_g, false) == true) {
m_work3r_exec(&w); m_work3r_exec(&w);
m_work3r_queue_pop_release(g->queue_g); m_work3r_queue_pop_release(g->queue_g);