diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-04-29 12:39:44 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-04-29 12:39:44 +0000 |
commit | a4283e0d49d6a527d84fb5be020f75cecfda4edc (patch) | |
tree | ef5d28666b539fd2e64aa04bb89f4046c7d65ed7 /os/kernel | |
parent | c670c00668799feea3ec8f6c637b730b1c559e6e (diff) | |
download | ChibiOS-a4283e0d49d6a527d84fb5be020f75cecfda4edc.tar.gz ChibiOS-a4283e0d49d6a527d84fb5be020f75cecfda4edc.tar.bz2 ChibiOS-a4283e0d49d6a527d84fb5be020f75cecfda4edc.zip |
Memory Pools improvement.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4146 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel')
-rw-r--r-- | os/kernel/include/chmempools.h | 2 | ||||
-rw-r--r-- | os/kernel/src/chmempools.c | 19 |
2 files changed, 10 insertions, 11 deletions
diff --git a/os/kernel/include/chmempools.h b/os/kernel/include/chmempools.h index a920e2579..c7624cd73 100644 --- a/os/kernel/include/chmempools.h +++ b/os/kernel/include/chmempools.h @@ -60,7 +60,7 @@ typedef struct { * @param[in] provider memory provider function for the memory pool
*/
#define _MEMORYPOOL_DATA(name, size, provider) \
- {NULL, MEM_ALIGN_NEXT(size), provider}
+ {NULL, size, provider}
/**
* @brief Static memory pool initializer in hungry mode.
diff --git a/os/kernel/src/chmempools.c b/os/kernel/src/chmempools.c index 8ef5cc403..21d205fc8 100644 --- a/os/kernel/src/chmempools.c +++ b/os/kernel/src/chmempools.c @@ -27,7 +27,10 @@ * <h2>Operation mode</h2>
* The Memory Pools APIs allow to allocate/free fixed size objects in
* <b>constant time</b> and reliably without memory fragmentation
- * problems.
+ * problems.<br>
+ * Memory Pools do not enforce any alignment constraint on the
+ * contained object however the objects must be properly aligned
+ * to contain a pointer to void.
* @pre In order to use the memory pools APIs the @p CH_USE_MEMPOOLS option
* must be enabled in @p chconf.h.
* @{
@@ -56,7 +59,7 @@ void chPoolInit(MemoryPool *mp, size_t size, memgetfunc_t provider) { chDbgCheck((mp != NULL) && (size >= sizeof(void *)), "chPoolInit");
mp->mp_next = NULL;
- mp->mp_object_size = MEM_ALIGN_NEXT(size);
+ mp->mp_object_size = size;
mp->mp_provider = provider;
}
@@ -75,8 +78,7 @@ void chPoolInit(MemoryPool *mp, size_t size, memgetfunc_t provider) { */
void chPoolLoadArray(MemoryPool *mp, void *p, size_t n) {
- chDbgCheck((mp != NULL) && MEM_IS_ALIGNED(p) && (n != 0),
- "chPoolLoadArray");
+ chDbgCheck((mp != NULL) && (n != 0), "chPoolLoadArray");
while (n) {
chPoolAdd(mp, p);
@@ -132,8 +134,7 @@ void *chPoolAlloc(MemoryPool *mp) { * @pre The memory pool must be already been initialized.
* @pre The freed object must be of the right size for the specified
* memory pool.
- * @pre The freed object must be memory aligned to the size of
- * @p stkalign_t type.
+ * @pre The object must be properly aligned to contain a pointer to void.
*
* @param[in] mp pointer to a @p MemoryPool structure
* @param[in] objp the pointer to the object to be released
@@ -144,8 +145,7 @@ void chPoolFreeI(MemoryPool *mp, void *objp) { struct pool_header *php = objp;
chDbgCheckClassI();
- chDbgCheck((mp != NULL) && (objp != NULL) && MEM_IS_ALIGNED(objp),
- "chPoolFreeI");
+ chDbgCheck((mp != NULL) && (objp != NULL), "chPoolFreeI");
php->ph_next = mp->mp_next;
mp->mp_next = php;
@@ -156,8 +156,7 @@ void chPoolFreeI(MemoryPool *mp, void *objp) { * @pre The memory pool must be already been initialized.
* @pre The freed object must be of the right size for the specified
* memory pool.
- * @pre The freed object must be memory aligned to the size of
- * @p stkalign_t type.
+ * @pre The object must be properly aligned to contain a pointer to void.
*
* @param[in] mp pointer to a @p MemoryPool structure
* @param[in] objp the pointer to the object to be released
|