31 #if !defined(CH_CFG_USE_MEMPOOLS) 32 #define CH_CFG_USE_MEMPOOLS FALSE 35 #if (CH_CFG_USE_MEMPOOLS == TRUE) || defined(__DOXYGEN__) 49 #if CH_CFG_USE_MEMCORE == FALSE 50 #error "CH_CFG_USE_MEMPOOLS requires CH_CFG_USE_MEMCORE" 77 #if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__) 102 #define _MEMORYPOOL_DATA(name, size, align, provider) \ 103 {NULL, size, align, provider} 116 #define MEMORYPOOL_DECL(name, size, align, provider) \ 117 memory_pool_t name = _MEMORYPOOL_DATA(name, size, align, provider) 119 #if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__) 129 #define _GUARDEDMEMORYPOOL_DATA(name, size, align) { \ 130 _SEMAPHORE_DATA(name.sem, (cnt_t)0), \ 131 _MEMORYPOOL_DATA(NULL, size, align, NULL) \ 143 #define GUARDEDMEMORYPOOL_DECL(name, size, align) \ 144 guarded_memory_pool_t name = _GUARDEDMEMORYPOOL_DATA(name, size, align) 161 #if CH_CFG_USE_SEMAPHORES == TRUE 238 #if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__) 272 "semaphore out of sync");
uint64_t sysinterval_t
Type of time interval.
static void chPoolObjectInit(memory_pool_t *mp, size_t size, memgetfunc_t provider)
Initializes an empty memory pool.
void chPoolLoadArray(memory_pool_t *mp, void *p, size_t n)
Loads a memory pool with an array of static objects.
void chPoolFree(memory_pool_t *mp, void *objp)
Releases an object into a memory pool.
void * chGuardedPoolAllocTimeout(guarded_memory_pool_t *gmp, sysinterval_t timeout)
Allocates an object from a guarded memory pool.
memgetfunc_t provider
Memory blocks provider for this pool.
static void chSemFastWaitI(semaphore_t *sp)
Decreases the semaphore counter.
unsigned align
Required alignment.
memory_pool_t pool
The memory pool itself.
static void chGuardedPoolAdd(guarded_memory_pool_t *gmp, void *objp)
Adds an object to a guarded memory pool.
static void chGuardedPoolObjectInit(guarded_memory_pool_t *gmp, size_t size)
Initializes an empty guarded memory pool.
static void * chGuardedPoolAllocI(guarded_memory_pool_t *gmp)
Allocates an object from a guarded memory pool.
void chGuardedPoolLoadArray(guarded_memory_pool_t *gmp, void *p, size_t n)
Loads a guarded memory pool with an array of static objects.
size_t object_size
Memory pool objects size.
static void chGuardedPoolFreeI(guarded_memory_pool_t *gmp, void *objp)
Releases an object into a guarded memory pool.
void chSchRescheduleS(void)
Performs a reschedule if a higher priority thread is runnable.
void * chPoolAlloc(memory_pool_t *mp)
Allocates an object from a memory pool.
static void chGuardedPoolAddI(guarded_memory_pool_t *gmp, void *objp)
Adds an object to a guarded memory pool.
struct pool_header * next
Pointer to the header.
void * chPoolAllocI(memory_pool_t *mp)
Allocates an object from a memory pool.
#define chDbgAssert(c, r)
Condition assertion.
void chGuardedPoolObjectInitAligned(guarded_memory_pool_t *gmp, size_t size, unsigned align)
Initializes an empty guarded memory pool.
void * chGuardedPoolAllocTimeoutS(guarded_memory_pool_t *gmp, sysinterval_t timeout)
Allocates an object from a guarded memory pool.
void chGuardedPoolFree(guarded_memory_pool_t *gmp, void *objp)
Releases an object into a guarded memory pool.
static void chPoolAddI(memory_pool_t *mp, void *objp)
Adds an object to a memory pool.
semaphore_t sem
Counter semaphore guarding the memory pool.
void chPoolObjectInitAligned(memory_pool_t *mp, size_t size, unsigned align, memgetfunc_t provider)
Initializes an empty memory pool.
void *(* memgetfunc_t)(size_t size, unsigned align)
Memory get function.
Guarded memory pool descriptor.
static void chPoolAdd(memory_pool_t *mp, void *objp)
Adds an object to a memory pool.
static cnt_t chSemGetCounterI(const semaphore_t *sp)
Returns the semaphore counter current value.
void chSemSignalI(semaphore_t *sp)
Performs a signal operation on a semaphore.
static void chGuardedPoolAddS(guarded_memory_pool_t *gmp, void *objp)
Adds an object to a guarded memory pool.
void chPoolFreeI(memory_pool_t *mp, void *objp)
Releases an object into a memory pool.
static void chGuardedPoolFreeS(guarded_memory_pool_t *gmp, void *objp)
Releases an object into a guarded memory pool.