37 #include "qs_dummy.hpp"
42Q_DEFINE_THIS_MODULE(
"qf_mem")
60 std::uint_fast32_t
const poolSize,
61 std::uint_fast16_t
const blockSize)
noexcept
69 m_start =
static_cast<void * *
>(poolSto);
74 std::uint_fast16_t index = 2U;
85 std::uint32_t nTot = 1U;
88 for (std::uint_fast32_t size = poolSize -
m_blockSize;
89 size >=
static_cast<std::uint_fast32_t
>(
m_blockSize);
90 size -=
static_cast<std::uint_fast32_t
>(
m_blockSize))
96 pfb =
static_cast<void * *
>(pfb[0]);
102#if (QF_MPOOL_CTR_SIZE == 1U)
104#elif (QF_MPOOL_CTR_SIZE == 2U)
122 std::uint_fast16_t
const margin,
123 std::uint_fast8_t
const qsId)
noexcept
137 if (nFree >
static_cast<QMPoolCtr>(margin)) {
142 void * *
const pfb_next =
static_cast<void * *
>(pfb[0]);
196 return static_cast<void *
>(pfb);
202 std::uint_fast8_t
const qsId)
noexcept
208 void * *
const pfb =
static_cast<void * *
>(block);
260 return static_cast<std::uint16_t
>(
m_nFree);
266 return static_cast<std::uint16_t
>(
m_nMin);
void * get(std::uint_fast16_t const margin, std::uint_fast8_t const qsId) noexcept
Obtain a memory block from a memory pool.
void init(void *const poolSto, std::uint_fast32_t const poolSize, std::uint_fast16_t const blockSize) noexcept
Initializes the native QF memory pool.
QMPoolSize m_blockSize
Memory block size [bytes] held by this fixed-size pool.
QMPoolSize getBlockSize() const noexcept
QMPool() noexcept
Default constructor of QP::QMPool.
QMPoolCtr m_nFree
Number of free memory blocks remaining in the pool at this point.
void put(void *const block, std::uint_fast8_t const qsId) noexcept
Recycles a memory block back to a memory pool.
std::uint16_t getMin() const noexcept
std::uint16_t getFree() const noexcept
QMPoolCtr m_nMin
Minimum number of free blocks ever present in this pool.
void ** m_end
End of the memory managed by this memory pool.
std::uint16_t getUse() const noexcept
void ** m_start
Start of the memory managed by this memory pool.
QMPoolCtr m_nTot
Total number of memory blocks in this pool.
QP/C++ Framework namespace.
std::uint16_t QMPoolSize
The data type to store the block-size based on the macro QF_MPOOL_SIZ_SIZE.
@ QS_QF_MPOOL_GET
a memory block was removed from memory pool
@ QS_QF_MPOOL_GET_ATTEMPT
attempt to get a memory block failed
@ QS_QF_MPOOL_PUT
a memory block was returned to memory pool
std::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 mark unused parameters of functions.
QP/C++ Framework in C++ internal (package-scope) interface.
QS (QP/Spy software tracing) internal (package-scope) interface.
#define QS_OBJ_PRE(obj_)
Output pre-formatted object pointer element.
#define QS_MPC_PRE(ctr_)
Output pre-formatted memory pool counter data element.
#define QS_END_PRE()
Pre-formatted QS trace record end.
#define QS_BEGIN_PRE(rec_, qsId_)
Pre-formatted QS trace record begin.
QP Functional Safety (FuSa) Subsystem.
#define Q_ASSERT_INCRIT(id_, expr_)
General-purpose assertion with user-specified ID number (in critical section).
#define Q_INVARIANT_INCRIT(id_, expr_)
Assertion for checking a postcondition (in critical section).
#define Q_REQUIRE_INCRIT(id_, expr_)
Assertion for checking a precondition (in critical section).