QP/C++  7.3.4
Real-Time Embedded Framework
Loading...
Searching...
No Matches
qf_qact.cpp
Go to the documentation of this file.
1//$file${src::qf::qf_qact.cpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2//
3// Model: qpcpp.qm
4// File: ${src::qf::qf_qact.cpp}
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) : qpcpp
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${src::qf::qf_qact.cpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43#define QP_IMPL // this is QP implementation
44#include "qp_port.hpp" // QP port
45#include "qp_pkg.hpp" // QP package-scope interface
46#include "qsafe.h" // QP Functional Safety (FuSa) Subsystem
47#ifdef Q_SPY // QS software tracing enabled?
48 #include "qs_port.hpp" // QS port
49 #include "qs_pkg.hpp" // QS facilities for pre-defined trace records
50#else
51 #include "qs_dummy.hpp" // disable the QS software tracing
52#endif // Q_SPY
53
54// unnamed namespace for local definitions with internal linkage
55namespace {
56Q_DEFINE_THIS_MODULE("qf_qact")
57} // unnamed namespace
58
59//$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
60// Check for the minimum required QP version
61#if (QP_VERSION < 730U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
62#error qpcpp version 7.3.0 or higher required
63#endif
64//$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65
66//$define${QF::QActive::QActive} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
67namespace QP {
68
69} // namespace QP
70//$enddef${QF::QActive::QActive} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
71
72//$define${QF::QActive::register_} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
73namespace QP {
74
75//${QF::QActive::register_} ..................................................
76void QActive::register_() noexcept {
79 QF_MEM_SYS();
80
81 if (m_pthre == 0U) { // preemption-threshold not defined?
82 m_pthre = m_prio; // apply the default
83 }
84
85 #ifndef Q_UNSAFE
86
88 && (registry_[m_prio] == nullptr)
89 && (m_prio <= m_pthre));
90
91 std::uint8_t prev_thre = m_pthre;
92 std::uint8_t next_thre = m_pthre;
93
94 std::uint_fast8_t p;
95 for (p = static_cast<std::uint_fast8_t>(m_prio) - 1U; p > 0U; --p) {
96 if (registry_[p] != nullptr) {
97 prev_thre = registry_[p]->m_pthre;
98 break;
99 }
100 }
101 for (p = static_cast<std::uint_fast8_t>(m_prio) + 1U;
102 p <= QF_MAX_ACTIVE; ++p)
103 {
104 if (registry_[p] != nullptr) {
105 next_thre = registry_[p]->m_pthre;
106 break;
107 }
108 }
109
110 Q_ASSERT_INCRIT(190, (prev_thre <= m_pthre)
111 && (m_pthre <= next_thre));
112
113 m_prio_dis = static_cast<std::uint8_t>(~m_prio);
114 m_pthre_dis = static_cast<std::uint8_t>(~m_pthre);
115
116 #endif // Q_UNSAFE
117
118 // register the AO at the QF-prio.
119 registry_[m_prio] = this;
120
121 QF_MEM_APP();
122 QF_CRIT_EXIT();
123}
124
125} // namespace QP
126//$enddef${QF::QActive::register_} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127
128//$define${QF::QActive::unregister_} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
129namespace QP {
130
131//${QF::QActive::unregister_} ................................................
132void QActive::unregister_() noexcept {
133 std::uint_fast8_t const p = static_cast<std::uint_fast8_t>(m_prio);
134
137 QF_MEM_SYS();
138
139 Q_REQUIRE_INCRIT(200, (0U < p) && (p <= QF_MAX_ACTIVE)
140 && (registry_[p] == this));
141 registry_[p] = nullptr; // free-up the priority level
142 m_state.fun = nullptr; // invalidate the state
143
144 QF_MEM_APP();
145 QF_CRIT_EXIT();
146}
147
148} // namespace QP
149//$enddef${QF::QActive::unregister_} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
std::uint8_t m_pthre_dis
Definition qp.hpp:748
void unregister_() noexcept
Definition qf_qact.cpp:132
std::uint8_t m_pthre
Definition qp.hpp:727
static QActive * registry_[QF_MAX_ACTIVE+1U]
Definition qp.hpp:750
std::uint8_t m_prio_dis
Definition qp.hpp:744
std::uint8_t m_prio
Definition qp.hpp:726
void register_() noexcept
Definition qf_qact.cpp:76
QAsmAttr m_state
Definition qp.hpp:222
QP/C++ framework.
Definition qequeue.hpp:50
#define QF_MEM_APP()
Definition qp.hpp:1276
#define QF_MEM_SYS()
Definition qp.hpp:1271
#define QF_MAX_ACTIVE
Internal (package scope) QP/C++ interface.
Sample QP/C++ port.
QS/C++ package-scope interface.
QS/C++ port to a 32-bit CPU, generic C++ compiler.
QP Functional Safety (FuSa) Subsystem.
#define QF_CRIT_ENTRY()
Definition qsafe.h:58
#define Q_ASSERT_INCRIT(id_, expr_)
Definition qsafe.h:72
#define QF_CRIT_EXIT()
Definition qsafe.h:62
#define Q_REQUIRE_INCRIT(id_, expr_)
Definition qsafe.h:136
#define QF_CRIT_STAT
Definition qsafe.h:54
QStateHandler fun
Definition qp.hpp:205