QP/C  8.0.0
Real-Time Embedded Framework
Loading...
Searching...
No Matches
qmpool.h
Go to the documentation of this file.
1//$file${include::qmpool.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2//
3// Model: qpc.qm
4// File: ${include::qmpool.h}
5//
6// This code has been generated by QM 7.0.0 <www.state-machine.com/qm>.
7// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
8//
9// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
10//
11// Q u a n t u m L e a P s
12// ------------------------
13// Modern Embedded Software
14//
15// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
16//
17// The QP/C software is dual-licensed under the terms of the open-source GNU
18// General Public License (GPL) or under the terms of one of the closed-
19// source Quantum Leaps commercial licenses.
20//
21// Redistributions in source code must retain this top-level comment block.
22// Plagiarizing this software to sidestep the license obligations is illegal.
23//
24// NOTE:
25// The GPL does NOT permit the incorporation of this code into proprietary
26// programs. Please contact Quantum Leaps for commercial licensing options,
27// which expressly supersede the GPL and are designed explicitly for
28// closed-source distribution.
29//
30// Quantum Leaps contact information:
31// <www.state-machine.com/licensing>
32// <info@state-machine.com>
33//
34//$endhead${include::qmpool.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35#ifndef QMPOOL_H_
36#define QMPOOL_H_
37
38#ifndef QF_MPOOL_SIZ_SIZE
39 #define QF_MPOOL_SIZ_SIZE 2U
40#endif
41#ifndef QF_MPOOL_CTR_SIZE
42 #define QF_MPOOL_CTR_SIZE 2U
43#endif
44
45#if (QF_MPOOL_SIZ_SIZE == 1U)
46 typedef uint8_t QMPoolSize;
47#elif (QF_MPOOL_SIZ_SIZE == 2U)
48 typedef uint16_t QMPoolSize;
49#elif (QF_MPOOL_SIZ_SIZE == 4U)
50 typedef uint32_t QMPoolSize;
51#else
52 #error "QF_MPOOL_SIZ_SIZE defined incorrectly, expected 1U, 2U, or 4U"
53#endif
54
55#if (QF_MPOOL_CTR_SIZE == 1U)
56 typedef uint8_t QMPoolCtr;
57#elif (QF_MPOOL_CTR_SIZE == 2U)
58 typedef uint16_t QMPoolCtr;
59#elif (QF_MPOOL_CTR_SIZE == 4U)
60 typedef uint32_t QMPoolCtr;
61#else
62 #error "QF_MPOOL_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U"
63#endif
64
65#define QF_MPOOL_EL(evType_) struct { \
66 QFreeBlock sto_[((sizeof(evType_) - 1U) / (2U * sizeof(void *))) + 1U]; \
67}
68
69//$declare${QF::QFreeBlock} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
70
71//${QF::QFreeBlock} ..........................................................
72//! @struct QFreeBlock
73typedef struct QFreeBlock {
74// private:
75
76 //! @private @memberof QFreeBlock
77 struct QFreeBlock * next;
78
79#ifndef Q_UNSAFE
80 //! @private @memberof QFreeBlock
81 uintptr_t next_dis;
82#endif // ndef Q_UNSAFE
84//$enddecl${QF::QFreeBlock} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
85
86//$declare${QF::QMPool} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
87
88//${QF::QMPool} ..............................................................
89//! @class QMPool
90typedef struct {
91// private:
92
93 //! @private @memberof QMPool
95
96 //! @private @memberof QMPool
98
99 //! @private @memberof QMPool
101
102 //! @private @memberof QMPool
104
105 //! @private @memberof QMPool
107
108 //! @private @memberof QMPool
109 QMPoolCtr volatile nFree;
110
111#ifndef Q_UNSAFE
112 //! @private @memberof QMPool
114#endif // ndef Q_UNSAFE
115
116#ifndef Q_UNSAFE
117 //! @private @memberof QMPool
118 uintptr_t free_head_dis;
119#endif // ndef Q_UNSAFE
120
121#ifndef Q_UNSAFE
122 //! @private @memberof QMPool
124#endif // ndef Q_UNSAFE
125} QMPool;
126
127// public:
128
129//! @public @memberof QMPool
130void QMPool_init(QMPool * const me,
131 void * const poolSto,
132 uint_fast32_t const poolSize,
133 uint_fast16_t const blockSize);
134
135//! @public @memberof QMPool
136void * QMPool_get(QMPool * const me,
137 uint_fast16_t const margin,
138 uint_fast8_t const qsId);
139
140//! @public @memberof QMPool
141void QMPool_put(QMPool * const me,
142 void * const block,
143 uint_fast8_t const qsId);
144//$enddecl${QF::QMPool} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
145
146#endif // QMPOOL_H_
uint16_t QMPoolSize
The data type to store the block-size based on the macro QF_MPOOL_SIZ_SIZE.
Definition qmpool.h:48
uint16_t QMPoolCtr
The data type to store the block-counter based on the macro QF_MPOOL_CTR_SIZE.
Definition qmpool.h:58
Structure representing a free block in QMPool.
Definition qmpool.h:73
uintptr_t next_dis
Duplicate inverse storage for the next pointer (QP FuSa Subsystem)
Definition qmpool.h:81
struct QFreeBlock * next
Link to the next memory block.
Definition qmpool.h:77
Native QF Memory Pool.
Definition qmpool.h:90
QMPoolCtr volatile nFree
Number of free memory blocks remaining in the pool at this point.
Definition qmpool.h:109
void QMPool_init(QMPool *const me, void *const poolSto, uint_fast32_t const poolSize, uint_fast16_t const blockSize)
Initializes the native QF memory pool.
QMPoolSize blockSize
Memory block size [bytes] held by this fixed-size pool.
Definition qmpool.h:103
QMPoolCtr nFree_dis
Definition qmpool.h:123
QFreeBlock * end
End of the memory managed by this memory pool.
Definition qmpool.h:97
QMPoolCtr nMin
Minimum number of free blocks ever present in this pool.
Definition qmpool.h:113
QFreeBlock *volatile free_head
Head of linked list of free memory blocks.
Definition qmpool.h:100
QFreeBlock * start
Start of the memory managed by this memory pool.
Definition qmpool.h:94
uintptr_t free_head_dis
Definition qmpool.h:118
QMPoolCtr nTot
Total number of memory blocks in this pool.
Definition qmpool.h:106