QP/C++  8.0.0
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 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
18// GNU 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${src::qf::qf_qact.cpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35#define QP_IMPL // this is QP implementation
36#include "qp_port.hpp" // QP port
37#include "qp_pkg.hpp" // QP package-scope interface
38#include "qsafe.h" // QP Functional Safety (FuSa) Subsystem
39#ifdef Q_SPY // QS software tracing enabled?
40 #include "qs_port.hpp" // QS port
41 #include "qs_pkg.hpp" // QS facilities for pre-defined trace records
42#else
43 #include "qs_dummy.hpp" // disable the QS software tracing
44#endif // Q_SPY
45
46// unnamed namespace for local definitions with internal linkage
47namespace {
48Q_DEFINE_THIS_MODULE("qf_qact")
49} // unnamed namespace
50
51//$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
52// Check for the minimum required QP version
53#if (QP_VERSION < 730U) || (QP_VERSION != ((QP_RELEASE^4294967295U)%0x2710U))
54#error qpcpp version 7.3.0 or higher required
55#endif
56//$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
57//$define${QF::QActive::QActive} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
58namespace QP {
59
60} // namespace QP
61//$enddef${QF::QActive::QActive} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62
63//$define${QF::QActive::register_} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
64namespace QP {
65
66//${QF::QActive::register_} ..................................................
67void QActive::register_() noexcept {
70 QF_MEM_SYS();
71
72 if (m_pthre == 0U) { // preemption-threshold not defined?
73 m_pthre = m_prio; // apply the default
74 }
75
76 #ifndef Q_UNSAFE
77
79 && (registry_[m_prio] == nullptr)
80 && (m_prio <= m_pthre));
81
82 std::uint8_t prev_thre = m_pthre;
83 std::uint8_t next_thre = m_pthre;
84
85 std::uint_fast8_t p;
86 for (p = static_cast<std::uint_fast8_t>(m_prio) - 1U; p > 0U; --p) {
87 if (registry_[p] != nullptr) {
88 prev_thre = registry_[p]->m_pthre;
89 break;
90 }
91 }
92 for (p = static_cast<std::uint_fast8_t>(m_prio) + 1U;
93 p <= QF_MAX_ACTIVE; ++p)
94 {
95 if (registry_[p] != nullptr) {
96 next_thre = registry_[p]->m_pthre;
97 break;
98 }
99 }
100
101 Q_ASSERT_INCRIT(190, (prev_thre <= m_pthre)
102 && (m_pthre <= next_thre));
103
104 m_prio_dis = static_cast<std::uint8_t>(~m_prio);
105 m_pthre_dis = static_cast<std::uint8_t>(~m_pthre);
106
107 #endif // Q_UNSAFE
108
109 // register the AO at the QF-prio.
110 registry_[m_prio] = this;
111
112 QF_MEM_APP();
113 QF_CRIT_EXIT();
114}
115
116} // namespace QP
117//$enddef${QF::QActive::register_} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
118
119//$define${QF::QActive::unregister_} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
120namespace QP {
121
122//${QF::QActive::unregister_} ................................................
123void QActive::unregister_() noexcept {
124 std::uint_fast8_t const p = static_cast<std::uint_fast8_t>(m_prio);
125
128 QF_MEM_SYS();
129
130 Q_REQUIRE_INCRIT(200, (0U < p) && (p <= QF_MAX_ACTIVE)
131 && (registry_[p] == this));
132 registry_[p] = nullptr; // free-up the priority level
133 m_state.fun = nullptr; // invalidate the state
134
135 QF_MEM_APP();
136 QF_CRIT_EXIT();
137}
138
139} // namespace QP
140//$enddef${QF::QActive::unregister_} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
void unregister_() noexcept
Definition qf_qact.cpp:123
static QActive * registry_[QF_MAX_ACTIVE+1U]
Definition qp.hpp:725
std::uint8_t m_pthre_dis
Definition qp.hpp:723
void register_() noexcept
Definition qf_qact.cpp:67
std::uint8_t m_pthre
Definition qp.hpp:702
std::uint8_t m_prio_dis
Definition qp.hpp:719
std::uint8_t m_prio
Definition qp.hpp:701
QAsmAttr m_state
Current state (pointer to the current state-handler function)
Definition qp.hpp:214
QP/C++ framework.
Definition qequeue.hpp:42
#define QF_MEM_APP()
Definition qp.hpp:1322
#define QF_MEM_SYS()
Definition qp.hpp:1317
#define QF_MAX_ACTIVE
Maximum # Active Objects in the system (1..64)
Internal (package scope) QP/C++ interface.
Sample QP/C++ port.
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:197