QP/C++ 6.9.3
qf_pkg.hpp
Go to the documentation of this file.
1 
39 #ifndef QF_PKG_HPP
40 #define QF_PKG_HPP
41 
43 #define QF_EVT_CONST_CAST_(e_) const_cast<QEvt *>(e_)
44 
45 // QF-specific critical section...
46 #ifndef QF_CRIT_STAT_TYPE
56  #define QF_CRIT_STAT_
57 
66  #define QF_CRIT_E_() QF_CRIT_ENTRY(dummy)
67 
77  #define QF_CRIT_X_() QF_CRIT_EXIT(dummy)
78 
79 #elif (!defined QF_CRIT_STAT_)
80  #define QF_CRIT_STAT_ QF_CRIT_STAT_TYPE critStat_;
81  #define QF_CRIT_E_() QF_CRIT_ENTRY(critStat_)
82  #define QF_CRIT_X_() QF_CRIT_EXIT(critStat_)
83 #endif // QF_CRIT_STAT_TYPE
84 
85 // Assertions inside the crticial section ------------------------------------
86 #ifdef Q_NASSERT // Q_NASSERT defined--assertion checking disabled
87 
88  #define Q_ASSERT_CRIT_(id_, test_) ((void)0)
89  #define Q_REQUIRE_CRIT_(id_, test_) ((void)0)
90  #define Q_ERROR_CRIT_(id_) ((void)0)
91 
92 #else // Q_NASSERT not defined--assertion checking enabled
93 
94  #define Q_ASSERT_CRIT_(id_, test_) do {\
95  if ((test_)) {} else { \
96  QF_CRIT_X_(); \
97  Q_onAssert(&Q_this_module_[0], static_cast<int_t>(id_)); \
98  } \
99  } while (false)
100 
101  #define Q_REQUIRE_CRIT_(id_, test_) Q_ASSERT_CRIT_((id_), (test_))
102 
103  #define Q_ERROR_CRIT_(id_) do { \
104  QF_CRIT_X_(); \
105  Q_onAssert(&Q_this_module_[0], static_cast<int_t>(id_)); \
106  } while (false)
107 
108 #endif // Q_NASSERT
109 
110 
111 namespace QP {
112 
113 // package-scope objects -----------------------------------------------------
116 extern QSubscrList *QF_subscrList_;
117 extern enum_t QF_maxPubSignal_;
118 
119 //............................................................................
122 struct QFreeBlock {
123  QFreeBlock * volatile m_next;
124 };
125 
126 //............................................................................
127 // The following flags and bitmasks are for the fields of the @c refCtr_
128 // attribute of the QP::QTimeEvt class (inherited from QEvt). This attribute
129 // is NOT used for reference counting in time events, because the @c poolId_
130 // attribute is zero ("static events").
131 //
132 constexpr std::uint8_t TE_IS_LINKED = 1U << 7U; // flag
133 constexpr std::uint8_t TE_WAS_DISARMED = 1U << 6U; // flag
134 constexpr std::uint8_t TE_TICK_RATE = 0x0FU; // bitmask
135 
136 //****************************************************************************
137 // internal helper inline functions
138 
140 inline std::uint8_t QF_EVT_POOL_ID_ (QEvt const * const e) noexcept {
141  return e->poolId_;
142 }
143 
145 inline std::uint8_t QF_EVT_REF_CTR_ (QEvt const * const e) noexcept {
146  return e->refCtr_;
147 }
148 
150 inline void QF_EVT_REF_CTR_INC_(QEvt const * const e) noexcept {
151  ++(QF_EVT_CONST_CAST_(e))->refCtr_;
152 }
153 
155 inline void QF_EVT_REF_CTR_DEC_(QEvt const * const e) noexcept {
156  --(QF_EVT_CONST_CAST_(e))->refCtr_;
157 }
158 
159 } // namespace QP
160 
168 #define QF_PTR_RANGE_(x_, min_, max_) (((min_) <= (x_)) && ((x_) <= (max_)))
169 
171 #define QF_PTR_AT_(base_, i_) (base_[i_])
172 
173 #endif // QF_PKG_HPP
unsigned char uint8_t
exact-width 8-bit unsigned int
Definition: 16bit/stdint.h:29
unsigned int uint_fast8_t
fast at-least 8-bit unsigned int
Definition: 16bit/stdint.h:36
#define QF_EPOOL_TYPE_
This macro defines the type of the event pool used in this QF port.
Definition: macros.hpp:102
namespace associated with the QP/C++ framework
Definition: struct.dox:1
void QF_EVT_REF_CTR_INC_(QEvt const *const e) noexcept
increment the refCtr_ of an event e
Definition: qf_pkg.hpp:150
constexpr std::uint8_t TE_WAS_DISARMED
Definition: qf_pkg.hpp:133
enum_t QF_maxPubSignal_
the maximum published signal
Definition: qf_ps.cpp:58
constexpr std::uint8_t TE_TICK_RATE
Definition: qf_pkg.hpp:134
constexpr std::uint8_t TE_IS_LINKED
Definition: qf_pkg.hpp:132
std::uint_fast8_t QF_maxPool_
Definition: qf_dyn.cpp:55
std::uint8_t QF_EVT_POOL_ID_(QEvt const *const e) noexcept
return the Pool-ID of an event e
Definition: qf_pkg.hpp:140
QFreeBlock *volatile m_next
link to the next free block
Definition: qf_pkg.hpp:123
QPSet QSubscrList
Subscriber List.
Definition: qf.hpp:488
QF_EPOOL_TYPE_ QF_pool_[QF_MAX_EPOOL]
allocate event pools
Definition: qf_dyn.cpp:54
QSubscrList * QF_subscrList_
the subscriber list array
Definition: qf_ps.cpp:57
void QF_EVT_REF_CTR_DEC_(QEvt const *const e) noexcept
decrement the refCtr_ of an event e
Definition: qf_pkg.hpp:155
std::uint8_t QF_EVT_REF_CTR_(QEvt const *const e) noexcept
return the Reference Conter of an event e
Definition: qf_pkg.hpp:145
Structure representing a free block in the Native QF Memory Pool.
Definition: qf_pkg.hpp:122
int enum_t
alias for enumerations used for event signals
Definition: qep.hpp:82
#define QF_EVT_CONST_CAST_(e_)
helper macro to cast const away from an event pointer e_
Definition: qf_pkg.hpp:43
#define QF_MAX_EPOOL
The maximum number of event pools in the application.
Definition: qxk/qf_port.hpp:74
QEvt base class.
Definition: qep.hpp:209