QP/C  7.4.0-rc.2
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 6.1.1 <www.state-machine.com/qm>.
7// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
8//
9// This code is covered by the following QP license:
10// License # : LicenseRef-QL-dual
11// Issued to : Any user of the QP/C real-time embedded framework
12// Framework(s) : qpc
13// Support ends : 2024-12-31
14// License scope:
15//
16// Copyright (C) 2005 Quantum Leaps, LLC <state-machine.com>.
17//
18// Q u a n t u m L e a P s
19// ------------------------
20// Modern Embedded Software
21//
22// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
23//
24// This software is dual-licensed under the terms of the open source GNU
25// General Public License version 3 (or any later version), or alternatively,
26// under the terms of one of the closed source Quantum Leaps commercial
27// licenses.
28//
29// The terms of the open source GNU General Public License version 3
30// can be found at: <www.gnu.org/licenses/gpl-3.0>
31//
32// The terms of the closed source Quantum Leaps commercial licenses
33// can be found at: <www.state-machine.com/licensing>
34//
35// Redistributions in source code must retain this top-level comment block.
36// Plagiarizing this software to sidestep the license obligations is illegal.
37//
38// Contact information:
39// <www.state-machine.com/licensing>
40// <info@state-machine.com>
41//
42//$endhead${include::qmpool.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43#ifndef QMPOOL_H_
44#define QMPOOL_H_
45
46#ifndef QF_MPOOL_SIZ_SIZE
47 #define QF_MPOOL_SIZ_SIZE 2U
48#endif
49#ifndef QF_MPOOL_CTR_SIZE
50 #define QF_MPOOL_CTR_SIZE 2U
51#endif
52
53#if (QF_MPOOL_SIZ_SIZE == 1U)
54 typedef uint8_t QMPoolSize;
55#elif (QF_MPOOL_SIZ_SIZE == 2U)
56 typedef uint16_t QMPoolSize;
57#elif (QF_MPOOL_SIZ_SIZE == 4U)
58 typedef uint32_t QMPoolSize;
59#else
60 #error "QF_MPOOL_SIZ_SIZE defined incorrectly, expected 1U, 2U, or 4U"
61#endif
62
63#if (QF_MPOOL_CTR_SIZE == 1U)
64 typedef uint8_t QMPoolCtr;
65#elif (QF_MPOOL_CTR_SIZE == 2U)
66 typedef uint16_t QMPoolCtr;
67#elif (QF_MPOOL_CTR_SIZE == 4U)
68 typedef uint32_t QMPoolCtr;
69#else
70 #error "QF_MPOOL_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U"
71#endif
72
73#define QF_MPOOL_EL(evType_) struct { \
74 QFreeBlock sto_[((sizeof(evType_) - 1U) \
75 / sizeof(QFreeBlock)) + 1U]; }
76
77//$declare${QF::QFreeBlock} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
78
79//${QF::QFreeBlock} ..........................................................
80//! @struct QFreeBlock
81typedef struct QFreeBlock {
82// private:
83
84 //! @private @memberof QFreeBlock
85 struct QFreeBlock * next;
86
87#ifndef Q_UNSAFE
88 //! @private @memberof QFreeBlock
89 uintptr_t next_dis;
90#endif // ndef Q_UNSAFE
92//$enddecl${QF::QFreeBlock} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
93
94//$declare${QF::QMPool} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
95
96//${QF::QMPool} ..............................................................
97//! @class QMPool
98typedef struct {
99// private:
100
101 //! @private @memberof QMPool
103
104 //! @private @memberof QMPool
106
107 //! @private @memberof QMPool
109
110 //! @private @memberof QMPool
112
113 //! @private @memberof QMPool
115
116 //! @private @memberof QMPool
117 QMPoolCtr volatile nFree;
118
119 //! @private @memberof QMPool
121} QMPool;
122
123// public:
124
125//! @public @memberof QMPool
126void QMPool_init(QMPool * const me,
127 void * const poolSto,
128 uint_fast32_t const poolSize,
129 uint_fast16_t const blockSize);
130
131//! @public @memberof QMPool
132void * QMPool_get(QMPool * const me,
133 uint_fast16_t const margin,
134 uint_fast8_t const qsId);
135
136//! @public @memberof QMPool
137void QMPool_put(QMPool * const me,
138 void * const block,
139 uint_fast8_t const qsId);
140//$enddecl${QF::QMPool} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
141
142#endif // QMPOOL_H_
uint16_t QMPoolSize
Definition qmpool.h:56
uint16_t QMPoolCtr
Definition qmpool.h:66
Structure representing a free block in QMPool.
Definition qmpool.h:81
uintptr_t next_dis
Definition qmpool.h:89
struct QFreeBlock * next
Definition qmpool.h:85
Native QF Memory Pool.
Definition qmpool.h:98
QMPoolCtr volatile nFree
Definition qmpool.h:117
void QMPool_init(QMPool *const me, void *const poolSto, uint_fast32_t const poolSize, uint_fast16_t const blockSize)
QMPoolSize blockSize
Definition qmpool.h:111
QFreeBlock * end
Definition qmpool.h:105
QMPoolCtr nMin
Definition qmpool.h:120
QFreeBlock *volatile free_head
Definition qmpool.h:108
QFreeBlock * start
Definition qmpool.h:102
QMPoolCtr nTot
Definition qmpool.h:114