Port to new memory model (add global context 0)
This commit is contained in:
1 parent
8069fae3d5
commit
10d918bbc9
3 files changed
+40
-9
No files matched your search
@@ -413,6 +413,21 @@ M_BEGIN_PROTECTED_CODE
|
||||
|
||||
|
||||
// FIXME: Rename to M_USE_MEMORY_CONTEXT?
|
||||
/* In order to support context for memory functions, the prototypes and usages of some functions are modified
|
||||
* so that they accept a first argument 'm_pool' which is the 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 such cases, the memory context parameter is not requested to
|
||||
* the used but set to 0.
|
||||
* several macros are defined **globally**. Theses macros expand to nothing if memory context 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_void: same but assume that there is no argument
|
||||
* * M_R_EXPAND: expand to the first parameter 'm_pool'
|
||||
* * 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_P: define the prototype of a function that may have the parameter m_pool.
|
||||
* * M_ASSERT_POOL: avoid warning of unused m_pool argument
|
||||
* * M_GLOBAL_POOL: define m_pool to zero, meaning it is a global memory context.
|
||||
*/
|
||||
#ifndef M_USE_POOL
|
||||
// Memory pool parameter not used for memory function. Stub it with 0 as it won't be used (global definition).
|
||||
# define M_P_EXPAND
|
||||
@@ -421,6 +436,7 @@ M_BEGIN_PROTECTED_CODE
|
||||
# define M_R_EXPAND_void
|
||||
# define M_R
|
||||
# define M_ASSERT_POOL()
|
||||
# define M_GLOBAL_POOL()
|
||||
#else
|
||||
// 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
|
||||
@@ -430,6 +446,7 @@ M_BEGIN_PROTECTED_CODE
|
||||
# define M_R_EXPAND_void m_pool
|
||||
# define M_R(...) (m_pool, __VA_ARGS__)
|
||||
# define M_ASSERT_POOL() (void) m_pool
|
||||
# define M_GLOBAL_POOL() M_USE_POOL m_pool = { 0 }
|
||||
#endif
|
||||
|
||||
// M_P: Expand to a prototype of a function that may trigger exception / accept memory context
|
||||
|
||||
Reference in new issue
Block a user