QP/C++  7.0.1
Real-Time Embedded Framework
qf_pkg.hpp
Go to the documentation of this file.
1//============================================================================
2// QP/C++ Real-Time Embedded Framework (RTEF)
3// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
4//
5// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
6//
7// This software is dual-licensed under the terms of the open source GNU
8// General Public License version 3 (or any later version), or alternatively,
9// under the terms of one of the closed source Quantum Leaps commercial
10// licenses.
11//
12// The terms of the open source GNU General Public License version 3
13// can be found at: <www.gnu.org/licenses/gpl-3.0>
14//
15// The terms of the closed source Quantum Leaps commercial licenses
16// can be found at: <www.state-machine.com/licensing>
17//
18// Redistributions in source code must retain this top-level comment block.
19// Plagiarizing this software to sidestep the license obligations is illegal.
20//
21// Contact information:
22// <www.state-machine.com>
23// <info@state-machine.com>
24//============================================================================
30
31#ifndef QF_PKG_HPP
32#define QF_PKG_HPP
33
35#define QF_EVT_CONST_CAST_(e_) const_cast<QEvt *>(e_)
36
37// QF-specific critical section...
38#ifndef QF_CRIT_STAT_TYPE
48 #define QF_CRIT_STAT_
49
58 #define QF_CRIT_E_() QF_CRIT_ENTRY(dummy)
59
69 #define QF_CRIT_X_() QF_CRIT_EXIT(dummy)
70
71#elif (!defined QF_CRIT_STAT_)
72 #define QF_CRIT_STAT_ QF_CRIT_STAT_TYPE critStat_;
73 #define QF_CRIT_E_() QF_CRIT_ENTRY(critStat_)
74 #define QF_CRIT_X_() QF_CRIT_EXIT(critStat_)
75#endif // QF_CRIT_STAT_TYPE
76
77// Assertions inside the crticial section ------------------------------------
78#ifdef Q_NASSERT // Q_NASSERT defined--assertion checking disabled
79
80 #define Q_ASSERT_CRIT_(id_, test_) static_cast<void>(0)
81 #define Q_REQUIRE_CRIT_(id_, test_) static_cast<void>(0)
82 #define Q_ERROR_CRIT_(id_) static_cast<void>(0)
83
84#else // Q_NASSERT not defined--assertion checking enabled
85
86 #define Q_ASSERT_CRIT_(id_, test_) do {\
87 if ((test_)) {} else { \
88 QF_CRIT_X_(); \
89 Q_onAssert(&Q_this_module_[0], static_cast<int_t>(id_)); \
90 } \
91 } while (false)
92
93 #define Q_REQUIRE_CRIT_(id_, test_) Q_ASSERT_CRIT_((id_), (test_))
94
95 #define Q_ERROR_CRIT_(id_) do { \
96 QF_CRIT_X_(); \
97 Q_onAssert(&Q_this_module_[0], static_cast<int_t>(id_)); \
98 } while (false)
99
100#endif // Q_NASSERT
101
102
103namespace QP {
104
105// package-scope objects -----------------------------------------------------
106extern QF_EPOOL_TYPE_ QF_pool_[QF_MAX_EPOOL];
107extern std::uint_fast8_t QF_maxPool_;
110
111//............................................................................
115 QFreeBlock * volatile m_next;
116};
117
118//............................................................................
119// The following flags and bitmasks are for the fields of the @c refCtr_
120// attribute of the QP::QTimeEvt class (inherited from QEvt). This attribute
121// is NOT used for reference counting in time events, because the @c poolId_
122// attribute is zero ("static events").
123//
124constexpr std::uint8_t TE_IS_LINKED = 1U << 7U; // flag
125constexpr std::uint8_t TE_WAS_DISARMED = 1U << 6U; // flag
126constexpr std::uint8_t TE_TICK_RATE = 0x0FU; // bitmask
127
128//============================================================================
129// internal helper inline functions
130
132inline std::uint8_t QF_EVT_POOL_ID_ (QEvt const * const e) noexcept {
133 return e->poolId_;
134}
135
137inline std::uint8_t QF_EVT_REF_CTR_ (QEvt const * const e) noexcept {
138 return e->refCtr_;
139}
140
142inline void QF_EVT_REF_CTR_INC_(QEvt const * const e) noexcept {
143 (QF_EVT_CONST_CAST_(e))->refCtr_ = (QF_EVT_CONST_CAST_(e))->refCtr_ + 1U;
144}
145
147inline void QF_EVT_REF_CTR_DEC_(QEvt const * const e) noexcept {
148 (QF_EVT_CONST_CAST_(e))->refCtr_ = (QF_EVT_CONST_CAST_(e))->refCtr_ - 1U;
149}
150
151} // namespace QP
152
160#define QF_PTR_RANGE_(x_, min_, max_) (((min_) <= (x_)) && ((x_) <= (max_)))
161
162#endif // QF_PKG_HPP
namespace associated with the QP/C++ framework
Definition: exa_native.dox:1
std::uint8_t QF_EVT_POOL_ID_(QEvt const *const e) noexcept
return the Pool-ID of an event e
Definition: qf_pkg.hpp:132
void QF_EVT_REF_CTR_DEC_(QEvt const *const e) noexcept
decrement the refCtr_ of an event e
Definition: qf_pkg.hpp:147
std::uint8_t QF_EVT_REF_CTR_(QEvt const *const e) noexcept
return the Reference Conter of an event e
Definition: qf_pkg.hpp:137
constexpr std::uint8_t TE_WAS_DISARMED
Definition: qf_pkg.hpp:125
enum_t QF_maxPubSignal_
the maximum published signal
Definition: qf_ps.cpp:54
constexpr std::uint8_t TE_TICK_RATE
Definition: qf_pkg.hpp:126
constexpr std::uint8_t TE_IS_LINKED
Definition: qf_pkg.hpp:124
std::uint_fast8_t QF_maxPool_
Definition: qf_dyn.cpp:53
QFreeBlock *volatile m_next
link to the next free block
Definition: qf_pkg.hpp:115
QPSet QSubscrList
Subscriber List.
Definition: qf.hpp:479
QF_EPOOL_TYPE_ QF_pool_[QF_MAX_EPOOL]
allocate event pools
Definition: qf_dyn.cpp:52
QSubscrList * QF_subscrList_
the subscriber list array
Definition: qf_ps.cpp:53
void QF_EVT_REF_CTR_INC_(QEvt const *const e) noexcept
increment the refCtr_ of an event e
Definition: qf_pkg.hpp:142
Structure representing a free block in the Native QF Memory Pool.
Definition: qf_pkg.hpp:114
int enum_t
alias for enumerations used for event signals
Definition: qep.hpp:66
#define QF_EVT_CONST_CAST_(e_)
helper macro to cast const away from an event pointer e_
Definition: qf_pkg.hpp:35
#define QF_EPOOL_TYPE_
Definition: qv.hpp:97
QEvt base class.
Definition: qep.hpp:191