Skip to content

re-generated files from qm #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions include/qequeue.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
//$file${include::qequeue.hpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: qpcpp.qm
// File: ${include::qequeue.hpp}
//
// This code has been generated by QM 6.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
//
// ____________________________________
// / /
// / GGGGGGG PPPPPPPP LL /
// / GG GG PP PP LL /
// / GG PP PP LL /
// / GG GGGGG PPPPPPPP LL /
// / GG GG PP LL /
// / GGGGGGG PP LLLLLLL /
// /___________________________________/
//
// Copyright (c) 2005 Quantum Leaps, LLC
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This generated code is open-source software licensed under the GNU
// General Public License (GPL) as published by the Free Software Foundation
// (see <https://www.gnu.org/licenses>).
//
// NOTE:
// The GPL does NOT permit the incorporation of this code into proprietary
// programs. Please contact Quantum Leaps for commercial licensing options,
// which expressly supersede the GPL and are designed explicitly for licensees
// interested in retaining the proprietary status of the generated code.
//
// Quantum Leaps contact information:
// <www.state-machine.com/licensing>
// <[email protected]>
//
//$endhead${include::qequeue.hpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#ifndef QEQUEUE_HPP_
#define QEQUEUE_HPP_

#ifndef QF_EQUEUE_CTR_SIZE
#define QF_EQUEUE_CTR_SIZE 1U
#endif

namespace QP {

#if (QF_EQUEUE_CTR_SIZE == 1U)
using QEQueueCtr = std::uint8_t;
#elif (QF_EQUEUE_CTR_SIZE == 2U)
using QEQueueCtr = std::uint16_t;
#elif (QF_EQUEUE_CTR_SIZE == 4U)
using QEQueueCtr = std::uint32_t;
#else
#error "QF_EQUEUE_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U"
#endif

class QEvt; // forward declaration

} // namespace QP

//$declare${QF::QEQueue} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

//${QF::QEQueue} .............................................................
class QEQueue {
private:
QEvt const * volatile m_frontEvt;
QEvt const ** m_ring;
QEQueueCtr m_end;
QEQueueCtr volatile m_head;
QEQueueCtr volatile m_tail;
QEQueueCtr volatile m_nFree;
QEQueueCtr m_nMin;

// friends...
friend class QActive;
friend class QTicker;
friend class QXMutex;
friend class QXThread;

public:
QEQueue() noexcept
: m_frontEvt(nullptr),
m_ring(nullptr),
m_end(0U),
m_head(0U),
m_tail(0U),
m_nFree(0U),
m_nMin(0U)
{}
void init(
QEvt const * qSto[],
std::uint_fast16_t const qLen) noexcept;
bool post(
QEvt const * const e,
std::uint_fast16_t const margin,
std::uint_fast8_t const qs_id) noexcept;
void postLIFO(
QEvt const * const e,
std::uint_fast8_t const qs_id) noexcept;
QEvt const * get(std::uint_fast8_t const qs_id) noexcept;
QEQueueCtr getNFree() const noexcept {
return m_nFree;
}
QEQueueCtr getNMin() const noexcept {
return m_nMin;
}
bool isEmpty() const noexcept {
return m_frontEvt == nullptr;
}

private:
QEQueue(QEQueue const & other) = delete;
QEQueue & operator=(QEQueue const & other) = delete;
}; // class QEQueue

} // namespace QP
//$enddecl${QF::QEQueue} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#endif // QEQUEUE_HPP_
175 changes: 175 additions & 0 deletions include/qk.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
//$file${include::qk.hpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: qpcpp.qm
// File: ${include::qk.hpp}
//
// This code has been generated by QM 6.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
//
// ____________________________________
// / /
// / GGGGGGG PPPPPPPP LL /
// / GG GG PP PP LL /
// / GG PP PP LL /
// / GG GGGGG PPPPPPPP LL /
// / GG GG PP LL /
// / GGGGGGG PP LLLLLLL /
// /___________________________________/
//
// Copyright (c) 2005 Quantum Leaps, LLC
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This generated code is open-source software licensed under the GNU
// General Public License (GPL) as published by the Free Software Foundation
// (see <https://www.gnu.org/licenses>).
//
// NOTE:
// The GPL does NOT permit the incorporation of this code into proprietary
// programs. Please contact Quantum Leaps for commercial licensing options,
// which expressly supersede the GPL and are designed explicitly for licensees
// interested in retaining the proprietary status of the generated code.
//
// Quantum Leaps contact information:
// <www.state-machine.com/licensing>
// <[email protected]>
//
//$endhead${include::qk.hpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#ifndef QK_HPP_
#define QK_HPP_

//$declare${QK::QSchedStatus} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

//${QK::QSchedStatus} ........................................................
using QSchedStatus = std::uint_fast16_t;

} // namespace QP
//$enddecl${QK::QSchedStatus} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$declare${QK::QK-base} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {
namespace QK {

//${QK::QK-base::schedLock} ..................................................
QSchedStatus schedLock(std::uint_fast8_t const ceiling) noexcept;

//${QK::QK-base::schedUnlock} ................................................
void schedUnlock(QSchedStatus const stat) noexcept;

//${QK::QK-base::onIdle} .....................................................
void onIdle();

} // namespace QK
} // namespace QP
//$enddecl${QK::QK-base} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extern "C" {
//$declare${QK-extern-C} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

//${QK-extern-C::QK_Attr} ....................................................
class QK_Attr {
public:
QP::QPSet readySet;

#ifndef Q_UNSAFE
QP::QPSet readySet_dis;
#endif // ndef Q_UNSAFE
std::uint_fast8_t volatile actPrio;
std::uint_fast8_t volatile nextPrio;
std::uint_fast8_t volatile actThre;
std::uint_fast8_t volatile lockCeil;
std::uint_fast8_t volatile lockHolder;
std::uint_fast8_t volatile intNest;
}; // class QK_Attr

//${QK-extern-C::QK_priv_} ...................................................
extern QK_Attr QK_priv_;

//${QK-extern-C::QK_sched_} ..................................................
std::uint_fast8_t QK_sched_() noexcept;

//${QK-extern-C::QK_activate_} ...............................................
void QK_activate_() noexcept;
//$enddecl${QK-extern-C} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
} // extern "C"

//============================================================================
// interface used only for internal implementation, but not in applications
#ifdef QP_IMPL

//$declare${QK-impl} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

//${QK-impl::QF_SCHED_STAT_} .................................................
#define QF_SCHED_STAT_ QSchedStatus lockStat_;

//${QK-impl::QF_SCHED_LOCK_} .................................................
#define QF_SCHED_LOCK_(ceil_) do { \
if (QK_ISR_CONTEXT_()) { \
lockStat_ = 0xFFU; \
} else { \
lockStat_ = QK::schedLock((ceil_)); \
} \
} while (false)

//${QK-impl::QF_SCHED_UNLOCK_} ...............................................
#define QF_SCHED_UNLOCK_() do { \
if (lockStat_ != 0xFFU) { \
QK::schedUnlock(lockStat_); \
} \
} while (false)

//${QK-impl::QACTIVE_EQUEUE_WAIT_} ...........................................
#define QACTIVE_EQUEUE_WAIT_(me_) \
Q_ASSERT_INCRIT(320, (me_)->m_eQueue.m_frontEvt != nullptr)

//${QK-impl::QACTIVE_EQUEUE_SIGNAL_} .........................................
#ifndef Q_UNSAFE
#define QACTIVE_EQUEUE_SIGNAL_(me_) do { \
QK_priv_.readySet.insert( \
static_cast<std::uint_fast8_t>((me_)->m_prio)); \
QK_priv_.readySet.update_(&QK_priv_.readySet_dis); \
if (!QK_ISR_CONTEXT_()) { \
if (QK_sched_() != 0U) { \
QK_activate_(); \
} \
} \
} while (false)
#endif // ndef Q_UNSAFE

//${QK-impl::QACTIVE_EQUEUE_SIGNAL_} .........................................
#ifdef Q_UNSAFE
#define QACTIVE_EQUEUE_SIGNAL_(me_) do { \
QK_priv_.readySet.insert( \
static_cast<std::uint_fast8_t>((me_)->m_prio)); \
if (!QK_ISR_CONTEXT_()) { \
if (QK_sched_() != 0U) { \
QK_activate_(); \
} \
} \
} while (false)
#endif // def Q_UNSAFE
//$enddecl${QK-impl} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$declare${QF_EPOOL-impl} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

//${QF_EPOOL-impl::QF_EPOOL_TYPE_} ...........................................
#define QF_EPOOL_TYPE_ QMPool

//${QF_EPOOL-impl::QF_EPOOL_INIT_} ...........................................
#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \
(p_).init((poolSto_), (poolSize_), (evtSize_))

//${QF_EPOOL-impl::QF_EPOOL_EVENT_SIZE_} .....................................
#define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize())

//${QF_EPOOL-impl::QF_EPOOL_GET_} ............................................
#define QF_EPOOL_GET_(p_, e_, m_, qs_id_) \
((e_) = static_cast<QEvt *>((p_).get((m_), (qs_id_))))

//${QF_EPOOL-impl::QF_EPOOL_PUT_} ............................................
#define QF_EPOOL_PUT_(p_, e_, qs_id_) ((p_).put((e_), (qs_id_)))
//$enddecl${QF_EPOOL-impl} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#endif // QP_IMPL

#endif // QK_HPP_
155 changes: 155 additions & 0 deletions include/qmpool.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
//$file${include::qmpool.hpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: qpcpp.qm
// File: ${include::qmpool.hpp}
//
// This code has been generated by QM 6.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
//
// ____________________________________
// / /
// / GGGGGGG PPPPPPPP LL /
// / GG GG PP PP LL /
// / GG PP PP LL /
// / GG GGGGG PPPPPPPP LL /
// / GG GG PP LL /
// / GGGGGGG PP LLLLLLL /
// /___________________________________/
//
// Copyright (c) 2005 Quantum Leaps, LLC
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This generated code is open-source software licensed under the GNU
// General Public License (GPL) as published by the Free Software Foundation
// (see <https://www.gnu.org/licenses>).
//
// NOTE:
// The GPL does NOT permit the incorporation of this code into proprietary
// programs. Please contact Quantum Leaps for commercial licensing options,
// which expressly supersede the GPL and are designed explicitly for licensees
// interested in retaining the proprietary status of the generated code.
//
// Quantum Leaps contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${include::qmpool.hpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#ifndef QMPOOL_HPP_
#define QMPOOL_HPP_

#ifndef QF_MPOOL_SIZ_SIZE
#define QF_MPOOL_SIZ_SIZE 2U
#endif
#ifndef QF_MPOOL_CTR_SIZE
#define QF_MPOOL_CTR_SIZE 2U
#endif

namespace QP {

#if (QF_MPOOL_SIZ_SIZE == 1U)
using QMPoolSize = std::uint8_t;
#elif (QF_MPOOL_SIZ_SIZE == 2U)
using QMPoolSize = std::uint16_t;
#elif (QF_MPOOL_SIZ_SIZE == 4U)
using QMPoolSize = std::uint32_t;
#else
#error "QF_MPOOL_SIZ_SIZE defined incorrectly, expected 1U, 2U, or 4U"
#endif

#if (QF_MPOOL_CTR_SIZE == 1U)
using QMPoolCtr = std::uint8_t;
#elif (QF_MPOOL_CTR_SIZE == 2U)
using QMPoolCtr = std::uint16_t;
#elif (QF_MPOOL_CTR_SIZE == 4U)
using QMPoolCtr = std::uint32_t;
#else
#error "QF_MPOOL_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U"
#endif

} // namespace QP

#define QF_MPOOL_EL(evType_) struct { \
QP::QFreeBlock sto_[((sizeof(evType_) - 1U) \
/ sizeof(QP::QFreeBlock)) + 1U]; }
//$declare${QF::QFreeBlock} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

//${QF::QFreeBlock} ..........................................................
class QFreeBlock {
private:
QFreeBlock * m_next;

#ifndef Q_UNSAFE
std::uintptr_t m_next_dis;
#endif // ndef Q_UNSAFE
friend class QMPool;
}; // class QFreeBlock

} // namespace QP
//$enddecl${QF::QFreeBlock} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$declare${QF::QMPool} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

//${QF::QMPool} ..............................................................
class QMPool {
private:
QFreeBlock * m_start;
QFreeBlock * m_end;
QFreeBlock * volatile m_free_head;
QMPoolSize m_blockSize;
QMPoolCtr m_nTot;
QMPoolCtr volatile m_nFree;
QMPoolCtr m_nMin;

public:
QMPool()
: m_start(nullptr),
m_end(nullptr),
m_free_head(nullptr),
m_blockSize(0U),
m_nTot(0U),
m_nFree(0U),
m_nMin(0U)
{}
void init(
void * const poolSto,
std::uint_fast32_t const poolSize,
std::uint_fast16_t const blockSize) noexcept;
void * get(
std::uint_fast16_t const margin,
std::uint_fast8_t const qs_id) noexcept;
void put(
void * const block,
std::uint_fast8_t const qs_id) noexcept;
QMPoolSize getBlockSize() const noexcept;
QMPoolCtr getNMin() const noexcept {
return m_nMin;
}
QMPoolCtr getNFree() const noexcept {
return m_nFree;
}

private:
QMPool(QEQueue const & other) = delete;
QMPool & operator=(QMPool const & other) = delete;

public:

#ifdef QF_ISR_API
void * getFromISR(
std::uint_fast16_t const margin,
std::uint_fast8_t const qs_id) noexcept;
#endif // def QF_ISR_API

#ifdef QF_ISR_API
void putFromISR(
void * const b,
std::uint_fast8_t const qs_id) noexcept;
#endif // def QF_ISR_API
}; // class QMPool

} // namespace QP
//$enddecl${QF::QMPool} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#endif // QMPOOL_HPP_
1,244 changes: 1,244 additions & 0 deletions include/qp.hpp

Large diffs are not rendered by default.

96 changes: 96 additions & 0 deletions include/qp_pkg.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//$file${include::qp_pkg.hpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: qpcpp.qm
// File: ${include::qp_pkg.hpp}
//
// This code has been generated by QM 6.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
//
// ____________________________________
// / /
// / GGGGGGG PPPPPPPP LL /
// / GG GG PP PP LL /
// / GG PP PP LL /
// / GG GGGGG PPPPPPPP LL /
// / GG GG PP LL /
// / GGGGGGG PP LLLLLLL /
// /___________________________________/
//
// Copyright (c) 2005 Quantum Leaps, LLC
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This generated code is open-source software licensed under the GNU
// General Public License (GPL) as published by the Free Software Foundation
// (see <https://www.gnu.org/licenses>).
//
// NOTE:
// The GPL does NOT permit the incorporation of this code into proprietary
// programs. Please contact Quantum Leaps for commercial licensing options,
// which expressly supersede the GPL and are designed explicitly for licensees
// interested in retaining the proprietary status of the generated code.
//
// Quantum Leaps contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${include::qp_pkg.hpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#ifndef QP_PKG_HPP_
#define QP_PKG_HPP_

//$declare${QF::QF-pkg} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {
namespace QF {

//${QF::QF-pkg::Attr} ........................................................
class Attr {
public:

#if (QF_MAX_EPOOL > 0U)
QF_EPOOL_TYPE_ ePool_[QF_MAX_EPOOL];
#endif // (QF_MAX_EPOOL > 0U)

#if (QF_MAX_EPOOL > 0U)
std::uint_fast8_t maxPool_;
#endif // (QF_MAX_EPOOL > 0U)

#if (QF_MAX_EPOOL == 0U)
std::uint8_t dummy;
#endif // (QF_MAX_EPOOL == 0U)
}; // class Attr

//${QF::QF-pkg::priv_} .......................................................
extern QF::Attr priv_;

//${QF::QF-pkg::bzero_} ......................................................
void bzero_(
void * const start,
std::uint_fast16_t const len) noexcept;

} // namespace QF
} // namespace QP
//$enddecl${QF::QF-pkg} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#define QF_CONST_CAST_(type_, ptr_) const_cast<type_>(ptr_)
#define QF_PTR_RANGE_(x_, min_, max_) (((min_) <= (x_)) && ((x_) <= (max_)))
#define Q_UINTPTR_CAST_(ptr_) (reinterpret_cast<std::uintptr_t>(ptr_))
#define Q_ACTION_CAST(act_) (reinterpret_cast<QP::QActionHandler>(act_))

namespace QP {

// Bitmasks are for the QTimeEvt::refCtr_ attribute (inherited from QEvt).
// In QTimeEvt this attribute is NOT used for reference counting.
constexpr std::uint8_t TE_IS_LINKED = 1U << 7U; // flag
constexpr std::uint8_t TE_WAS_DISARMED = 1U << 6U; // flag
constexpr std::uint8_t TE_TICK_RATE = 0x0FU; // bitmask

inline void QEvt_refCtr_inc_(QEvt const * const e) noexcept {
(QF_CONST_CAST_(QEvt*, e))->refCtr_ = e->refCtr_ + 1U;
}

inline void QEvt_refCtr_dec_(QEvt const * const e) noexcept {
(QF_CONST_CAST_(QEvt*, e))->refCtr_ = e->refCtr_ - 1U;
}

} // namespace QP

#endif // QP_PKG_HPP_
142 changes: 79 additions & 63 deletions src/qpcpp.hpp → include/qpcpp.hpp
Original file line number Diff line number Diff line change
@@ -3,52 +3,43 @@
// Model: qpcpp.qm
// File: ${include::qpcpp.hpp}
//
// This code has been generated by QM 5.2.5 <www.state-machine.com/qm>.
// This code has been generated by QM 6.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
//
// This code is covered by the following QP license:
// License # : LicenseRef-QL-dual
// Issued to : Any user of the QP/C++ real-time embedded framework
// Framework(s) : qpcpp
// Support ends : 2023-12-31
// License scope:
// ____________________________________
// / /
// / GGGGGGG PPPPPPPP LL /
// / GG GG PP PP LL /
// / GG PP PP LL /
// / GG GGGGG PPPPPPPP LL /
// / GG GG PP LL /
// / GGGGGGG PP LLLLLLL /
// /___________________________________/
//
// Copyright (C) 2005 Quantum Leaps, LLC <state-machine.com>.
// Copyright (c) 2005 Quantum Leaps, LLC
// SPDX-License-Identifier: GPL-3.0-or-later
//
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
// This generated code is open-source software licensed under the GNU
// General Public License (GPL) as published by the Free Software Foundation
// (see <https://www.gnu.org/licenses>).
//
// This software is dual-licensed under the terms of the open source GNU
// General Public License version 3 (or any later version), or alternatively,
// under the terms of one of the closed source Quantum Leaps commercial
// licenses.
// NOTE:
// The GPL does NOT permit the incorporation of this code into proprietary
// programs. Please contact Quantum Leaps for commercial licensing options,
// which expressly supersede the GPL and are designed explicitly for licensees
// interested in retaining the proprietary status of the generated code.
//
// The terms of the open source GNU General Public License version 3
// can be found at: <www.gnu.org/licenses/gpl-3.0>
//
// The terms of the closed source Quantum Leaps commercial licenses
// can be found at: <www.state-machine.com/licensing>
//
// Redistributions in source code must retain this top-level comment block.
// Plagiarizing this software to sidestep the license obligations is illegal.
//
// Contact information:
// Quantum Leaps contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${include::qpcpp.hpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//! @file
//! @brief QP/C++ public interface including backwards-compatibility layer
//!
//! @details
//! This header file must be included directly or indirectly
//! in all application modules (*.cpp files) that use QP/C++.

#ifndef QPCPP_HPP_

#define QPCPP_HPP_

//============================================================================
#include "qf_port.hpp" // QF/C++ port from the port directory
#include "qassert.h" // QP assertions
#include "qp_port.hpp" // QP port from the port directory
#include "qsafe.h" // QP Functional Safety (FuSa) Subsystem
#ifdef Q_SPY // software tracing enabled?
#include "qs_port.hpp" // QS/C++ port from the port directory
#else
@@ -58,40 +49,65 @@
//============================================================================
#ifndef QP_API_VERSION

//! Macro that specifies the backwards compatibility with the
//! QP/C++ API version.
//!
//! @details
//! For example, QP_API_VERSION=540 will cause generating the compatibility
//! layer with QP/C++ version 5.4.0 and newer, but not older than 5.4.0.
//! QP_API_VERSION=0 causes generation of the compatibility layer "from the
//! begining of time", which is the maximum backwards compatibilty. This is
//! the default.<br>
//!
//! Conversely, QP_API_VERSION=9999 means that no compatibility layer should
//! be generated. This setting is useful for checking if an application
//! complies with the latest QP/C++ API.
#define QP_API_VERSION 0

#endif // QP_API_VERSION

//============================================================================
// QP/C++ API compatibility layer...

#if (QP_API_VERSION < 700)

//! @deprecated use QP::QF::NO_MARGIN instead
#define QF_NO_MARGIN QP::QF::NO_MARGIN
#if (QP_API_VERSION < 730)

//! @deprecated plain 'char' is no longer forbidden in MISRA/AUTOSAR-C++
using char_t = char;

//! @deprecated assertion failure handler
//! Use Q_onError() instead.
#define Q_onAssert(module_, id_) Q_onError(module_, id_)

//! @deprecated #Q_NASSERT preprocessor switch to disable QP assertions
#ifdef Q_NASSERT

// #Q_UNSAFE now replaces the functionality of Q_NASSERT
#define Q_UNSAFE

//! @deprecated general purpose assertion with user-specified ID
//! number that **always** evaluates the `expr_` expression.
#define Q_ALLEGE_ID(id_, expr_) ((void)(expr_))

#else // QP FuSa Subsystem enabled

//! @deprecated general purpose assertion with user-specified ID
//! number that **always** evaluates the `expr_` expression.
//! @note
//! The use of this macro is no longer recommended.
#define Q_ALLEGE_ID(id_, expr_) if (!(expr_)) { \
QF_CRIT_STAT \
QF_CRIT_ENTRY(); \
Q_onError(&Q_this_module_[0], (id_)); \
QF_CRIT_EXIT(); \
} else ((void)0)

#endif

//! @deprecated general purpose assertion without ID number
//! that **always** evaluates the `expr_` expression.
//! Instead of ID number, this macro is based on the standard
//! `__LINE__` macro.
//!
//! @note The use of this macro is no longer recommended.
#define Q_ALLEGE(expr_) Q_ALLEGE_ID(__LINE__, (expr_))

//! Static (compile-time) assertion.
//!
//! @deprecated
//! Use Q_ASSERT_STATIC() or better yet `static_assert()` instead.
//!
#define Q_ASSERT_COMPILE(expr_) Q_ASSERT_STATIC(expr_)

//! @deprecated use QP::QF::NO_MARGIN instead
#define QF_NO_MARGIN QP::QF::NO_MARGIN

//============================================================================
#if (QP_API_VERSION < 691)

@@ -120,22 +136,22 @@ using char_t = char;

//! @deprecated local Filter for a generic application object `obj_`.
#define QS_FILTER_AP_OBJ(obj_) \
(QP::QS::priv_.locFilter_AP = (obj_))
(QP::QS::filt_.loc_AP = (obj_))

//! @deprecated begin of a user QS record, instead use QS_BEGIN_ID()
#define QS_BEGIN(rec_, obj_) \
if (QS_GLB_FILTER_(rec_) && \
((QP::QS::priv_.locFilter[QP::QS::AP_OBJ] == nullptr) \
|| (QP::QS::priv_.locFilter_AP == (obj_)))) \
{ \
QS_CRIT_STAT_ \
QS_CRIT_E_(); \
#define QS_BEGIN(rec_, obj_) \
if (QS_GLB_FILTER_(rec_) && \
((QP::QS::filt_.loc[QP::QS::AP_OBJ] == nullptr) \
|| (QP::QS::filt_.loc_AP == (obj_)))) \
{ \
QS_CRIT_STAT \
QS_CRIT_ENTRY(); \
QP::QS::beginRec_(static_cast<std::uint_fast8_t>(rec_)); \
QS_TIME_PRE_();

//! @deprecated output hex-formatted std::uint32_t to the QS record
#define QS_U32_HEX(width_, data_) \
(QP::QS::u32_fmt_(static_cast<std::uint8_t>( \
#define QS_U32_HEX(width_, data_) \
(QP::QS::u32_fmt_(static_cast<std::uint8_t>( \
(static_cast<std::uint8_t>((width_) << 4)) | QS_HEX_FMT), (data_)))

#else
@@ -150,7 +166,7 @@ using char_t = char;
#if (QP_API_VERSION < 680)

//! @deprecated
//! Macro to specify a transition in the "me->" impl-strategy.
//! Macro to specify a tran. in the "me->" impl-strategy.
//! Instead use the new impl-strategy without the "me->" pointer, where
//! you call tran(Q_STATE_CAST(target_)).
#define Q_TRAN(target_) (me->tran(Q_STATE_CAST(target_)))
@@ -186,7 +202,7 @@ using char_t = char;
#define QM_SM_EXIT(state_) (me->qm_sm_exit((state_)))

//! @deprecated
//! Macro to call in a QM state-handler when it executes a transition.
//! Macro to call in a QM state-handler when it executes a tran.
//! Instead use the new impl-strategy without the "me->" pointer, where
//! the QM-generated code calls qm_tran((tatbl_)).
#define QM_TRAN(tatbl_) (me->qm_tran((tatbl_)))
@@ -226,4 +242,4 @@ using char_t = char;
#endif // QP_API_VERSION < 691
#endif // QP_API_VERSION < 700

#endif // QPCPP_HPP_
#endif // QPCPP_HPP_
993 changes: 993 additions & 0 deletions include/qs.hpp

Large diffs are not rendered by default.

124 changes: 38 additions & 86 deletions src/qs_dummy.hpp → include/qs_dummy.hpp
Original file line number Diff line number Diff line change
@@ -3,43 +3,37 @@
// Model: qpcpp.qm
// File: ${include::qs_dummy.hpp}
//
// This code has been generated by QM 5.2.5 <www.state-machine.com/qm>.
// This code has been generated by QM 6.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
//
// This code is covered by the following QP license:
// License # : LicenseRef-QL-dual
// Issued to : Any user of the QP/C++ real-time embedded framework
// Framework(s) : qpcpp
// Support ends : 2023-12-31
// License scope:
// ____________________________________
// / /
// / GGGGGGG PPPPPPPP LL /
// / GG GG PP PP LL /
// / GG PP PP LL /
// / GG GGGGG PPPPPPPP LL /
// / GG GG PP LL /
// / GGGGGGG PP LLLLLLL /
// /___________________________________/
//
// Copyright (C) 2005 Quantum Leaps, LLC <state-machine.com>.
// Copyright (c) 2005 Quantum Leaps, LLC
// SPDX-License-Identifier: GPL-3.0-or-later
//
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
// This generated code is open-source software licensed under the GNU
// General Public License (GPL) as published by the Free Software Foundation
// (see <https://www.gnu.org/licenses>).
//
// This software is dual-licensed under the terms of the open source GNU
// General Public License version 3 (or any later version), or alternatively,
// under the terms of one of the closed source Quantum Leaps commercial
// licenses.
// NOTE:
// The GPL does NOT permit the incorporation of this code into proprietary
// programs. Please contact Quantum Leaps for commercial licensing options,
// which expressly supersede the GPL and are designed explicitly for licensees
// interested in retaining the proprietary status of the generated code.
//
// The terms of the open source GNU General Public License version 3
// can be found at: <www.gnu.org/licenses/gpl-3.0>
//
// The terms of the closed source Quantum Leaps commercial licenses
// can be found at: <www.state-machine.com/licensing>
//
// Redistributions in source code must retain this top-level comment block.
// Plagiarizing this software to sidestep the license obligations is illegal.
//
// Contact information:
// Quantum Leaps contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${include::qs_dummy.hpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//! @file
//! @brief Dummy definitions of the QS macros that avoid code generation from
//! the QS instrumentation.

#ifndef QS_DUMMY_HPP_
#define QS_DUMMY_HPP_

@@ -58,8 +52,8 @@

#define QS_BEGIN_ID(rec_, qs_id_) if (false) {
#define QS_END() }
#define QS_BEGIN_NOCRIT(rec_, qs_id_) if (false) {
#define QS_END_NOCRIT() }
#define QS_BEGIN_INCRIT(rec_, qs_id_) if (false) {
#define QS_END_INCRIT() }

#define QS_I8(width_, data_) static_cast<void>(0)
#define QS_U8(width_, data_) static_cast<void>(0)
@@ -94,63 +88,16 @@

#define QS_OUTPUT() static_cast<void>(0)
#define QS_RX_INPUT() static_cast<void>(0)
#define QS_ONLY(code_) static_cast<void>(0)

//============================================================================
//$declare${QS::QSpyIdOffsets} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

//${QS::QSpyIdOffsets} .......................................................
//! QS ID offsets for QS_LOC_FILTER()
enum QSpyIdOffsets : std::int16_t {
QS_AO_ID = 0, //!< offset for AO priorities
QS_EP_ID = 64, //!< offset for event-pool IDs
QS_EQ_ID = 80, //!< offset for event-queue IDs
QS_AP_ID = 96 //!< offset for Appl-spec IDs
};

} // namespace QP
//$enddecl${QS::QSpyIdOffsets} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//$declare${QS::QSpyIdGroups} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

//${QS::QSpyIdGroups} ........................................................
//! QS ID groups for QS_LOC_FILTER()
enum QSpyIdGroups : std::int16_t {
QS_ALL_IDS = 0xF0, //!< all QS IDs
QS_AO_IDS = 0x80 + QS_AO_ID, //!< AO IDs (priorities)
QS_EP_IDS = 0x80 + QS_EP_ID, //!< event-pool IDs
QS_EQ_IDS = 0x80 + QS_EQ_ID, //!< event-queue IDs
QS_AP_IDS = 0x80 + QS_AP_ID //!< Application-specific IDs
};

} // namespace QP
//$enddecl${QS::QSpyIdGroups} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//$declare${QS::QSpyId} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

//${QS::QSpyId} ..............................................................
//! QS ID type for applying local filtering
struct QSpyId {
std::uint8_t m_prio; //!< "priority" (qs_id) for the QS "local filter"

//! get the "priority" (qs_id) from the QSpyId opbject
std::uint_fast8_t getPrio() const noexcept {
return static_cast<std::uint_fast8_t>(m_prio);
}
};

} // namespace QP
//$enddecl${QS::QSpyId} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//============================================================================
// internal QS macros used only in the QP components

// interface used only for internal implementation, but not in applications
#ifdef QP_IMPL
// predefined QS trace records
#define QS_BEGIN_PRE_(rec_, qs_id_) if (false) {
#define QS_END_PRE_() }
#define QS_BEGIN_NOCRIT_PRE_(rec_, qs_id_) if (false) {
#define QS_END_NOCRIT_PRE_() }
#define QS_BEGIN_PRE_(rec_, qs_id_) if (false) {
#define QS_END_PRE_() }
#define QS_U8_PRE_(data_) static_cast<void>(0)
#define QS_2U8_PRE_(data1_, data2_) static_cast<void>(0)
#define QS_U16_PRE_(data_) static_cast<void>(0)
@@ -165,12 +112,17 @@ struct QSpyId {
#define QS_MPS_PRE_(size_) static_cast<void>(0)
#define QS_TEC_PRE_(ctr_) static_cast<void>(0)

#define QS_CRIT_STAT_
#define QF_QS_CRIT_ENTRY() static_cast<void>(0)
#define QF_QS_CRIT_EXIT() static_cast<void>(0)
#define QF_QS_ISR_ENTRY(isrnest_, prio_) static_cast<void>(0)
#define QF_QS_ISR_EXIT(isrnest_, prio_) static_cast<void>(0)
#define QF_QS_ACTION(act_) static_cast<void>(0)
#define QS_CRIT_STAT
#define QS_CRIT_ENTRY() static_cast<void>(0)
#define QS_CRIT_EXIT() static_cast<void>(0)

#define QS_MEM_SYS() static_cast<void>(0)
#define QS_MEM_APP() static_cast<void>(0)

#define QS_TR_CRIT_ENTRY() static_cast<void>(0)
#define QS_TR_CRIT_EXIT() static_cast<void>(0)
#define QS_TR_ISR_ENTRY(isrnest_, prio_) static_cast<void>(0)
#define QS_Tr_ISR_EXIT(isrnest_, prio_) static_cast<void>(0)
#endif // QP_IMPL

#endif // QS_DUMMY_HPP_
209 changes: 209 additions & 0 deletions include/qs_pkg.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
//$file${include::qs_pkg.hpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: qpcpp.qm
// File: ${include::qs_pkg.hpp}
//
// This code has been generated by QM 6.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
//
// ____________________________________
// / /
// / GGGGGGG PPPPPPPP LL /
// / GG GG PP PP LL /
// / GG PP PP LL /
// / GG GGGGG PPPPPPPP LL /
// / GG GG PP LL /
// / GGGGGGG PP LLLLLLL /
// /___________________________________/
//
// Copyright (c) 2005 Quantum Leaps, LLC
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This generated code is open-source software licensed under the GNU
// General Public License (GPL) as published by the Free Software Foundation
// (see <https://www.gnu.org/licenses>).
//
// NOTE:
// The GPL does NOT permit the incorporation of this code into proprietary
// programs. Please contact Quantum Leaps for commercial licensing options,
// which expressly supersede the GPL and are designed explicitly for licensees
// interested in retaining the proprietary status of the generated code.
//
// Quantum Leaps contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${include::qs_pkg.hpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#ifndef QS_PKG_HPP_
#define QS_PKG_HPP_

//============================================================================
//! @cond INTERNAL

namespace QP {

//! QS received record types (RX channel)
enum QSpyRxRecords : std::uint8_t {
QS_RX_INFO, //!< query Target info (ver, config, tstamp)
QS_RX_COMMAND, //!< execute a user-defined command in the Target
QS_RX_RESET, //!< reset the Target
QS_RX_TICK, //!< call system clock tick in the Target
QS_RX_PEEK, //!< peek Target memory
QS_RX_POKE, //!< poke Target memory
QS_RX_FILL, //!< fill Target memory
QS_RX_TEST_SETUP, //!< test setup
QS_RX_TEST_TEARDOWN, //!< test teardown
QS_RX_TEST_PROBE, //!< set a Test-Probe in the Target
QS_RX_GLB_FILTER, //!< set global filters in the Target
QS_RX_LOC_FILTER, //!< set local filters in the Target
QS_RX_AO_FILTER, //!< set local AO filter in the Target
QS_RX_CURR_OBJ, //!< set the "current-object" in the Target
QS_RX_TEST_CONTINUE, //!< continue a test after QS_TEST_PAUSE()
QS_RX_QUERY_CURR, //!< query the "current object" in the Target
QS_RX_EVENT //!< inject an event to the Target
};

constexpr std::uint8_t QS_FRAME {0x7EU};
constexpr std::uint8_t QS_ESC {0x7DU};
constexpr std::uint8_t QS_ESC_XOR {0x20U};
constexpr std::uint8_t QS_GOOD_CHKSUM {0xFFU};

} // namespace QP

//----------------------------------------------------------------------------
#define QS_BEGIN_PRE_(rec_, qs_id_) \
if (QS_GLB_CHECK_(rec_) && QS_LOC_CHECK_(qs_id_)) { \
QP::QS::beginRec_(static_cast<std::uint_fast8_t>(rec_));
#define QS_END_PRE_() QP::QS::endRec_(); }

#define QS_U8_PRE_(data_) \
(QP::QS::u8_raw_(static_cast<std::uint8_t>(data_)))
#define QS_2U8_PRE_(data1_, data2_) \
(QP::QS::u8u8_raw_(static_cast<std::uint8_t>(data1_), \
static_cast<std::uint8_t>(data2_)))
#define QS_U16_PRE_(data_) \
(QP::QS::u16_raw_(static_cast<std::uint16_t>(data_)))
#define QS_U32_PRE_(data_) \
(QP::QS::u32_raw_(static_cast<std::uint32_t>(data_)))
#define QS_STR_PRE_(msg_) (QP::QS::str_raw_(msg_))
#define QS_OBJ_PRE_(obj_) (QP::QS::obj_raw_(obj_))

#if (!defined Q_SIGNAL_SIZE || (Q_SIGNAL_SIZE == 1U))
#define QS_SIG_PRE_(sig_) \
(QP::QS::u8_raw_(static_cast<std::uint8_t>(sig_)))
#elif (Q_SIGNAL_SIZE == 2U)
#define QS_SIG_PRE_(sig_) \
(QP::QS::u16_raw_(static_cast<std::uint16_t>(sig_)))
#elif (Q_SIGNAL_SIZE == 4U)
#define QS_SIG_PRE_(sig_) \
(QP::QS::u32_raw_(static_cast<std::uint32_t>(sig_)))
#endif

#if (!defined QS_FUN_PTR_SIZE || (QS_FUN_PTR_SIZE == 2U))
#define QS_FUN_PRE_(fun_) \
(QP::QS::u16_raw_(reinterpret_cast<std::uint16_t>(fun_)))
#elif (QS_FUN_PTR_SIZE == 4U)
#define QS_FUN_PRE_(fun_) \
(QP::QS::u32_raw_(reinterpret_cast<std::uint32_t>(fun_)))
#elif (QS_FUN_PTR_SIZE == 8U)
#define QS_FUN_PRE_(fun_) \
(QP::QS::u64_raw_(reinterpret_cast<std::uint64_t>(fun_)))
#else
#define QS_FUN_PRE_(fun_) \
(QP::QS::u32_raw_(reinterpret_cast<std::uint32_t>(fun_)))
#endif

//----------------------------------------------------------------------------
#if (!defined QF_EQUEUE_CTR_SIZE || (QF_EQUEUE_CTR_SIZE == 1U))
#define QS_EQC_PRE_(ctr_) \
QP::QS::u8_raw_(static_cast<std::uint8_t>(ctr_))
#elif (QF_EQUEUE_CTR_SIZE == 2U)
#define QS_EQC_PRE_(ctr_) \
QP::QS::u16_raw_(static_cast<std::uint16_t>(ctr_))
#elif (QF_EQUEUE_CTR_SIZE == 4U)
#define QS_EQC_PRE_(ctr_) \
QP::QS::u32_raw_(static_cast<std::uint32_t>(ctr_))
#else
#error "QF_EQUEUE_CTR_SIZE not defined"
#endif

#if (!defined QF_EVENT_SIZ_SIZE || (QF_EVENT_SIZ_SIZE == 1U))
#define QS_EVS_PRE_(size_) \
QP::QS::u8_raw_(static_cast<std::uint8_t>(size_))
#elif (QF_EVENT_SIZ_SIZE == 2U)
#define QS_EVS_PRE_(size_) \
QP::QS::u16_raw_(static_cast<std::uint16_t>(size_))
#elif (QF_EVENT_SIZ_SIZE == 4U)
#define QS_EVS_PRE_(size_) \
QP::QS::u32_raw_(static_cast<std::uint32_t>(size_))
#endif

#if (!defined QF_MPOOL_SIZ_SIZE || (QF_MPOOL_SIZ_SIZE == 1U))
#define QS_MPS_PRE_(size_) \
QP::QS::u8_raw_(static_cast<std::uint8_t>(size_))
#elif (QF_MPOOL_SIZ_SIZE == 2U)
#define QS_MPS_PRE_(size_) \
QP::QS::u16_raw_(static_cast<std::uint16_t>(size_))
#elif (QF_MPOOL_SIZ_SIZE == 4U)
#define QS_MPS_PRE_(size_) \
QP::QS::u32_raw_(static_cast<std::uint32_t>(size_))
#endif

#if (!defined QF_MPOOL_CTR_SIZE || (QF_MPOOL_CTR_SIZE == 1U))
#define QS_MPC_PRE_(ctr_) \
QP::QS::u8_raw_(static_cast<std::uint8_t>(ctr_))
#elif (QF_MPOOL_CTR_SIZE == 2U)
#define QS_MPC_PRE_(ctr_) \
QP::QS::u16_raw_(static_cast<std::uint16_t>(ctr_))
#elif (QF_MPOOL_CTR_SIZE == 4U)
#define QS_MPC_PRE_(ctr_) \
QP::QS::u32_raw_(static_cast<std::uint32_t>(ctr_))
#endif

#if (!defined QF_TIMEEVT_CTR_SIZE || (QF_TIMEEVT_CTR_SIZE == 1U))
#define QS_TEC_PRE_(ctr_) \
QP::QS::u8_raw_(static_cast<std::uint8_t>(ctr_))
#elif (QF_TIMEEVT_CTR_SIZE == 2U)
#define QS_TEC_PRE_(ctr_) \
QP::QS::u16_raw_(static_cast<std::uint16_t>(ctr_))
#elif (QF_TIMEEVT_CTR_SIZE == 4U)
#define QS_TEC_PRE_(ctr_) \
QP::QS::u32_raw_(static_cast<std::uint32_t>(ctr_))
#endif

#define QS_REC_NUM_(enum_) (static_cast<std::uint_fast8_t>(enum_))

//----------------------------------------------------------------------------
#define QS_INSERT_BYTE_(b_) \
buf[head] = (b_); \
++head; \
if (head == end) { \
head = 0U; \
}

#define QS_INSERT_ESC_BYTE_(b_) \
chksum = static_cast<std::uint8_t>(chksum + (b_)); \
if (((b_) != QS_FRAME) && ((b_) != QS_ESC)) { \
QS_INSERT_BYTE_(b_) \
} \
else { \
QS_INSERT_BYTE_(QS_ESC) \
QS_INSERT_BYTE_(static_cast<std::uint8_t>((b_) ^ QS_ESC_XOR)) \
priv_.used = priv_.used + 1U; \
}

//----------------------------------------------------------------------------
#if (defined Q_UTEST) && (Q_UTEST != 0)
namespace QP {
namespace QS {

void processTestEvts_();

} // namespace QS
} // namespace QP
#endif // Q_UTEST != 0

//! @endcond
//============================================================================

#endif // QS_PKG_HPP_
45 changes: 45 additions & 0 deletions include/qstamp.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//$file${include::qstamp.hpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: qpcpp.qm
// File: ${include::qstamp.hpp}
//
// This code has been generated by QM 6.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
//
// ____________________________________
// / /
// / GGGGGGG PPPPPPPP LL /
// / GG GG PP PP LL /
// / GG PP PP LL /
// / GG GGGGG PPPPPPPP LL /
// / GG GG PP LL /
// / GGGGGGG PP LLLLLLL /
// /___________________________________/
//
// Copyright (c) 2005 Quantum Leaps, LLC
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This generated code is open-source software licensed under the GNU
// General Public License (GPL) as published by the Free Software Foundation
// (see <https://www.gnu.org/licenses>).
//
// NOTE:
// The GPL does NOT permit the incorporation of this code into proprietary
// programs. Please contact Quantum Leaps for commercial licensing options,
// which expressly supersede the GPL and are designed explicitly for licensees
// interested in retaining the proprietary status of the generated code.
//
// Quantum Leaps contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${include::qstamp.hpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#ifndef QSTAMP_HPP_
#define QSTAMP_HPP_

namespace QP {
extern char const BUILD_DATE[12];
extern char const BUILD_TIME[9];
} // namespace QP

#endif // QSTAMP_HPP_
119 changes: 119 additions & 0 deletions include/qv.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
//$file${include::qv.hpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: qpcpp.qm
// File: ${include::qv.hpp}
//
// This code has been generated by QM 6.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
//
// ____________________________________
// / /
// / GGGGGGG PPPPPPPP LL /
// / GG GG PP PP LL /
// / GG PP PP LL /
// / GG GGGGG PPPPPPPP LL /
// / GG GG PP LL /
// / GGGGGGG PP LLLLLLL /
// /___________________________________/
//
// Copyright (c) 2005 Quantum Leaps, LLC
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This generated code is open-source software licensed under the GNU
// General Public License (GPL) as published by the Free Software Foundation
// (see <https://www.gnu.org/licenses>).
//
// NOTE:
// The GPL does NOT permit the incorporation of this code into proprietary
// programs. Please contact Quantum Leaps for commercial licensing options,
// which expressly supersede the GPL and are designed explicitly for licensees
// interested in retaining the proprietary status of the generated code.
//
// Quantum Leaps contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${include::qv.hpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#ifndef QV_HPP_
#define QV_HPP_

//$declare${QV::QV-base} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {
namespace QV {

//${QV::QV-base::Attr} .......................................................
class Attr {
public:
QPSet readySet;

#ifndef Q_UNSAFE
QPSet readySet_dis;
#endif // ndef Q_UNSAFE
}; // class Attr

//${QV::QV-base::priv_} ......................................................
extern QV::Attr priv_;

//${QV::QV-base::onIdle} .....................................................
void onIdle();

} // namespace QV
} // namespace QP
//$enddecl${QV::QV-base} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//============================================================================
// interface used only for internal implementation, but not in applications
#ifdef QP_IMPL

//$declare${QV-impl} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

//${QV-impl::QF_SCHED_STAT_} .................................................
#define QF_SCHED_STAT_

//${QV-impl::QF_SCHED_LOCK_} .................................................
#define QF_SCHED_LOCK_(dummy) (static_cast<void>(0))

//${QV-impl::QF_SCHED_UNLOCK_} ...............................................
#define QF_SCHED_UNLOCK_() (static_cast<void>(0))

//${QV-impl::QACTIVE_EQUEUE_WAIT_} ...........................................
#define QACTIVE_EQUEUE_WAIT_(me_) \
Q_ASSERT_INCRIT(310, (me_)->m_eQueue.m_frontEvt != nullptr)

//${QV-impl::QACTIVE_EQUEUE_SIGNAL_} .........................................
#ifndef Q_UNSAFE
#define QACTIVE_EQUEUE_SIGNAL_(me_) \
QV::priv_.readySet.insert((me_)->m_prio); \
QV::priv_.readySet.update_(&QV::priv_.readySet_dis)
#endif // ndef Q_UNSAFE

//${QV-impl::QACTIVE_EQUEUE_SIGNAL_} .........................................
#ifdef Q_UNSAFE
#define QACTIVE_EQUEUE_SIGNAL_(me_) \
(QV::priv_.readySet.insert((me_)->m_prio))
#endif // def Q_UNSAFE
//$enddecl${QV-impl} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$declare${QF_EPOOL-impl} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

//${QF_EPOOL-impl::QF_EPOOL_TYPE_} ...........................................
#define QF_EPOOL_TYPE_ QMPool

//${QF_EPOOL-impl::QF_EPOOL_INIT_} ...........................................
#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \
(p_).init((poolSto_), (poolSize_), (evtSize_))

//${QF_EPOOL-impl::QF_EPOOL_EVENT_SIZE_} .....................................
#define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize())

//${QF_EPOOL-impl::QF_EPOOL_GET_} ............................................
#define QF_EPOOL_GET_(p_, e_, m_, qs_id_) \
((e_) = static_cast<QEvt *>((p_).get((m_), (qs_id_))))

//${QF_EPOOL-impl::QF_EPOOL_PUT_} ............................................
#define QF_EPOOL_PUT_(p_, e_, qs_id_) ((p_).put((e_), (qs_id_)))
//$enddecl${QF_EPOOL-impl} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#endif // QP_IMPL

#endif // QV_HPP_
336 changes: 336 additions & 0 deletions include/qxk.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,336 @@
//$file${include::qxk.hpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: qpcpp.qm
// File: ${include::qxk.hpp}
//
// This code has been generated by QM 6.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
//
// ____________________________________
// / /
// / GGGGGGG PPPPPPPP LL /
// / GG GG PP PP LL /
// / GG PP PP LL /
// / GG GGGGG PPPPPPPP LL /
// / GG GG PP LL /
// / GGGGGGG PP LLLLLLL /
// /___________________________________/
//
// Copyright (c) 2005 Quantum Leaps, LLC
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This generated code is open-source software licensed under the GNU
// General Public License (GPL) as published by the Free Software Foundation
// (see <https://www.gnu.org/licenses>).
//
// NOTE:
// The GPL does NOT permit the incorporation of this code into proprietary
// programs. Please contact Quantum Leaps for commercial licensing options,
// which expressly supersede the GPL and are designed explicitly for licensees
// interested in retaining the proprietary status of the generated code.
//
// Quantum Leaps contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${include::qxk.hpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#ifndef QXK_HPP_
#define QXK_HPP_

//$declare${QXK::QSchedStatus} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

//${QXK::QSchedStatus} .......................................................
using QSchedStatus = std::uint_fast16_t;

} // namespace QP
//$enddecl${QXK::QSchedStatus} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$declare${QXK::QXTHREAD_NO_TIMEOUT} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

//${QXK::QXTHREAD_NO_TIMEOUT} ................................................
constexpr QTimeEvtCtr QXTHREAD_NO_TIMEOUT {0U};

} // namespace QP
//$enddecl${QXK::QXTHREAD_NO_TIMEOUT} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$declare${QXK::QXK-base} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {
namespace QXK {

//${QXK::QXK-base::onIdle} ...................................................
void onIdle();

//${QXK::QXK-base::schedLock} ................................................
QSchedStatus schedLock(std::uint_fast8_t const ceiling) noexcept;

//${QXK::QXK-base::schedUnlock} ..............................................
void schedUnlock(QSchedStatus const stat) noexcept;

//${QXK::QXK-base::current} ..................................................
QP::QActive * current() noexcept;

} // namespace QXK
} // namespace QP
//$enddecl${QXK::QXK-base} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$declare${QXK::QXThread} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

//${QXK::QXThread} ...........................................................
class QXThread : public QP::QActive {
private:
QTimeEvt m_timeEvt;

public:
friend class QActive;
friend class QTimeEvt;
friend class QXSemaphore;
friend class QXMutex;

public:
static constexpr QTimeEvtCtr QXTHREAD_NO_TIMEOUT{0U};

public:
QXThread(
QXThreadHandler const handler,
std::uint_fast8_t const tickRate = 0U) noexcept;
void init(
void const * const e,
std::uint_fast8_t const qs_id) override;
void init(std::uint_fast8_t const qs_id) override {
this->init(nullptr, qs_id);
}
void dispatch(
QEvt const * const e,
std::uint_fast8_t const qs_id) override;
QTimeEvt const * getTimeEvt() const noexcept {
return &m_timeEvt;
}
static bool delay(QTimeEvtCtr const nTicks) noexcept;
bool delayCancel() noexcept;
static QEvt const * queueGet(QTimeEvtCtr const nTicks = QXTHREAD_NO_TIMEOUT) noexcept;

private:
void block_() const noexcept;
void unblock_() const noexcept;
static void timeout_(QActive * const act);
void teArm_(
enum_t const sig,
QTimeEvtCtr const nTicks) noexcept;
bool teDisarm_() noexcept;
void stackInit_(
QP::QXThreadHandler const handler,
void * const stkSto,
std::uint_fast16_t const stkSize) noexcept;
}; // class QXThread

} // namespace QP
//$enddecl${QXK::QXThread} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$declare${QXK::QXSemaphore} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

//${QXK::QXSemaphore} ........................................................
class QXSemaphore {
private:
QPSet m_waitSet;
std::uint8_t m_count;
std::uint8_t m_max_count;

public:
void init(
std::uint_fast8_t const count,
std::uint_fast8_t const max_count = 0xFFU) noexcept;
bool wait(QTimeEvtCtr const nTicks = QXTHREAD_NO_TIMEOUT) noexcept;
bool tryWait() noexcept;
bool signal() noexcept;
}; // class QXSemaphore

} // namespace QP
//$enddecl${QXK::QXSemaphore} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$declare${QXK::QXMutex} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

//${QXK::QXMutex} ............................................................
class QXMutex {
private:
QActive m_ao;
QPSet m_waitSet;

public:
QXMutex();
void init(QPrioSpec const prioSpec) noexcept;
bool lock(QTimeEvtCtr const nTicks = QXTHREAD_NO_TIMEOUT) noexcept;
bool tryLock() noexcept;
void unlock() noexcept;
}; // class QXMutex

} // namespace QP
//$enddecl${QXK::QXMutex} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

extern "C" {
//$declare${QXK-extern-C} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

//${QXK-extern-C::QXK_Attr} ..................................................
class QXK_Attr {
public:
QP::QActive * volatile curr;
QP::QActive * volatile next;
QP::QActive * volatile prev;
std::uint_fast8_t volatile actPrio;
std::uint_fast8_t volatile lockCeil;
std::uint_fast8_t volatile lockHolder;
QP::QPSet readySet;

#ifndef Q_UNSAFE
QP::QPSet readySet_dis;
#endif // ndef Q_UNSAFE
}; // class QXK_Attr

//${QXK-extern-C::QXK_priv_} .................................................
extern QXK_Attr QXK_priv_;

//${QXK-extern-C::QXK_sched_} ................................................
std::uint_fast8_t QXK_sched_() noexcept;

//${QXK-extern-C::QXK_activate_} .............................................
void QXK_activate_() noexcept;

//${QXK-extern-C::QXK_contextSw_} ............................................
void QXK_contextSw_(QP::QActive * const next);

//${QXK-extern-C::QXK_threadExit_} ...........................................
void QXK_threadExit_();
//$enddecl${QXK-extern-C} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
} // extern "C"

//============================================================================
// interface used only for internal implementation, but not in applications
#ifdef QP_IMPL

//$declare${QXK-impl} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

//${QXK-impl::QF_SCHED_STAT_} ................................................
#define QF_SCHED_STAT_ QSchedStatus lockStat_;

//${QXK-impl::QF_SCHED_LOCK_} ................................................
#define QF_SCHED_LOCK_(ceil_) do { \
if (QXK_ISR_CONTEXT_()) { \
lockStat_ = 0xFFU; \
} else { \
lockStat_ = QXK::schedLock((ceil_)); \
} \
} while (false)

//${QXK-impl::QF_SCHED_UNLOCK_} ..............................................
#define QF_SCHED_UNLOCK_() do { \
if (lockStat_ != 0xFFU) { \
QXK::schedUnlock(lockStat_); \
} \
} while (false)

//${QXK-impl::QACTIVE_EQUEUE_WAIT_} ..........................................
// QXK native event queue waiting
#define QACTIVE_EQUEUE_WAIT_(me_) \
Q_ASSERT_INCRIT(310, (me_)->m_eQueue.m_frontEvt != nullptr)

//${QXK-impl::QACTIVE_EQUEUE_SIGNAL_} ........................................
#ifndef Q_UNSAFE
// QXK native event queue signalling
#define QACTIVE_EQUEUE_SIGNAL_(me_) do { \
QXK_priv_.readySet.insert( \
static_cast<std::uint_fast8_t>((me_)->m_prio)); \
QXK_priv_.readySet.update_(&QXK_priv_.readySet_dis); \
if (!QXK_ISR_CONTEXT_()) { \
if (QXK_sched_() != 0U) { \
QXK_activate_(); \
} \
} \
} while (false)
#endif // ndef Q_UNSAFE

//${QXK-impl::QACTIVE_EQUEUE_SIGNAL_} ........................................
#ifdef Q_UNSAFE
// QXK native event queue signalling
#define QACTIVE_EQUEUE_SIGNAL_(me_) do { \
QXK_priv_.readySet.insert( \
static_cast<std::uint_fast8_t>((me_)->m_prio)); \
if (!QXK_ISR_CONTEXT_()) { \
if (QXK_sched_() != 0U) { \
QXK_activate_(); \
} \
} \
} while (false)
#endif // def Q_UNSAFE

//${QXK-impl::QXTHREAD_EQUEUE_SIGNAL_} .......................................
#ifndef Q_UNSAFE
#define QXTHREAD_EQUEUE_SIGNAL_(me_) do { \
if ((me_)->m_temp.obj == QXK_PTR_CAST_(QMState*, &(me_)->m_eQueue)) { \
static_cast<void>(QXTHREAD_CAST_(me_)->teDisarm_()); \
QXK_priv_.readySet.insert( \
static_cast<std::uint_fast8_t>((me_)->m_prio)); \
QXK_priv_.readySet.update_(&QXK_priv_.readySet_dis); \
if (!QXK_ISR_CONTEXT_()) { \
static_cast<void>(QXK_sched_()); \
} \
} \
} while (false)
#endif // ndef Q_UNSAFE

//${QXK-impl::QXTHREAD_EQUEUE_SIGNAL_} .......................................
#ifdef Q_UNSAFE
#define QXTHREAD_EQUEUE_SIGNAL_(me_) do { \
if ((me_)->m_temp.obj == QXK_PTR_CAST_(QMState*, &(me_)->m_eQueue)) { \
static_cast<void>(QXTHREAD_CAST_(me_)->teDisarm_()); \
QXK_priv_.readySet.insert( \
static_cast<std::uint_fast8_t>((me_)->m_prio)); \
if (!QXK_ISR_CONTEXT_()) { \
static_cast<void>(QXK_sched_()); \
} \
} \
} while (false)
#endif // def Q_UNSAFE

//${QXK-impl::QXTHREAD_CAST_} ................................................
#define QXTHREAD_CAST_(ptr_) (static_cast<QP::QXThread *>(ptr_))

//${QXK-impl::QXK_PTR_CAST_} .................................................
#define QXK_PTR_CAST_(type_, ptr_) (reinterpret_cast<type_>(ptr_))
//$enddecl${QXK-impl} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$declare${QF_EPOOL-impl} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

//${QF_EPOOL-impl::QF_EPOOL_TYPE_} ...........................................
#define QF_EPOOL_TYPE_ QMPool

//${QF_EPOOL-impl::QF_EPOOL_INIT_} ...........................................
#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \
(p_).init((poolSto_), (poolSize_), (evtSize_))

//${QF_EPOOL-impl::QF_EPOOL_EVENT_SIZE_} .....................................
#define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize())

//${QF_EPOOL-impl::QF_EPOOL_GET_} ............................................
#define QF_EPOOL_GET_(p_, e_, m_, qs_id_) \
((e_) = static_cast<QEvt *>((p_).get((m_), (qs_id_))))

//${QF_EPOOL-impl::QF_EPOOL_PUT_} ............................................
#define QF_EPOOL_PUT_(p_, e_, qs_id_) ((p_).put((e_), (qs_id_)))
//$enddecl${QF_EPOOL-impl} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

namespace QP {
namespace QXK {
enum TimeoutSigs : QSignal {
DELAY_SIG = 1U,
TIMEOUT_SIG
};
} // namespace QXK
} // namespace QP

#endif // QP_IMPL

#endif // QXK_HPP_
11,980 changes: 11,980 additions & 0 deletions qpcpp.qm

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions qpcpp.qms
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<session version="6.2.3">
<group name="locked"/>
<group name="settings">
<item name="tabs">1</item>
<item name="windows">0</item>
<item name="grid">3</item>
<item name="backups">0</item>
</group>
<group name="windows"/>
<group name="search">
<item name="options">2032128</item>
<item name="replace">0</item>
</group>
<group name="vars"/>
<group name="tools">
<group name="tool">
<item name="icon">0</item>
<item name="title"></item>
<item name="command"></item>
<item name="args"></item>
<item name="dir"></item>
<item name="options">0</item>
</group>
<group name="tool">
<item name="icon">0</item>
<item name="title"></item>
<item name="command"></item>
<item name="args"></item>
<item name="dir"></item>
<item name="options">0</item>
</group>
<group name="tool">
<item name="icon">0</item>
<item name="title"></item>
<item name="command"></item>
<item name="args"></item>
<item name="dir"></item>
<item name="options">0</item>
</group>
<group name="tool">
<item name="icon">0</item>
<item name="title"></item>
<item name="command"></item>
<item name="args"></item>
<item name="dir"></item>
<item name="options">0</item>
</group>
<group name="tool">
<item name="icon">0</item>
<item name="title"></item>
<item name="command"></item>
<item name="args"></item>
<item name="dir"></item>
<item name="options">0</item>
</group>
</group>
</session>
395 changes: 0 additions & 395 deletions src/qassert.h

This file was deleted.

982 changes: 0 additions & 982 deletions src/qep.hpp

This file was deleted.

628 changes: 0 additions & 628 deletions src/qep_hsm.cpp

This file was deleted.

52 changes: 0 additions & 52 deletions src/qep_port.hpp

This file was deleted.

334 changes: 0 additions & 334 deletions src/qequeue.hpp

This file was deleted.

1,880 changes: 0 additions & 1,880 deletions src/qf.hpp

This file was deleted.

626 changes: 626 additions & 0 deletions src/qf/qep_hsm.cpp

Large diffs are not rendered by default.

348 changes: 217 additions & 131 deletions src/qep_msm.cpp → src/qf/qep_msm.cpp

Large diffs are not rendered by default.

126 changes: 126 additions & 0 deletions src/qf/qf_act.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
//$file${src::qf::qf_act.cpp} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: qpcpp.qm
// File: ${src::qf::qf_act.cpp}
//
// This code has been generated by QM 6.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
//
// ____________________________________
// / /
// / GGGGGGG PPPPPPPP LL /
// / GG GG PP PP LL /
// / GG PP PP LL /
// / GG GGGGG PPPPPPPP LL /
// / GG GG PP LL /
// / GGGGGGG PP LLLLLLL /
// /___________________________________/
//
// Copyright (c) 2005 Quantum Leaps, LLC
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This generated code is open-source software licensed under the GNU
// General Public License (GPL) as published by the Free Software Foundation
// (see <https://www.gnu.org/licenses>).
//
// NOTE:
// The GPL does NOT permit the incorporation of this code into proprietary
// programs. Please contact Quantum Leaps for commercial licensing options,
// which expressly supersede the GPL and are designed explicitly for licensees
// interested in retaining the proprietary status of the generated code.
//
// Quantum Leaps contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${src::qf::qf_act.cpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#define QP_IMPL // this is QP implementation
#include "qp_port.hpp" // QP port
#include "qp_pkg.hpp" // QP package-scope interface
#include "qsafe.h" // QP Functional Safety (FuSa) Subsystem
#ifdef Q_SPY // QS software tracing enabled?
#include "qs_port.hpp" // QS port
#include "qs_pkg.hpp" // QS facilities for pre-defined trace records
#else
#include "qs_dummy.hpp" // disable the QS software tracing
#endif // Q_SPY

// unnamed namespace for local definitions with internal linkage
namespace {
//Q_DEFINE_THIS_MODULE("qf_act")
} // unnamed namespace

//$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// Check for the minimum required QP version
#if (QP_VERSION < 730U) || (QP_VERSION != ((QP_RELEASE^4294967295U)%0x2710U))
#error qpcpp version 7.3.0 or higher required
#endif
//$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//$define${QF::QActive::registry_[QF_MAX_ACTIVE + 1U]} vvvvvvvvvvvvvvvvvvvvvvv
namespace QP {
QActive * QActive::registry_[QF_MAX_ACTIVE + 1U];

} // namespace QP
//$enddef${QF::QActive::registry_[QF_MAX_ACTIVE + 1U]} ^^^^^^^^^^^^^^^^^^^^^^^

//$define${QF::QF-pkg} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {
namespace QF {

//${QF::QF-pkg::priv_} .......................................................
QF::Attr priv_;

//${QF::QF-pkg::bzero_} ......................................................
void bzero_(
void * const start,
std::uint_fast16_t const len) noexcept
{
std::uint8_t *ptr = static_cast<std::uint8_t *>(start);
for (std::uint_fast16_t n = len; n > 0U; --n) {
*ptr = 0U;
++ptr;
}
}

} // namespace QF
} // namespace QP
//$enddef${QF::QF-pkg} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$define${QF::types::QF_LOG2} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

//${QF::types::QF_LOG2} ......................................................
#ifndef QF_LOG2
std::uint_fast8_t QF_LOG2(QP::QPSetBits x) noexcept {
static std::uint8_t const log2LUT[16] = {
0U, 1U, 2U, 2U, 3U, 3U, 3U, 3U,
4U, 4U, 4U, 4U, 4U, 4U, 4U, 4U
};
std::uint_fast8_t n = 0U;
QP::QPSetBits t;

#if (QF_MAX_ACTIVE > 16U)
t = static_cast<QP::QPSetBits>(x >> 16U);
if (t != 0U) {
n += 16U;
x = t;
}
#endif
#if (QF_MAX_ACTIVE > 8U)
t = (x >> 8U);
if (t != 0U) {
n += 8U;
x = t;
}
#endif
t = (x >> 4U);
if (t != 0U) {
n += 4U;
x = t;
}
return n + log2LUT[x];
}
#endif // ndef QF_LOG2

} // namespace QP
//$enddef${QF::types::QF_LOG2} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
439 changes: 439 additions & 0 deletions src/qf/qf_actq.cpp

Large diffs are not rendered by default.

103 changes: 53 additions & 50 deletions src/qf_defer.cpp → src/qf/qf_defer.cpp
Original file line number Diff line number Diff line change
@@ -3,47 +3,41 @@
// Model: qpcpp.qm
// File: ${src::qf::qf_defer.cpp}
//
// This code has been generated by QM 5.2.5 <www.state-machine.com/qm>.
// This code has been generated by QM 6.2.3 <www.state-machine.com/qm>.
// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
//
// This code is covered by the following QP license:
// License # : LicenseRef-QL-dual
// Issued to : Any user of the QP/C++ real-time embedded framework
// Framework(s) : qpcpp
// Support ends : 2023-12-31
// License scope:
// ____________________________________
// / /
// / GGGGGGG PPPPPPPP LL /
// / GG GG PP PP LL /
// / GG PP PP LL /
// / GG GGGGG PPPPPPPP LL /
// / GG GG PP LL /
// / GGGGGGG PP LLLLLLL /
// /___________________________________/
//
// Copyright (C) 2005 Quantum Leaps, LLC <state-machine.com>.
// Copyright (c) 2005 Quantum Leaps, LLC
// SPDX-License-Identifier: GPL-3.0-or-later
//
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
// This generated code is open-source software licensed under the GNU
// General Public License (GPL) as published by the Free Software Foundation
// (see <https://www.gnu.org/licenses>).
//
// This software is dual-licensed under the terms of the open source GNU
// General Public License version 3 (or any later version), or alternatively,
// under the terms of one of the closed source Quantum Leaps commercial
// licenses.
// NOTE:
// The GPL does NOT permit the incorporation of this code into proprietary
// programs. Please contact Quantum Leaps for commercial licensing options,
// which expressly supersede the GPL and are designed explicitly for licensees
// interested in retaining the proprietary status of the generated code.
//
// The terms of the open source GNU General Public License version 3
// can be found at: <www.gnu.org/licenses/gpl-3.0>
//
// The terms of the closed source Quantum Leaps commercial licenses
// can be found at: <www.state-machine.com/licensing>
//
// Redistributions in source code must retain this top-level comment block.
// Plagiarizing this software to sidestep the license obligations is illegal.
//
// Contact information:
// Quantum Leaps contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${src::qf::qf_defer.cpp} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//! @file
//! @brief QActive::defer(), QActive::recall(), and
//! QActive::flushDeferred() definitions.

#define QP_IMPL // this is QP implementation
#include "qf_port.hpp" // QF port
#include "qf_pkg.hpp" // QF package-scope interface
#include "qassert.h" // QP embedded systems-friendly assertions
#include "qp_port.hpp" // QP port
#include "qp_pkg.hpp" // QP package-scope interface
#include "qsafe.h" // QP Functional Safety (FuSa) Subsystem
#ifdef Q_SPY // QS software tracing enabled?
#include "qs_port.hpp" // QS port
#include "qs_pkg.hpp" // QS facilities for pre-defined trace records
@@ -58,11 +52,10 @@ Q_DEFINE_THIS_MODULE("qf_defer")

//$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// Check for the minimum required QP version
#if (QP_VERSION < 700U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpcpp version 7.0.0 or higher required
#if (QP_VERSION < 730U) || (QP_VERSION != ((QP_RELEASE^4294967295U)%0x2710U))
#error qpcpp version 7.3.0 or higher required
#endif
//$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$define${QF::QActive::defer} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

@@ -72,78 +65,88 @@ bool QActive::defer(
QEvt const * const e) const noexcept
{
bool const status = eq->post(e, 0U, m_prio);
QS_CRIT_STAT_

QS_CRIT_STAT
QS_CRIT_ENTRY();
QS_MEM_SYS();
QS_BEGIN_PRE_(QS_QF_ACTIVE_DEFER, m_prio)
QS_TIME_PRE_(); // time stamp
QS_OBJ_PRE_(this); // this active object
QS_OBJ_PRE_(eq); // the deferred queue
QS_SIG_PRE_(e->sig); // the signal of the event
QS_2U8_PRE_(e->poolId_, e->refCtr_); // pool Id & ref Count
QS_2U8_PRE_(e->getPoolId_(), e->refCtr_); // poolId & refCtr
QS_END_PRE_()
QS_MEM_APP();
QS_CRIT_EXIT();

return status;
}

} // namespace QP
//$enddef${QF::QActive::defer} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$define${QF::QActive::recall} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

//${QF::QActive::recall} .....................................................
bool QActive::recall(QEQueue * const eq) noexcept {
QEvt const * const e = eq->get(m_prio); // get evt from deferred queue
bool recalled;
QF_CRIT_STAT

// event available?
if (e != nullptr) {
QActive::postLIFO(e); // post it to the _front_ of the AO's queue
bool recalled;
if (e != nullptr) { // event available?
postLIFO(e); // post it to the _front_ of the AO's queue

QF_CRIT_STAT_
QF_CRIT_E_();
QF_CRIT_ENTRY();
QF_MEM_SYS();

// is it a dynamic event?
if (e->poolId_ != 0U) {
if (e->getPoolId_() != 0U) { // is it a mutable event?

// after posting to the AO's queue the event must be referenced
// at least twice: once in the deferred event queue (eq->get()
// did NOT decrement the reference counter) and once in the
// AO's event queue.
Q_ASSERT_CRIT_(210, e->refCtr_ >= 2U);
Q_ASSERT_INCRIT(210, e->refCtr_ >= 2U);

// we need to decrement the reference counter once, to account
// for removing the event from the deferred event queue.
QEvt_refCtr_dec_(e); // decrement the reference counter
}

QS_BEGIN_NOCRIT_PRE_(QS_QF_ACTIVE_RECALL, m_prio)
QS_BEGIN_PRE_(QS_QF_ACTIVE_RECALL, m_prio)
QS_TIME_PRE_(); // time stamp
QS_OBJ_PRE_(this); // this active object
QS_OBJ_PRE_(eq); // the deferred queue
QS_SIG_PRE_(e->sig); // the signal of the event
QS_2U8_PRE_(e->poolId_, e->refCtr_); // pool Id & ref Count
QS_END_NOCRIT_PRE_()
QS_2U8_PRE_(e->getPoolId_(), e->refCtr_); // poolId & refCtr
QS_END_PRE_()

QF_MEM_APP();
QF_CRIT_EXIT();

QF_CRIT_X_();
recalled = true;
}
else {
QS_CRIT_STAT_
QS_CRIT_ENTRY();
QS_MEM_SYS();

QS_BEGIN_PRE_(QS_QF_ACTIVE_RECALL_ATTEMPT, m_prio)
QS_TIME_PRE_(); // time stamp
QS_OBJ_PRE_(this); // this active object
QS_OBJ_PRE_(eq); // the deferred queue
QS_END_PRE_()

QS_MEM_APP();
QS_CRIT_EXIT();

recalled = false;
}
return recalled;

}

} // namespace QP
//$enddef${QF::QActive::recall} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//$define${QF::QActive::flushDeferred} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
namespace QP {

Loading