QP/C++  8.0.3
Real-Time Event Framework
Loading...
Searching...
No Matches
qf_act.cpp
Go to the documentation of this file.
1//============================================================================
2// QP/C++ Real-Time Event Framework (RTEF)
3//
4// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
5//
6// Q u a n t u m L e a P s
7// ------------------------
8// Modern Embedded Software
9//
10// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
11//
12// This software is dual-licensed under the terms of the open-source GNU
13// General Public License (GPL) or under the terms of one of the closed-
14// source Quantum Leaps commercial licenses.
15//
16// Redistributions in source code must retain this top-level comment block.
17// Plagiarizing this software to sidestep the license obligations is illegal.
18//
19// NOTE:
20// The GPL does NOT permit the incorporation of this code into proprietary
21// programs. Please contact Quantum Leaps for commercial licensing options,
22// which expressly supersede the GPL and are designed explicitly for
23// closed-source distribution.
24//
25// Quantum Leaps contact information:
26// <www.state-machine.com/licensing>
27// <info@state-machine.com>
28//============================================================================
29#define QP_IMPL // this is QP implementation
30#include "qp_port.hpp" // QP port
31#include "qp_pkg.hpp" // QP package-scope interface
32#include "qsafe.h" // QP Functional Safety (FuSa) Subsystem
33#ifdef Q_SPY // QS software tracing enabled?
34 #include "qs_port.hpp" // QS port
35 #include "qs_pkg.hpp" // QS facilities for pre-defined trace records
36#else
37 #include "qs_dummy.hpp" // disable the QS software tracing
38#endif // Q_SPY
39
40// unnamed namespace for local definitions with internal linkage
41namespace {
42//Q_DEFINE_THIS_MODULE("qf_act")
43} // unnamed namespace
44
45namespace QP {
46
47// QP version string embedded in the binary image
48char const versionStr[] = "QP/C++ " QP_VERSION_STR;
49
51
52namespace QF {
53
55
56void bzero_(
57 void * const start,
58 std::uint_fast16_t const len) noexcept
59{
60 std::uint8_t *ptr = static_cast<std::uint8_t *>(start);
61 for (std::uint_fast16_t n = len; n > 0U; --n) {
62 *ptr = 0U;
63 ++ptr;
64 }
65}
66
67} // namespace QF
68
69//............................................................................
70#ifndef QF_LOG2
71std::uint_fast8_t QF_LOG2(QP::QPSetBits const bitmask) noexcept {
72 static constexpr std::uint8_t log2LUT[16] = {
73 0U, 1U, 2U, 2U, 3U, 3U, 3U, 3U,
74 4U, 4U, 4U, 4U, 4U, 4U, 4U, 4U
75 };
76 std::uint_fast8_t n = 0U;
77 QP::QPSetBits x = bitmask;
78 QP::QPSetBits tmp;
79
80#if (QF_MAX_ACTIVE > 16U)
81 tmp = static_cast<QP::QPSetBits>(x >> 16U);
82 if (tmp != 0U) {
83 n += 16U;
84 x = tmp;
85 }
86#endif
87#if (QF_MAX_ACTIVE > 8U)
88 tmp = (x >> 8U);
89 if (tmp != 0U) {
90 n += 8U;
91 x = tmp;
92 }
93#endif
94 tmp = (x >> 4U);
95 if (tmp != 0U) {
96 n += 4U;
97 x = tmp;
98 }
99 return n + log2LUT[x];
100}
101#endif // ndef QF_LOG2
102
103} // namespace QP
104
Active object class (based on the QHsm implementation strategy)
Definition qp.hpp:563
static QActive * registry_[QF_MAX_ACTIVE+1U]
Definition qp.hpp:581
Private attributes of the QF framework.
Definition qp_pkg.hpp:41
QF Active Object Framework namespace.
void bzero_(void *const start, std::uint_fast16_t const len) noexcept
Definition qf_act.cpp:56
QF::Attr priv_
Definition qf_act.cpp:54
QP/C++ framework.
Definition qequeue.hpp:36
char const versionStr[24]
Definition qf_act.cpp:48
std::uint_fast8_t QF_LOG2(QP::QPSetBits const bitmask) noexcept
Definition qf_act.cpp:71
std::uint32_t QPSetBits
Definition qp.hpp:471
#define QP_VERSION_STR
Version string complying with Semantic Versioning
Definition qp.hpp:33
#define QF_MAX_ACTIVE
Maximum # Active Objects in the system (1..64)
Internal (package scope) QP/C++ interface.
Sample QP/C++ port.
QS/C++ dummy public interface.
Sample QS/C++ port.
QP Functional Safety (FuSa) Subsystem.