aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/mempools.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/mempools.h')
-rw-r--r--src/include/mempools.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/include/mempools.h b/src/include/mempools.h
index 537ca3425..38e54b3d8 100644
--- a/src/include/mempools.h
+++ b/src/include/mempools.h
@@ -44,6 +44,25 @@ typedef struct {
size_t mp_object_size; /**< Memory pool objects size.*/
} MemoryPool;
+/**
+ * @brief Data part of a static memory pool initializer.
+ * @details This macro should be used when statically initializing a
+ * memory pool that is part of a bigger structure.
+ * @param name the name of the memory pool variable
+ * @param size size of the memory pool contained objects
+ */
+#define _MEMORYPOOL_DATA(name, size) {NULL, size}
+
+/**
+ * @brief Static memory pool initializer.
+ * @details Statically initialized memory pools require no explicit
+ * initialization using @p chPoolInit().
+ * @param name the name of the memory pool variable
+ * @param size size of the memory pool contained objects
+ */
+#define MEMORYPOOL_DECL(name, size) \
+ MemoryPool name = _MEMORYPOOL_DATA(name, size)
+
#ifdef __cplusplus
extern "C" {
#endif