54Q_DEFINE_THIS_MODULE(
"qf_mem")
58#if (QP_VERSION < 730U) || (QP_VERSION != ((QP_RELEASE^4294967295U)%0x2710U))
59#error qpc version 7.3.0 or higher required
68void QMPool_init(
QMPool *
const me,
70 uint_fast32_t
const poolSize,
71 uint_fast16_t
const blockSize)
78 && (poolSize >= (uint_fast32_t)
sizeof(
QFreeBlock))
79 && ((uint_fast16_t)(blockSize +
sizeof(
QFreeBlock)) > blockSize));
85 uint_fast16_t nblocks = 1U;
99 for (uint_fast32_t size = poolSize - me->
blockSize;
103 fb->
next = &fb[nblocks];
112 #if (QF_MPOOL_CTR_SIZE == 1U)
114 #elif (QF_MPOOL_CTR_SIZE == 2U)
136 uint_fast16_t
const margin,
137 uint_fast8_t
const qsId)
162 if (me->
nFree == 0U) {
177 (me->
start <= fb_next) && (fb_next <= me->end));
190 QS_MPC_PRE_(me->
nFree);
191 QS_MPC_PRE_(me->
nMin);
200 QS_MPC_PRE_(me->
nFree);
215 uint_fast8_t
const qsId)
228 && (me->
start <= fb) && (fb <= me->end));
243 QS_MPC_PRE_(me->
nFree);
uint16_t QMPoolSize
The data type to store the block-size based on the macro QF_MPOOL_SIZ_SIZE.
uint16_t QMPoolCtr
The data type to store the block-counter based on the macro QF_MPOOL_CTR_SIZE.
#define Q_UNUSED_PAR(par_)
Helper macro to clearly mark unused parameters of functions.
Internal (package scope) QP/C interface.
#define Q_UINTPTR_CAST_(ptr_)
@ QS_QF_MPOOL_GET_ATTEMPT
attempt to get a memory block failed
@ QS_QF_MPOOL_PUT
a memory block was returned to memory pool
@ QS_QF_MPOOL_GET
a memory block was removed from memory pool
QS/C package-scope interface.
QP Functional Safety (FuSa) Subsystem.
#define Q_ASSERT_INCRIT(id_, expr_)
#define Q_INVARIANT_INCRIT(id_, expr_)
#define Q_ENSURE_INCRIT(id_, expr_)
#define Q_REQUIRE_INCRIT(id_, expr_)
Structure representing a free block in QMPool.
uintptr_t next_dis
Duplicate inverse storage for the next pointer (QP FuSa Subsystem)
struct QFreeBlock * next
Link to the next memory block.
QMPoolCtr volatile nFree
Number of free memory blocks remaining in the pool at this point.
QMPoolSize blockSize
Memory block size [bytes] held by this fixed-size pool.
QFreeBlock * end
End of the memory managed by this memory pool.
QMPoolCtr nMin
Minimum number of free blocks ever present in this pool.
QFreeBlock *volatile free_head
Head of linked list of free memory blocks.
QFreeBlock * start
Start of the memory managed by this memory pool.
QMPoolCtr nTot
Total number of memory blocks in this pool.