40#if (CH_CFG_USE_HEAP == TRUE) || defined(__DOXYGEN__)
49#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
50#define H_LOCK(h) chMtxLock(&(h)->mtx)
51#define H_UNLOCK(h) chMtxUnlock(&(h)->mtx)
53#define H_LOCK(h) (void) chSemWait(&(h)->sem)
54#define H_UNLOCK(h) chSemSignal(&(h)->sem)
57#define H_BLOCK(hp) ((hp) + 1U)
59#define H_LIMIT(hp) (H_BLOCK(hp) + H_PAGES(hp))
61#define H_NEXT(hp) ((hp)->free.next)
63#define H_PAGES(hp) ((hp)->free.pages)
65#define H_HEAP(hp) ((hp)->used.heap)
67#define H_SIZE(hp) ((hp)->used.size)
72#define NPAGES(p1, p2) \
74 ((size_t)((p1) - (p2))) \
112#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
139 size -= (size_t)((uint8_t *)hp - (uint8_t *)buf);
148#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
196 while (
H_NEXT(qp) != NULL) {
214 if (bpages > pages) {
220 H_PAGES(fp) = (bpages - pages) - 1U;
315 if (((qp == &heapp->
header) || (hp > qp)) &&
359 size_t n, tpages, lpages;
370 while (
H_NEXT(qp) != NULL) {
376 if (pages > lpages) {
384 if (totalp != NULL) {
389 if (largestp != NULL) {
ChibiOS/RT main include file.
#define chDbgAssert(c, r)
Condition assertion.
#define chDbgCheck(c)
Function parameters check.
#define MEM_IS_VALID_ALIGNMENT(a)
Returns whatever a constant is a valid alignment.
#define MEM_IS_ALIGNED(p, a)
Returns whatever a pointer or memory size is aligned.
#define MEM_ALIGN_NEXT(p, a)
Aligns to the next aligned memory address.
void chMtxObjectInit(mutex_t *mp)
Initializes s mutex_t structure.
#define chCoreAllocAlignedWithOffset
Allocates a memory block.
void chHeapFree(void *p)
Frees a previously allocated memory block.
void __heap_init(void)
Initializes the default heap.
void chHeapObjectInit(memory_heap_t *heapp, void *buf, size_t size)
Initializes a memory heap from a static memory area.
struct memory_heap memory_heap_t
Type of a memory heap.
size_t chHeapStatus(memory_heap_t *heapp, size_t *totalp, size_t *largestp)
Reports the heap status.
static memory_heap_t default_heap
Default heap descriptor.
void * chHeapAllocAligned(memory_heap_t *heapp, size_t size, unsigned align)
Allocates a block of memory from the heap by using the first-fit algorithm.
union heap_header heap_header_t
Type of a memory heap header.
#define CH_HEAP_ALIGNMENT
Minimum alignment used for heap.
void chSemObjectInit(semaphore_t *sp, cnt_t n)
Initializes a semaphore with the specified counter value.
memgetfunc2_t provider
Memory blocks provider for this heap.
mutex_t mtx
Heap access mutex.
heap_header_t header
Free blocks list header.