From 24594525990ee1769ee933261b821211b4c299e8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 24 Feb 2011 14:57:38 +0000 Subject: Fixed bugs 3191107 and 3191112. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2762 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chheap.c | 2 +- os/kernel/src/chmemcore.c | 38 +++++++++++++++++++------------------- os/kernel/src/chmempools.c | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'os/kernel/src') diff --git a/os/kernel/src/chheap.c b/os/kernel/src/chheap.c index 13db7cf6b..c655e3852 100644 --- a/os/kernel/src/chheap.c +++ b/os/kernel/src/chheap.c @@ -125,7 +125,7 @@ void *chHeapAlloc(MemoryHeap *heapp, size_t size) { if (heapp == NULL) heapp = &default_heap; - size = MEM_ALIGN_SIZE(size); + size = MEM_ALIGN_NEXT(size); qp = &heapp->h_free; H_LOCK(heapp); diff --git a/os/kernel/src/chmemcore.c b/os/kernel/src/chmemcore.c index 69d3014a5..1fed481c5 100644 --- a/os/kernel/src/chmemcore.c +++ b/os/kernel/src/chmemcore.c @@ -24,18 +24,20 @@ * @addtogroup memcore * @details Core Memory Manager related APIs and services. *

Operation mode

- * The core memory manager is a simplified allocator that only allows - * to allocate memory blocks without the possibility to free them.
- * This allocator is meant as a memory blocks provider for the other - * allocators such as: + * The core memory manager is a simplified allocator that only + * allows to allocate memory blocks without the possibility to + * free them.
+ * This allocator is meant as a memory blocks provider for the + * other allocators such as: * - C-Runtime allocator (through a compiler specific adapter module). * - Heap allocator (see @ref heaps). * - Memory pools allocator (see @ref pools). * . - * By having a centralized memory provider the various allocators can - * coexist and share the main memory.
- * This allocator, alone, is also useful for very simple applications - * that just require a simple way to get memory blocks. + * By having a centralized memory provider the various allocators + * can coexist and share the main memory.
+ * This allocator, alone, is also useful for very simple + * applications that just require a simple way to get memory + * blocks. * @pre In order to use the core memory manager APIs the @p CH_USE_MEMCORE * option must be enabled in @p chconf.h. * @{ @@ -57,22 +59,20 @@ void core_init(void) { #if CH_MEMCORE_SIZE == 0 extern uint8_t __heap_base__; extern uint8_t __heap_end__; - nextmem = &__heap_base__; - endmem = &__heap_end__; + nextmem = (uint8_t *)MEM_ALIGN_NEXT(&__heap_base__); + endmem = (uint8_t *)MEM_ALIGN_PREV(&__heap_end__); #else - static stkalign_t buffer[MEM_ALIGN_SIZE(CH_MEMCORE_SIZE) / - sizeof(stkalign_t)]; + static stkalign_t buffer[MEM_ALIGN_NEXT(CH_MEMCORE_SIZE)/MEM_ALIGN_SIZE]; nextmem = (uint8_t *)&buffer[0]; - endmem = (uint8_t *)&buffer[MEM_ALIGN_SIZE(CH_MEMCORE_SIZE) / - sizeof(stkalign_t)]; + endmem = (uint8_t *)&buffer[MEM_ALIGN_NEXT(CH_MEMCORE_SIZE)/MEM_ALIGN_SIZE]; #endif } /** * @brief Allocates a memory block. * @details The size of the returned block is aligned to the alignment - * type @p stkalign_t so it is not possible to allocate less - * than sizeof(stkalign_t). + * type so it is not possible to allocate less + * than MEM_ALIGN_SIZE. * * @param[in] size the size of the block to be allocated * @return A pointer to the allocated memory block. @@ -92,8 +92,8 @@ void *chCoreAlloc(size_t size) { /** * @brief Allocates a memory block. * @details The size of the returned block is aligned to the alignment - * type @p align_t so it is not possible to allocate less than - * sizeof(align_t). + * type so it is not possible to allocate less than + * MEM_ALIGN_SIZE. * * @param[in] size the size of the block to be allocated. * @return A pointer to the allocated memory block. @@ -104,7 +104,7 @@ void *chCoreAlloc(size_t size) { void *chCoreAllocI(size_t size) { void *p; - size = MEM_ALIGN_SIZE(size); + size = MEM_ALIGN_NEXT(size); if ((size_t)(endmem - nextmem) < size) return NULL; p = nextmem; diff --git a/os/kernel/src/chmempools.c b/os/kernel/src/chmempools.c index 054823af0..83e6366f4 100644 --- a/os/kernel/src/chmempools.c +++ b/os/kernel/src/chmempools.c @@ -55,7 +55,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_SIZE(size); + mp->mp_object_size = MEM_ALIGN_NEXT(size); mp->mp_provider = provider; } -- cgit v1.2.3