aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel/include/chmempools.h
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-07-19 14:51:35 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-07-19 14:51:35 +0000
commit25ddb1c801f06a3be7171e20dcfd46d11a75f112 (patch)
tree8a9cc02a0a62649b44821817b96a6c148ddfc9f8 /os/kernel/include/chmempools.h
parentd58064a533743df77e52f9d76385a9e0ea1d0227 (diff)
downloadChibiOS-25ddb1c801f06a3be7171e20dcfd46d11a75f112.tar.gz
ChibiOS-25ddb1c801f06a3be7171e20dcfd46d11a75f112.tar.bz2
ChibiOS-25ddb1c801f06a3be7171e20dcfd46d11a75f112.zip
First cleanup pass finished, queues and streams not yet removed.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5999 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel/include/chmempools.h')
-rw-r--r--os/kernel/include/chmempools.h83
1 files changed, 59 insertions, 24 deletions
diff --git a/os/kernel/include/chmempools.h b/os/kernel/include/chmempools.h
index 80d6eeaf2..f211ec1d1 100644
--- a/os/kernel/include/chmempools.h
+++ b/os/kernel/include/chmempools.h
@@ -31,6 +31,26 @@
#if CH_USE_MEMPOOLS || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+#if !CH_USE_MEMCORE
+#error "CH_USE_MEMPOOLS requires CH_USE_MEMCORE"
+#endif
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
/**
* @brief Memory pool free object header.
*/
@@ -46,9 +66,13 @@ typedef struct {
struct pool_header *mp_next; /**< @brief Pointer to the header. */
size_t mp_object_size; /**< @brief Memory pool objects
size. */
- memgetfunc_t mp_provider; /**< @brief Memory blocks provider for
- this pool. */
-} MemoryPool;
+ memgetfunc_t mp_provider; /**< @brief Memory blocks provider
+ for this pool. */
+} memory_pool_t;
+
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
/**
* @brief Data part of a static memory pool initializer.
@@ -73,12 +97,29 @@ typedef struct {
* if the pool is not allowed to grow automatically
*/
#define MEMORYPOOL_DECL(name, size, provider) \
- MemoryPool name = _MEMORYPOOL_DATA(name, size, provider)
+ memory_pool_t name = _MEMORYPOOL_DATA(name, size, provider)
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void chPoolInit(memory_pool_t *mp, size_t size, memgetfunc_t provider);
+ void chPoolLoadArray(memory_pool_t *mp, void *p, size_t n);
+ void *chPoolAllocI(memory_pool_t *mp);
+ void *chPoolAlloc(memory_pool_t *mp);
+ void chPoolFreeI(memory_pool_t *mp, void *objp);
+ void chPoolFree(memory_pool_t *mp, void *objp);
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
-/**
- * @name Macro Functions
- * @{
- */
/**
* @brief Adds an object to a memory pool.
* @pre The memory pool must be already been initialized.
@@ -89,12 +130,15 @@ typedef struct {
* @note This function is just an alias for @p chPoolFree() and has been
* added for clarity.
*
- * @param[in] mp pointer to a @p MemoryPool structure
+ * @param[in] mp pointer to a @p memory_pool_t structure
* @param[in] objp the pointer to the object to be added
*
* @api
*/
-#define chPoolAdd(mp, objp) chPoolFree(mp, objp)
+static inline void chPoolAdd(memory_pool_t *mp, void *objp) {
+
+ chPoolFree(mp, objp);
+}
/**
* @brief Adds an object to a memory pool.
@@ -106,26 +150,17 @@ typedef struct {
* @note This function is just an alias for @p chPoolFree() and has been
* added for clarity.
*
- * @param[in] mp pointer to a @p MemoryPool structure
+ * @param[in] mp pointer to a @p memory_pool_t structure
* @param[in] objp the pointer to the object to be added
*
* @iclass
*/
-#define chPoolAddI(mp, objp) chPoolFreeI(mp, objp)
-/** @} */
+static inline void chPoolAddI(memory_pool_t *mp, void *objp) {
-#ifdef __cplusplus
-extern "C" {
-#endif
- void chPoolInit(MemoryPool *mp, size_t size, memgetfunc_t provider);
- void chPoolLoadArray(MemoryPool *mp, void *p, size_t n);
- void *chPoolAllocI(MemoryPool *mp);
- void *chPoolAlloc(MemoryPool *mp);
- void chPoolFreeI(MemoryPool *mp, void *objp);
- void chPoolFree(MemoryPool *mp, void *objp);
-#ifdef __cplusplus
+ chDbgCheckClassI();
+
+ chPoolFreeI(mp, objp);
}
-#endif
#endif /* CH_USE_MEMPOOLS */