mirror of
https://github.com/QuantumLeaps/qpcpp.git
synced 2025-01-28 06:02:56 +08:00
7.3.3
bug https://sourceforge.net/p/qpc/bugs/349/ QS adaptation for MPU isolation
This commit is contained in:
parent
ac99a2774a
commit
a2c05d3b05
@ -1 +1 @@
|
||||
Subproject commit 025100adc4853702cd6ce6fa733b206c6a70ee8a
|
||||
Subproject commit ebe4896f82bdb7b883f42f930307d243a4cd43d6
|
2
examples
2
examples
@ -1 +1 @@
|
||||
Subproject commit 9b8141914cce0d7320b1407c0c4c2448f046c271
|
||||
Subproject commit c89346fe6c765ac03d6d55d7ee0aa9c082bfa046
|
@ -99,11 +99,6 @@
|
||||
|
||||
//! @endcond
|
||||
//============================================================================
|
||||
#ifdef QEVT_DYN_CTOR
|
||||
#include <new> // for placement new
|
||||
#include <cstdarg> // for va_list
|
||||
#endif // QEVT_DYN_CTOR
|
||||
|
||||
//$declare${glob-types} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||
|
||||
//${glob-types::int_t} .......................................................
|
||||
@ -155,19 +150,16 @@ public:
|
||||
#endif // def QEVT_DYN_CTOR
|
||||
|
||||
public:
|
||||
QEvt() = delete;
|
||||
|
||||
#ifdef QEVT_DYN_CTOR
|
||||
QEvt * ctor(DynEvt const dummy) noexcept;
|
||||
#endif // def QEVT_DYN_CTOR
|
||||
explicit constexpr QEvt(QSignal const s) noexcept
|
||||
: sig(s),
|
||||
refCtr_(0U),
|
||||
evtTag_(MARKER)
|
||||
{}
|
||||
|
||||
#ifdef QEVT_DYN_CTOR
|
||||
explicit QEvt(DynEvt dummy) noexcept {
|
||||
static_cast<void>(dummy); // unused parameter
|
||||
// dynamic event already initialized in QP::QF::newX_()
|
||||
}
|
||||
#endif // def QEVT_DYN_CTOR
|
||||
QEvt() = delete;
|
||||
static bool verify_(QEvt const * const e) noexcept {
|
||||
return (e != nullptr)
|
||||
&& ((e->evtTag_ & 0xF0U) == MARKER);
|
||||
@ -1188,9 +1180,8 @@ void QF_onContextSw(
|
||||
|
||||
//${QF-macros::Q_NEW} ........................................................
|
||||
#ifdef QEVT_DYN_CTOR
|
||||
#define Q_NEW(evtT_, sig_, ...) (static_cast<evtT_ *>( \
|
||||
new(QP::QF::newX_(sizeof(evtT_), QP::QF::NO_MARGIN, (sig_))) \
|
||||
evtT_(__VA_ARGS__)))
|
||||
#define Q_NEW(evtT_, sig_, ...) ( static_cast<evtT_ *>( \
|
||||
QP::QF::newX_(sizeof(evtT_), QP::QF::NO_MARGIN, (sig_)))->ctor(__VA_ARGS__))
|
||||
#endif // def QEVT_DYN_CTOR
|
||||
|
||||
//${QF-macros::Q_NEW_X} ......................................................
|
||||
@ -1201,9 +1192,8 @@ void QF_onContextSw(
|
||||
|
||||
//${QF-macros::Q_NEW_X} ......................................................
|
||||
#ifdef QEVT_DYN_CTOR
|
||||
#define Q_NEW_X(evtT_, margin_, sig_, ...) (static_cast<evtT_ *>( \
|
||||
new(QP::QF::newX_(sizeof(evtT_), (margin_), (sig_))) \
|
||||
evtT_(__VA_ARGS__)))
|
||||
#define Q_NEW_X(evtT_, margin_, sig_, ...) ( static_cast<evtT_ *>( \
|
||||
QP::QF::newX_(sizeof(evtT_), (margin_), (sig_)))->ctor(__VA_ARGS__))
|
||||
#endif // def QEVT_DYN_CTOR
|
||||
|
||||
//${QF-macros::Q_NEW_REF} ....................................................
|
||||
|
372
include/qs.hpp
372
include/qs.hpp
@ -249,6 +249,36 @@ struct QSpyId {
|
||||
}
|
||||
};
|
||||
|
||||
//${QS::types::QSObj} ........................................................
|
||||
#if (QS_OBJ_PTR_SIZE == 2U)
|
||||
using QSObj = std::uint16_t;
|
||||
#endif // (QS_OBJ_PTR_SIZE == 2U)
|
||||
|
||||
//${QS::types::QSObj} ........................................................
|
||||
#if (QS_OBJ_PTR_SIZE == 4U)
|
||||
using QSObj = std::uint32_t;
|
||||
#endif // (QS_OBJ_PTR_SIZE == 4U)
|
||||
|
||||
//${QS::types::QSObj} ........................................................
|
||||
#if (QS_OBJ_PTR_SIZE == 8U)
|
||||
using QSObj = std::uint64_t;
|
||||
#endif // (QS_OBJ_PTR_SIZE == 8U)
|
||||
|
||||
//${QS::types::QSFun} ........................................................
|
||||
#if (QS_FUN_PTR_SIZE == 2U)
|
||||
using QSFun = std::uint16_t;
|
||||
#endif // (QS_FUN_PTR_SIZE == 2U)
|
||||
|
||||
//${QS::types::QSFun} ........................................................
|
||||
#if (QS_FUN_PTR_SIZE == 4U)
|
||||
using QSFun = std::uint32_t;
|
||||
#endif // (QS_FUN_PTR_SIZE == 4U)
|
||||
|
||||
//${QS::types::QSFun} ........................................................
|
||||
#if (QS_FUN_PTR_SIZE == 8U)
|
||||
using QSFun = std::uint64_t;
|
||||
#endif // (QS_FUN_PTR_SIZE == 8U)
|
||||
|
||||
//${QS::types::QSpyFunPtr} ...................................................
|
||||
using QSpyFunPtr = void (*)();
|
||||
|
||||
@ -272,21 +302,6 @@ using QSTimeCtr = std::uint16_t;
|
||||
using QSTimeCtr = std::uint32_t;
|
||||
#endif // (QS_TIME_SIZE == 4U)
|
||||
|
||||
//${QS::types::QSFun} ........................................................
|
||||
#if (QS_FUN_PTR_SIZE == 2U)
|
||||
using QSFun = std::uint16_t;
|
||||
#endif // (QS_FUN_PTR_SIZE == 2U)
|
||||
|
||||
//${QS::types::QSFun} ........................................................
|
||||
#if (QS_FUN_PTR_SIZE == 4U)
|
||||
using QSFun = std::uint32_t;
|
||||
#endif // (QS_FUN_PTR_SIZE == 4U)
|
||||
|
||||
//${QS::types::QSFun} ........................................................
|
||||
#if (QS_FUN_PTR_SIZE == 8U)
|
||||
using QSFun = std::uint64_t;
|
||||
#endif // (QS_FUN_PTR_SIZE == 8U)
|
||||
|
||||
} // namespace QP
|
||||
//$enddecl${QS::types} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
//$declare${QS::filters} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||
@ -624,71 +639,43 @@ void beginRec_(std::uint_fast8_t const rec) noexcept;
|
||||
void endRec_() noexcept;
|
||||
|
||||
void u8_raw_(std::uint8_t const d) noexcept;
|
||||
void u8u8_raw_(
|
||||
std::uint8_t const d1,
|
||||
std::uint8_t const d2) noexcept;
|
||||
void u8u8_raw_(std::uint8_t const d1, std::uint8_t const d2) noexcept;
|
||||
void u16_raw_(std::uint16_t d) noexcept;
|
||||
void u32_raw_(std::uint32_t d) noexcept;
|
||||
void u64_raw_(std::uint64_t d) noexcept;
|
||||
void obj_raw_(void const * const obj) noexcept;
|
||||
void str_raw_(char const * s) noexcept;
|
||||
|
||||
void u8_fmt_(
|
||||
std::uint8_t const format,
|
||||
std::uint8_t const d) noexcept;
|
||||
void u16_fmt_(
|
||||
std::uint8_t format,
|
||||
std::uint16_t d) noexcept;
|
||||
void u32_fmt_(
|
||||
std::uint8_t format,
|
||||
void u8_fmt_(std::uint8_t const format, std::uint8_t const d) noexcept;
|
||||
void u16_fmt_(std::uint8_t format, std::uint16_t d) noexcept;
|
||||
void u32_fmt_(std::uint8_t format,
|
||||
std::uint32_t d) noexcept;
|
||||
void u64_fmt_(
|
||||
std::uint8_t format,
|
||||
std::uint64_t d) noexcept;
|
||||
void f32_fmt_(
|
||||
std::uint8_t format,
|
||||
float32_t f) noexcept;
|
||||
void f64_fmt_(
|
||||
std::uint8_t format,
|
||||
float64_t d) noexcept;
|
||||
void u64_fmt_(std::uint8_t format, std::uint64_t d) noexcept;
|
||||
void f32_fmt_(std::uint8_t format, float32_t f) noexcept;
|
||||
void f64_fmt_(std::uint8_t format, float64_t d) noexcept;
|
||||
void str_fmt_(char const * s) noexcept;
|
||||
void mem_fmt_(
|
||||
std::uint8_t const * blk,
|
||||
std::uint8_t size) noexcept;
|
||||
void mem_fmt_(std::uint8_t const * blk, std::uint8_t size) noexcept;
|
||||
|
||||
void sig_dict_pre_(
|
||||
QSignal const sig,
|
||||
void const * const obj,
|
||||
void sig_dict_pre_(QSignal const sig, void const * const obj,
|
||||
char const * const name) noexcept;
|
||||
void obj_dict_pre_(
|
||||
void const * const obj,
|
||||
void obj_dict_pre_(void const * const obj,
|
||||
char const * const name) noexcept;
|
||||
void obj_arr_dict_pre_(
|
||||
void const * const obj,
|
||||
void obj_arr_dict_pre_(void const * const obj,
|
||||
std::uint_fast16_t const idx,
|
||||
char const * const name) noexcept;
|
||||
void fun_dict_pre_(
|
||||
QSpyFunPtr fun,
|
||||
void fun_dict_pre_(QSpyFunPtr fun,
|
||||
char const * const name) noexcept;
|
||||
void usr_dict_pre_(
|
||||
enum_t const rec,
|
||||
char const * const name) noexcept;
|
||||
void enum_dict_pre_(
|
||||
enum_t const value,
|
||||
std::uint8_t const group,
|
||||
void usr_dict_pre_(enum_t const rec, char const * const name) noexcept;
|
||||
void enum_dict_pre_(enum_t const value, std::uint8_t const group,
|
||||
char const * const name) noexcept;
|
||||
|
||||
void assertion_pre_(
|
||||
char const * const module,
|
||||
int_t const id,
|
||||
void assertion_pre_(char const * const module, int_t const id,
|
||||
std::uint32_t const delay) noexcept;
|
||||
void crit_entry_pre_() noexcept;
|
||||
void crit_exit_pre_() noexcept;
|
||||
void isr_entry_pre_(
|
||||
std::uint8_t const isrnest,
|
||||
void isr_entry_pre_(std::uint8_t const isrnest,
|
||||
std::uint8_t const prio) noexcept;
|
||||
void isr_exit_pre_(
|
||||
std::uint8_t const isrnest,
|
||||
void isr_exit_pre_(std::uint8_t const isrnest,
|
||||
std::uint8_t const prio) noexcept;
|
||||
|
||||
void target_info_pre_(std::uint8_t const isReset);
|
||||
@ -763,105 +750,6 @@ QSTimeCtr onGetTime();
|
||||
} // namespace QP
|
||||
//$enddecl${QS::QS-TX} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
//============================================================================
|
||||
//! @cond INTERNAL
|
||||
|
||||
namespace QP {
|
||||
namespace QS {
|
||||
|
||||
struct RxAttr {
|
||||
void * currObj[8];
|
||||
std::uint8_t * buf;
|
||||
QSCtr end;
|
||||
QSCtr volatile head;
|
||||
QSCtr volatile tail;
|
||||
#ifdef Q_UTEST
|
||||
bool inTestLoop;
|
||||
#endif
|
||||
} ;
|
||||
|
||||
extern RxAttr rxPriv_;
|
||||
|
||||
} // namespace QS
|
||||
} // namespace QP
|
||||
|
||||
//! @endcond
|
||||
//============================================================================
|
||||
|
||||
//$declare${QS::QS-RX} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||
namespace QP {
|
||||
namespace QS {
|
||||
|
||||
//${QS::QS-RX::QSpyObjKind} ..................................................
|
||||
//! Kinds of objects used QS-RX
|
||||
enum QSpyObjKind : std::uint8_t {
|
||||
SM_OBJ, //!< state machine object
|
||||
AO_OBJ, //!< active object
|
||||
MP_OBJ, //!< event pool object
|
||||
EQ_OBJ, //!< raw queue object
|
||||
TE_OBJ, //!< time event object
|
||||
AP_OBJ, //!< generic Application-specific object
|
||||
MAX_OBJ
|
||||
};
|
||||
|
||||
//${QS::QS-RX::OSpyObjCombnation} ............................................
|
||||
//! Object combinations for QS-RX
|
||||
enum OSpyObjCombnation : std::uint8_t {
|
||||
SM_AO_OBJ = MAX_OBJ //!< combination of SM and AO
|
||||
};
|
||||
|
||||
//${QS::QS-RX::rxInitBuf} ....................................................
|
||||
void rxInitBuf(
|
||||
std::uint8_t * const sto,
|
||||
std::uint16_t const stoSize) noexcept;
|
||||
|
||||
//${QS::QS-RX::rxPut} ........................................................
|
||||
inline bool rxPut(std::uint8_t const b) noexcept {
|
||||
// NOTE: does not need critical section
|
||||
// But requires system-level memory access (QF_MEM_SYS()).
|
||||
|
||||
QSCtr head = rxPriv_.head + 1U;
|
||||
if (head == rxPriv_.end) {
|
||||
head = 0U;
|
||||
}
|
||||
if (head != rxPriv_.tail) { // buffer NOT full?
|
||||
rxPriv_.buf[rxPriv_.head] = b;
|
||||
rxPriv_.head = head;
|
||||
return true; // byte placed in the buffer
|
||||
}
|
||||
else {
|
||||
return false; // byte NOT placed in the buffer
|
||||
}
|
||||
}
|
||||
|
||||
//${QS::QS-RX::rxParse} ......................................................
|
||||
void rxParse();
|
||||
|
||||
//${QS::QS-RX::setCurrObj} ...................................................
|
||||
void setCurrObj(
|
||||
std::uint8_t const obj_kind,
|
||||
void * const obj_ptr);
|
||||
|
||||
//${QS::QS-RX::rxGetNfree} ...................................................
|
||||
std::uint16_t rxGetNfree() noexcept;
|
||||
|
||||
//${QS::QS-RX::doInput} ......................................................
|
||||
void doInput();
|
||||
|
||||
//${QS::QS-RX::onReset} ......................................................
|
||||
void onReset();
|
||||
|
||||
//${QS::QS-RX::onCommand} ....................................................
|
||||
void onCommand(
|
||||
std::uint8_t cmdId,
|
||||
std::uint32_t param1,
|
||||
std::uint32_t param2,
|
||||
std::uint32_t param3);
|
||||
|
||||
} // namespace QS
|
||||
} // namespace QP
|
||||
//$enddecl${QS::QS-RX} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
//============================================================================
|
||||
#ifdef Q_UTEST
|
||||
|
||||
@ -1001,4 +889,170 @@ private:
|
||||
|
||||
#endif // Q_UTEST
|
||||
|
||||
//============================================================================
|
||||
//! @cond INTERNAL
|
||||
|
||||
namespace QP {
|
||||
namespace QS {
|
||||
|
||||
//............................................................................
|
||||
struct CmdVar {
|
||||
std::uint32_t param1;
|
||||
std::uint32_t param2;
|
||||
std::uint32_t param3;
|
||||
std::uint8_t idx;
|
||||
std::uint8_t cmdId;
|
||||
};
|
||||
|
||||
struct TickVar {
|
||||
std::uint_fast8_t rate;
|
||||
};
|
||||
|
||||
struct PeekVar {
|
||||
std::uint16_t offs;
|
||||
std::uint8_t size;
|
||||
std::uint8_t num;
|
||||
std::uint8_t idx;
|
||||
};
|
||||
|
||||
struct PokeVar {
|
||||
std::uint32_t data;
|
||||
std::uint16_t offs;
|
||||
std::uint8_t size;
|
||||
std::uint8_t num;
|
||||
std::uint8_t idx;
|
||||
std::uint8_t fill;
|
||||
};
|
||||
|
||||
struct FltVar {
|
||||
std::uint8_t data[16];
|
||||
std::uint8_t idx;
|
||||
std::uint8_t recId; // global/local
|
||||
};
|
||||
|
||||
struct ObjVar {
|
||||
QSObj addr;
|
||||
std::uint8_t idx;
|
||||
std::uint8_t kind; // see qs.hpp, enum QSpyObjKind
|
||||
std::uint8_t recId;
|
||||
};
|
||||
|
||||
struct EvtVar {
|
||||
QP::QEvt *e;
|
||||
std::uint8_t *p;
|
||||
QP::QSignal sig;
|
||||
std::uint16_t len;
|
||||
std::uint8_t prio;
|
||||
std::uint8_t idx;
|
||||
};
|
||||
|
||||
struct RxAttr {
|
||||
void * currObj[8];
|
||||
std::uint8_t * buf;
|
||||
QSCtr end;
|
||||
QSCtr volatile head;
|
||||
QSCtr volatile tail;
|
||||
std::uint8_t state;
|
||||
std::uint8_t esc;
|
||||
std::uint8_t seq;
|
||||
std::uint8_t chksum;
|
||||
#ifdef Q_UTEST
|
||||
bool inTestLoop;
|
||||
#endif
|
||||
union Variant {
|
||||
CmdVar cmd;
|
||||
TickVar tick;
|
||||
PeekVar peek;
|
||||
PokeVar poke;
|
||||
FltVar flt;
|
||||
ObjVar obj;
|
||||
EvtVar evt;
|
||||
#ifdef Q_UTEST
|
||||
QP::QS::TProbe tp;
|
||||
#endif // Q_UTEST
|
||||
} var;
|
||||
} ;
|
||||
|
||||
extern RxAttr rxPriv_;
|
||||
|
||||
} // namespace QS
|
||||
} // namespace QP
|
||||
|
||||
//! @endcond
|
||||
//============================================================================
|
||||
|
||||
//$declare${QS::QS-RX} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||
namespace QP {
|
||||
namespace QS {
|
||||
|
||||
//${QS::QS-RX::QSpyObjKind} ..................................................
|
||||
//! Kinds of objects used QS-RX
|
||||
enum QSpyObjKind : std::uint8_t {
|
||||
SM_OBJ, //!< state machine object
|
||||
AO_OBJ, //!< active object
|
||||
MP_OBJ, //!< event pool object
|
||||
EQ_OBJ, //!< raw queue object
|
||||
TE_OBJ, //!< time event object
|
||||
AP_OBJ, //!< generic Application-specific object
|
||||
MAX_OBJ
|
||||
};
|
||||
|
||||
//${QS::QS-RX::OSpyObjCombnation} ............................................
|
||||
//! Object combinations for QS-RX
|
||||
enum OSpyObjCombnation : std::uint8_t {
|
||||
SM_AO_OBJ = MAX_OBJ //!< combination of SM and AO
|
||||
};
|
||||
|
||||
//${QS::QS-RX::rxInitBuf} ....................................................
|
||||
void rxInitBuf(
|
||||
std::uint8_t * const sto,
|
||||
std::uint16_t const stoSize) noexcept;
|
||||
|
||||
//${QS::QS-RX::rxPut} ........................................................
|
||||
inline bool rxPut(std::uint8_t const b) noexcept {
|
||||
// NOTE: does not need critical section
|
||||
// But requires system-level memory access (QF_MEM_SYS()).
|
||||
|
||||
QSCtr head = rxPriv_.head + 1U;
|
||||
if (head == rxPriv_.end) {
|
||||
head = 0U;
|
||||
}
|
||||
if (head != rxPriv_.tail) { // buffer NOT full?
|
||||
rxPriv_.buf[rxPriv_.head] = b;
|
||||
rxPriv_.head = head;
|
||||
return true; // byte placed in the buffer
|
||||
}
|
||||
else {
|
||||
return false; // byte NOT placed in the buffer
|
||||
}
|
||||
}
|
||||
|
||||
//${QS::QS-RX::rxParse} ......................................................
|
||||
void rxParse();
|
||||
|
||||
//${QS::QS-RX::setCurrObj} ...................................................
|
||||
void setCurrObj(
|
||||
std::uint8_t const obj_kind,
|
||||
void * const obj_ptr);
|
||||
|
||||
//${QS::QS-RX::rxGetNfree} ...................................................
|
||||
std::uint16_t rxGetNfree() noexcept;
|
||||
|
||||
//${QS::QS-RX::doInput} ......................................................
|
||||
void doInput();
|
||||
|
||||
//${QS::QS-RX::onReset} ......................................................
|
||||
void onReset();
|
||||
|
||||
//${QS::QS-RX::onCommand} ....................................................
|
||||
void onCommand(
|
||||
std::uint8_t cmdId,
|
||||
std::uint32_t param1,
|
||||
std::uint32_t param2,
|
||||
std::uint32_t param3);
|
||||
|
||||
} // namespace QS
|
||||
} // namespace QP
|
||||
//$enddecl${QS::QS-RX} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
#endif // QS_HPP_
|
||||
|
42
ports/lint-plus/cstddef
Normal file
42
ports/lint-plus/cstddef
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef _CSTDDEF_
|
||||
#define _CSTDDEF_
|
||||
|
||||
//lint -save
|
||||
//lint -e9093 the name is reserved to the compiler
|
||||
//lint -e9141 global declaration of symbol 'operator new'
|
||||
//lint -e9215 unnamed parameter for 'non-virtual' function 'operator new'
|
||||
|
||||
namespace std {
|
||||
using ptrdiff_t = unsigned int;
|
||||
using size_t = unsigned int;
|
||||
using max_align_t = unsigned int;
|
||||
using nullptr_t = decltype(nullptr);
|
||||
|
||||
enum class byte : unsigned char {};
|
||||
|
||||
// byte type operations
|
||||
template<class IntType>
|
||||
constexpr byte& operator<<=(byte& b, IntType shift) noexcept;
|
||||
template<class IntType>
|
||||
constexpr byte operator<<(byte b, IntType shift) noexcept;
|
||||
template<class IntType>
|
||||
constexpr byte& operator>>=(byte& b, IntType shift) noexcept;
|
||||
template<class IntType>
|
||||
constexpr byte operator>>(byte b, IntType shift) noexcept;
|
||||
constexpr byte& operator|=(byte& l, byte r) noexcept;
|
||||
constexpr byte operator|(byte l, byte r) noexcept;
|
||||
constexpr byte& operator&=(byte& l, byte r) noexcept;
|
||||
constexpr byte operator&(byte l, byte r) noexcept;
|
||||
constexpr byte& operator^=(byte& l, byte r) noexcept;
|
||||
constexpr byte operator^(byte l, byte r) noexcept;
|
||||
constexpr byte operator~(byte b) noexcept;
|
||||
template<class IntType>
|
||||
constexpr IntType to_integer(byte b) noexcept;
|
||||
}
|
||||
|
||||
#define NULL nullptr
|
||||
//#define offsetof(type, member) ...
|
||||
|
||||
//lint -restore
|
||||
|
||||
#endif // _CSTDDEF_
|
@ -1,29 +0,0 @@
|
||||
#ifndef _NEW
|
||||
#define _NEW
|
||||
|
||||
namespace std {
|
||||
|
||||
typedef unsigned long size_t;
|
||||
|
||||
// These are replaceable signatures:
|
||||
// - normal single new and delete (no arguments, throw @c bad_alloc on error)
|
||||
// - normal array new and delete (same)
|
||||
// - @c nothrow single new and delete (take a @c nothrow argument, return
|
||||
// @c NULL on error)
|
||||
// - @c nothrow array new and delete (same)
|
||||
//
|
||||
// Placement new and delete signatures (take a memory address argument,
|
||||
// does nothing) may not be replaced by a user's program.
|
||||
//
|
||||
|
||||
// Default placement versions of operator new.
|
||||
inline void *operator new(size_t, void *__p) throw() { return __p; }
|
||||
inline void *operator new[](size_t, void *__p) throw() { return __p; }
|
||||
|
||||
// Default placement versions of operator delete.
|
||||
inline void operator delete (void *, void *) throw() { }
|
||||
inline void operator delete[](void *, void *) throw() { }
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif
|
@ -22,7 +22,7 @@
|
||||
// <www.state-machine.com>
|
||||
// <info@state-machine.com>
|
||||
//============================================================================
|
||||
//! @date Last updated on: 2023-09-08
|
||||
//! @date Last updated on: 2024-02-19
|
||||
//! @version Last updated for: @ref qpcpp_7_3_0
|
||||
//!
|
||||
//! @file
|
||||
@ -141,12 +141,13 @@ qpcpp.lnt // QP/C++ options
|
||||
-emacro(826,
|
||||
QTICKER_CAST_)
|
||||
|
||||
// AUTOSAR Rule M5-2-9 casting from pointer type to integer type
|
||||
// AC++M5-2-9 casting from pointer type to integer type
|
||||
-emacro(9091,
|
||||
Q_UINTPTR_CAST_)
|
||||
|
||||
// [AUTOSAR Rule A12-1-1] non-static data member not initialized by ctor
|
||||
// [AC++M12-1-1] non-static data member not initialized by ctor
|
||||
-esym(1401,
|
||||
QP::QEvt::*,
|
||||
QP::QActive::*)
|
||||
|
||||
// definition of macro ends in semi-colon
|
||||
@ -179,15 +180,6 @@ qpcpp.lnt // QP/C++ options
|
||||
-emacro(9079,
|
||||
QF_EPOOL_GET_)
|
||||
|
||||
-efunc(9079,
|
||||
QP::QF::bzero_,
|
||||
QP::QTimeEvt::armX,
|
||||
QP::QTimeEvt::disarm,
|
||||
QP::QTimeEvt::rearm,
|
||||
QP::QMPool::init,
|
||||
QP::QMPool::get,
|
||||
QP::QMPool::put)
|
||||
|
||||
// M3-R18.3(r) relational operator <= applied to pointers
|
||||
-emacro(946,
|
||||
QF_PTR_RANGE_)
|
||||
@ -208,16 +200,7 @@ qpcpp.lnt // QP/C++ options
|
||||
-esym(952,
|
||||
QP::QEQueue::init)
|
||||
|
||||
// call to unqualified virtual function 'QP::*::init'
|
||||
// from non-static member function
|
||||
-esym(1933,
|
||||
QP::*::init)
|
||||
|
||||
// [AUTOSAR Rule M7-3-1] lobal declaration of symbol 'dummy' in the file
|
||||
-esym(9141,
|
||||
dummy)
|
||||
|
||||
// AUTOSAR Rule M5-2-3: downcast of polymorphic type
|
||||
// AC++M5-2-3: downcast of polymorphic type
|
||||
-efunc(9171,
|
||||
QP::QActive::post_,
|
||||
QP::QActive::postLIFO)
|
||||
@ -227,11 +210,30 @@ qpcpp.lnt // QP/C++ options
|
||||
QP::QActive::post_,
|
||||
QP::QActive::postLIFO)
|
||||
|
||||
// PCLP-1939: casting from base class to derived class
|
||||
// [AC++M5-2-2]: casting from base class to derived class (QP::QActiveDummy)
|
||||
-efunc(1939,
|
||||
QP::QActive::post_,
|
||||
QP::QActive::postLIFO)
|
||||
|
||||
// PCLP-1731: public virtual function (in a class without virtual destructor)
|
||||
-esym(1731,
|
||||
QP::QTicker::*)
|
||||
|
||||
// PCLP-1933: call to unqualified virtual function from non-static member function
|
||||
-efunc(1933,
|
||||
QP::QActive::start)
|
||||
|
||||
// PCLP-9079:
|
||||
-efunc(9079,
|
||||
QP::QF::bzero_,
|
||||
QP::QTimeEvt::armX,
|
||||
QP::QTimeEvt::disarm,
|
||||
QP::QTimeEvt::rearm,
|
||||
QP::QMPool::init,
|
||||
QP::QMPool::get,
|
||||
QP::QMPool::put)
|
||||
|
||||
|
||||
// QV ------------------------------------------------------------------------
|
||||
// MC++R16-0-4 function-like macro
|
||||
-esym(9026,
|
||||
|
@ -22,8 +22,8 @@
|
||||
// <www.state-machine.com>
|
||||
// <info@state-machine.com>
|
||||
//============================================================================
|
||||
//! @date Last updated on: 2023-09-01
|
||||
//! @version Last updated for version: 7.3.0
|
||||
//! @date Last updated on: 2024-02-18
|
||||
//! @version Last updated for version: 7.3.3
|
||||
//!
|
||||
//! @file
|
||||
//! @brief PC-Lint-Plus option file for linting QP/C++ __Applications__
|
||||
@ -270,25 +270,6 @@
|
||||
Q_NEW_X,
|
||||
Q_NEW_REF)
|
||||
|
||||
// implicit conversion (call) from 'enum ...' to 'const enum_t'
|
||||
-emacro(713,
|
||||
Q_NEW,
|
||||
Q_NEW_X)
|
||||
|
||||
// implicit conversion of 'enum ...' to integral type 'enum_t'
|
||||
-emacro(641,
|
||||
Q_NEW,
|
||||
Q_NEW_X)
|
||||
|
||||
// public virtual function 'QP::QHsm::...'
|
||||
-esym(1731,
|
||||
QP::QActive::*,
|
||||
QP::QMActive::*,
|
||||
QP::QTicker::*)
|
||||
|
||||
// public base 'QP::QEvt' has no non-destructor virtual functions
|
||||
-esym(1790,
|
||||
QP::QEvt)
|
||||
|
||||
// QK ------------------------------------------------------------------------
|
||||
|
||||
@ -297,7 +278,7 @@
|
||||
QK_ISR_ENTRY,
|
||||
QK_ISR_EXIT)
|
||||
|
||||
// MC++R7-3-1 global declaration of symbol
|
||||
// AC++M7-3-1 global declaration of symbol
|
||||
-esym(9141,
|
||||
QK_Attr)
|
||||
|
||||
@ -453,10 +434,6 @@
|
||||
QS_USR_DICTIONARY,
|
||||
QS_ENUM_DICTIONARY)
|
||||
|
||||
// MC++R9-5-1 union 'TCast' declared
|
||||
-esym(9018,
|
||||
TCast)
|
||||
|
||||
// M3-R10.3(r) cannot assign enum to different essential type
|
||||
-emacro(9034,
|
||||
QS_SIG_DICTIONARY)
|
||||
@ -476,5 +453,7 @@
|
||||
-esym(9018,
|
||||
F32Rep,
|
||||
F64Rep,
|
||||
U32Rep)
|
||||
U32Rep,
|
||||
TCast,
|
||||
QP::QS::RxAttr::Variant)
|
||||
|
||||
|
21
qpcpp.md5
21
qpcpp.md5
@ -1,23 +1,23 @@
|
||||
47986b70c115871c237783a4e4eb4576 *qpcpp.qm
|
||||
ddd90780c6b874c0f8d27fe842e6005e *qpcpp.qm
|
||||
da3f0e1d1bc147b9e5ee801bc1fdd130 *include/qequeue.hpp
|
||||
fe1ff6084ff592ca8d14a6efffec296c *include/qk.hpp
|
||||
ebf2cb455c1471c2248bbde4b90ce634 *include/qmpool.hpp
|
||||
377391a63f2d24d9ba9f1d8cff2f5366 *include/qp.hpp
|
||||
344c0ecb3d7f5645a5f4e75aea7956ac *include/qp.hpp
|
||||
61c7a3aa8cb265f478915f39b7fae9cc *include/qp_pkg.hpp
|
||||
81e2fed348f03200d00b4d7c4473826f *include/qpcpp.hpp
|
||||
b97591429612996ff62d1f2c472b82fb *include/qs.hpp
|
||||
be2da5d56117fd172f12c8b6589f6402 *include/qs.hpp
|
||||
d59808009be96849963572ffcbf9dceb *include/qs_dummy.hpp
|
||||
db4013ceefb33498f5d38e15d0cb9323 *include/qs_pkg.hpp
|
||||
2a36b08d4f3ec92da6ae6f7c18ad83ca *include/qsafe.h
|
||||
e66cf5dd191fb0e7c1f8660fb477b860 *include/qstamp.hpp
|
||||
d42a19307ba3c0c5b890431767f35b42 *include/qv.hpp
|
||||
c0bc33e3823dde00803a301c4b85637d *include/qxk.hpp
|
||||
fbf5677e511880c581cf4a12269174d3 *src/qf/qep_hsm.cpp
|
||||
03756de2431414185d61aa3f838e699d *src/qf/qep_msm.cpp
|
||||
88c84e634597fafced2012faea838750 *src/qf/qep_hsm.cpp
|
||||
becbd953c6da010daddf4907784e9766 *src/qf/qep_msm.cpp
|
||||
8b5c1ece58069ed5582864fd2dc58167 *src/qf/qf_act.cpp
|
||||
8fca896aa3dee712f6c844a0f31c130e *src/qf/qf_actq.cpp
|
||||
39b02b596faa57abfa96b0f7c3f7fb82 *src/qf/qf_defer.cpp
|
||||
69c1fcdd15230427a077a607ebb9a7a0 *src/qf/qf_dyn.cpp
|
||||
069220fa20ca5bd9e0ddfcb2f4f8f0ba *src/qf/qf_dyn.cpp
|
||||
0d3572af3a2acbf7144b27be35fa018a *src/qf/qf_mem.cpp
|
||||
40218fcd6cbb521f2c8ae5f7c0d5c04e *src/qf/qf_ps.cpp
|
||||
19cf8976578a43e93bfbb51dbe932b6c *src/qf/qf_qact.cpp
|
||||
@ -28,7 +28,7 @@ c49e1c15e6d6e035668d910c8d13a684 *src/qf/qf_time.cpp
|
||||
ecdd6f0f0a7dc56d8bb0c769e67b48fc *src/qs/qs.cpp
|
||||
a2ca20b2332d025067645839e4b25711 *src/qs/qs_64bit.cpp
|
||||
8f6551c7786fdbb106c3d1bc7824c060 *src/qs/qs_fp.cpp
|
||||
4e403740b59b9352c7bf3fea54c0e524 *src/qs/qs_rx.cpp
|
||||
4af89f114491668f7a26af694ff11993 *src/qs/qs_rx.cpp
|
||||
2655cd10d009075b71a84368fb6bf4d4 *src/qs/qstamp.cpp
|
||||
180d454ecdbd08f522ff9a9c299de5df *src/qs/qutest.cpp
|
||||
deac78388761a8e1d4d0e5c51d5b338b *src/qv/qv.cpp
|
||||
@ -36,6 +36,13 @@ deac78388761a8e1d4d0e5c51d5b338b *src/qv/qv.cpp
|
||||
efe0395b16911eaff880649a9968d6a3 *src/qxk/qxk_mutex.cpp
|
||||
ce5ff1926bd91dd8683e0232d3e1d471 *src/qxk/qxk_sema.cpp
|
||||
78ec1d0d6aa9efbdc8b3d09e6deea40e *src/qxk/qxk_xthr.cpp
|
||||
bf56a383eb7dafafa408d6219b585b40 *ports/lint-plus/au-autosar.lnt
|
||||
e3e3f3000f9a80a446255ef52f3a6299 *ports/lint-plus/au-autosar19.lnt
|
||||
2a8fea61bccbe5e8c7536a29f2ec8e98 *ports/lint-plus/au-ds.lnt
|
||||
ede719cdbc201d14586a3f11e77ced26 *ports/lint-plus/au-ql-cpp11.lnt
|
||||
dddbecd55afec10d85006f7787e40c7d *ports/lint-plus/options.lnt
|
||||
00e7bc0ddabc998469615ac2ff9d79f1 *ports/lint-plus/qpcpp.lnt
|
||||
5f789348dba099c2055f737ba756faac *ports/lint-plus/std.lnt
|
||||
1f3d9dfbf71077abbdb9f27c96879101 *ports/arm-cm/qk/armclang/qk_port.cpp
|
||||
aba379ac6a39b1f21057bed8156f0516 *ports/arm-cm/qk/armclang/qp_port.hpp
|
||||
91a3b66c3f12a98bef48b00640ed5e6d *ports/arm-cm/qk/armclang/qs_port.hpp
|
||||
|
@ -13,6 +13,7 @@
|
||||
@md5sum qpcpp.qm ^
|
||||
include/* ^
|
||||
src/qf/* src/qk/* src/qs/* src/qv/* src/qxk/* ^
|
||||
ports/lint-plus/*.lnt ^
|
||||
ports/arm-cm/qk/armclang/* ports/arm-cm/qk/config/* ports/arm-cm/qk/gnu/* ports/arm-cm/qk/iar/* ^
|
||||
ports/arm-cm/qv/armclang/* ports/arm-cm/qv/config/* ports/arm-cm/qv/gnu/* ports/arm-cm/qv/iar/* ^
|
||||
ports/arm-cm/qxk/armclang/* ports/arm-cm/qxk/config/* ports/arm-cm/qxk/gnu/* ports/arm-cm/qxk/iar/* ^
|
||||
|
@ -74,24 +74,24 @@ static QP::QEvt const l_reservedEvt_[4] {
|
||||
|
||||
// helper macro to trace state entry
|
||||
#define QS_STATE_ENTRY_(state_, qsId_) \
|
||||
QS_CRIT_ENTRY(); \
|
||||
QS_MEM_SYS(); \
|
||||
QS_CRIT_ENTRY(); \
|
||||
QS_MEM_SYS(); \
|
||||
QS_BEGIN_PRE_(QS_QEP_STATE_ENTRY, (qsId_)) \
|
||||
QS_OBJ_PRE_(this); \
|
||||
QS_FUN_PRE_(state_); \
|
||||
QS_END_PRE_() \
|
||||
QS_MEM_APP(); \
|
||||
QS_OBJ_PRE_(this); \
|
||||
QS_FUN_PRE_(state_); \
|
||||
QS_END_PRE_() \
|
||||
QS_MEM_APP(); \
|
||||
QS_CRIT_EXIT()
|
||||
|
||||
// helper macro to trace state exit
|
||||
#define QS_STATE_EXIT_(state_, qsId_) \
|
||||
QS_CRIT_ENTRY(); \
|
||||
QS_MEM_SYS(); \
|
||||
QS_CRIT_ENTRY(); \
|
||||
QS_MEM_SYS(); \
|
||||
QS_BEGIN_PRE_(QS_QEP_STATE_EXIT, (qsId_)) \
|
||||
QS_OBJ_PRE_(this); \
|
||||
QS_FUN_PRE_(state_); \
|
||||
QS_END_PRE_() \
|
||||
QS_MEM_APP(); \
|
||||
QS_OBJ_PRE_(this); \
|
||||
QS_FUN_PRE_(state_); \
|
||||
QS_END_PRE_() \
|
||||
QS_MEM_APP(); \
|
||||
QS_CRIT_EXIT()
|
||||
|
||||
//! @endcond
|
||||
@ -172,20 +172,24 @@ void QHsm::init(
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
// drill down into the state hierarchy with initial transitions...
|
||||
std::int_fast8_t limit = MAX_NEST_DEPTH_; // loop hard limit
|
||||
do {
|
||||
QStateHandler path[MAX_NEST_DEPTH_]; // tran entry path array
|
||||
std::int_fast8_t ip = 0; // entry path index
|
||||
std::int_fast8_t ip = 0; // tran entry path index
|
||||
|
||||
path[0] = m_temp.fun;
|
||||
static_cast<void>(QHSM_RESERVED_EVT_(m_temp.fun, Q_EMPTY_SIG));
|
||||
while (m_temp.fun != t) {
|
||||
++ip;
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ASSERT_INCRIT(220, ip < MAX_NEST_DEPTH_);
|
||||
QF_CRIT_EXIT();
|
||||
path[ip] = m_temp.fun;
|
||||
static_cast<void>(QHSM_RESERVED_EVT_(m_temp.fun, Q_EMPTY_SIG));
|
||||
}
|
||||
QF_CRIT_ENTRY();
|
||||
// The initial transition source state must be reached
|
||||
// Too many state nesting levels or "malformed" HSM.
|
||||
Q_ASSERT_INCRIT(220, m_temp.fun == t);
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
m_temp.fun = path[0];
|
||||
|
||||
// retrace the entry path in reverse (desired) order...
|
||||
@ -217,9 +221,14 @@ void QHsm::init(
|
||||
}
|
||||
#endif // Q_SPY
|
||||
|
||||
} while (r == Q_RET_TRAN);
|
||||
--limit;
|
||||
} while ((r == Q_RET_TRAN) && (limit > 0));
|
||||
|
||||
QF_CRIT_ENTRY();
|
||||
// Loop limit must not be reached.
|
||||
// Too many state nesting levels or likely "malformed" HSM
|
||||
Q_ENSURE_INCRIT(290, limit > 0);
|
||||
|
||||
QS_CRIT_ENTRY();
|
||||
QS_MEM_SYS();
|
||||
QS_BEGIN_PRE_(QS_QEP_INIT_TRAN, qsId)
|
||||
QS_TIME_PRE_(); // time stamp
|
||||
@ -227,7 +236,8 @@ void QHsm::init(
|
||||
QS_FUN_PRE_(t); // the new active state
|
||||
QS_END_PRE_()
|
||||
QS_MEM_APP();
|
||||
QS_CRIT_EXIT();
|
||||
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
m_state.fun = t; // change the current active state
|
||||
#ifndef Q_UNSAFE
|
||||
@ -267,6 +277,7 @@ void QHsm::dispatch(
|
||||
// process the event hierarchically...
|
||||
QState r;
|
||||
m_temp.fun = s;
|
||||
std::int_fast8_t limit = MAX_NEST_DEPTH_; // loop hard limit
|
||||
do {
|
||||
s = m_temp.fun;
|
||||
r = (*s)(this, e); // invoke state handler s
|
||||
@ -285,7 +296,13 @@ void QHsm::dispatch(
|
||||
|
||||
r = QHSM_RESERVED_EVT_(s, Q_EMPTY_SIG); // superstate of s
|
||||
}
|
||||
} while (r == Q_RET_SUPER);
|
||||
|
||||
--limit;
|
||||
} while ((r == Q_RET_SUPER) && (limit > 0));
|
||||
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ASSERT_INCRIT(310, limit > 0);
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
if (r >= Q_RET_TRAN) { // regular tran. taken?
|
||||
QStateHandler path[MAX_NEST_DEPTH_];
|
||||
@ -295,14 +312,20 @@ void QHsm::dispatch(
|
||||
path[2] = s; // tran. source
|
||||
|
||||
// exit current state to tran. source s...
|
||||
for (; t != s; t = m_temp.fun) {
|
||||
limit = MAX_NEST_DEPTH_; // loop hard limit
|
||||
for (; (t != s) && (limit > 0); t = m_temp.fun) {
|
||||
// exit from t
|
||||
if (QHSM_RESERVED_EVT_(t, Q_EXIT_SIG) == Q_RET_HANDLED) {
|
||||
QS_STATE_EXIT_(t, qsId);
|
||||
// find superstate of t
|
||||
static_cast<void>(QHSM_RESERVED_EVT_(t, Q_EMPTY_SIG));
|
||||
}
|
||||
--limit;
|
||||
}
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ASSERT_INCRIT(320, limit > 0);
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
std::int_fast8_t ip = hsm_tran(path, qsId); // take the tran.
|
||||
|
||||
#ifdef Q_SPY
|
||||
@ -350,20 +373,21 @@ void QHsm::dispatch(
|
||||
// find superstate
|
||||
static_cast<void>(QHSM_RESERVED_EVT_(m_temp.fun, Q_EMPTY_SIG));
|
||||
|
||||
while (m_temp.fun != t) {
|
||||
while ((m_temp.fun != t) && (ip < (MAX_NEST_DEPTH_ - 1))) {
|
||||
++ip;
|
||||
path[ip] = m_temp.fun;
|
||||
// find superstate
|
||||
static_cast<void>(
|
||||
QHSM_RESERVED_EVT_(m_temp.fun, Q_EMPTY_SIG));
|
||||
}
|
||||
m_temp.fun = path[0];
|
||||
|
||||
// entry path must not overflow
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ASSERT_INCRIT(410, ip < MAX_NEST_DEPTH_);
|
||||
// The initial transition source state must be reached.
|
||||
// Too many state nesting levels or "malformed" HSM.
|
||||
Q_ASSERT_INCRIT(330, m_temp.fun == t);
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
m_temp.fun = path[0];
|
||||
|
||||
// retrace the entry path in reverse (correct) order...
|
||||
do {
|
||||
// enter path[ip]
|
||||
@ -549,21 +573,18 @@ std::int_fast8_t QHsm::hsm_tran(
|
||||
// and store the entry path along the way
|
||||
std::int_fast8_t iq = 0; // indicate that LCA was found
|
||||
ip = 1; // enter target and its superstate
|
||||
path[1] = t; // save the superstate of target
|
||||
t = m_temp.fun; // save source->super
|
||||
path[1] = t; // save the superstate of target
|
||||
t = m_temp.fun; // save source->super
|
||||
|
||||
// find target->super->super...
|
||||
QState r = QHSM_RESERVED_EVT_(path[1], Q_EMPTY_SIG);
|
||||
while (r == Q_RET_SUPER) {
|
||||
while ((r == Q_RET_SUPER)
|
||||
&& (ip < (MAX_NEST_DEPTH_ - 1)))
|
||||
{
|
||||
++ip;
|
||||
path[ip] = m_temp.fun; // store the entry path
|
||||
if (m_temp.fun == s) { // is it the source?
|
||||
iq = 1; // indicate that the LCA found
|
||||
|
||||
// entry path must not overflow
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ASSERT_INCRIT(510, ip < MAX_NEST_DEPTH_);
|
||||
QF_CRIT_EXIT();
|
||||
--ip; // do not enter the source
|
||||
r = Q_RET_HANDLED; // terminate the loop
|
||||
}
|
||||
@ -571,14 +592,14 @@ std::int_fast8_t QHsm::hsm_tran(
|
||||
r = QHSM_RESERVED_EVT_(m_temp.fun, Q_EMPTY_SIG);
|
||||
}
|
||||
}
|
||||
QF_CRIT_ENTRY();
|
||||
// Tran. source must be found within the nesting depth
|
||||
// Too many state nesting levels or "malformed" HSM.
|
||||
Q_ASSERT_INCRIT(510, r != Q_RET_SUPER);
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
// the LCA not found yet?
|
||||
if (iq == 0) {
|
||||
// entry path must not overflow
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ASSERT_INCRIT(520, ip < MAX_NEST_DEPTH_);
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
// exit source s
|
||||
if (QHSM_RESERVED_EVT_(s, Q_EXIT_SIG)
|
||||
== Q_RET_HANDLED)
|
||||
@ -606,6 +627,7 @@ std::int_fast8_t QHsm::hsm_tran(
|
||||
// (g) check each source->super->...
|
||||
// for each target->super...
|
||||
r = Q_RET_IGNORED; // keep looping
|
||||
std::int_fast8_t limit = MAX_NEST_DEPTH_;
|
||||
do {
|
||||
// exit from t
|
||||
if (QHSM_RESERVED_EVT_(t, Q_EXIT_SIG)
|
||||
@ -629,13 +651,21 @@ std::int_fast8_t QHsm::hsm_tran(
|
||||
--iq;
|
||||
}
|
||||
} while (iq >= 0);
|
||||
} while (r != Q_RET_HANDLED);
|
||||
|
||||
--limit;
|
||||
} while ((r != Q_RET_HANDLED) && (limit > 0));
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ASSERT_INCRIT(530, limit > 0);
|
||||
QF_CRIT_EXIT();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ENSURE_INCRIT(590, ip < MAX_NEST_DEPTH_);
|
||||
QF_CRIT_EXIT();
|
||||
return ip;
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,15 @@ namespace {
|
||||
|
||||
Q_DEFINE_THIS_MODULE("qep_msm")
|
||||
|
||||
// maximum depth of state nesting in a QMsm (including the top level)
|
||||
static constexpr std::int_fast8_t MAX_NEST_DEPTH_ {6};
|
||||
|
||||
// maximum length of transition-action array
|
||||
static constexpr std::int_fast8_t MAX_TRAN_LENGTH_ {3*MAX_NEST_DEPTH_};
|
||||
|
||||
// maximum depth of entry levels in a MSM for tran. to history.
|
||||
static constexpr std::int_fast8_t MAX_ENTRY_DEPTH_ {4};
|
||||
|
||||
// top-state object for QMsm-style state machines
|
||||
QP::QMState const l_msm_top_s = {
|
||||
nullptr,
|
||||
@ -68,8 +77,6 @@ QP::QMState const l_msm_top_s = {
|
||||
nullptr
|
||||
};
|
||||
|
||||
static constexpr std::int_fast8_t MAX_ENTRY_DEPTH_ {4};
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
//! @endcond
|
||||
@ -131,12 +138,16 @@ void QMsm::init(
|
||||
m_state.obj = m_temp.tatbl->target;
|
||||
|
||||
// drill down into the state hierarchy with initial transitions...
|
||||
std::int_fast8_t limit = MAX_NEST_DEPTH_; // loop hard limit
|
||||
do {
|
||||
// execute the tran. table
|
||||
r = execTatbl_(m_temp.tatbl, qsId);
|
||||
} while (r >= Q_RET_TRAN_INIT);
|
||||
--limit;
|
||||
} while ((r >= Q_RET_TRAN_INIT) && (limit > 0));
|
||||
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ENSURE_INCRIT(290, limit > 0);
|
||||
|
||||
QS_CRIT_ENTRY();
|
||||
QS_MEM_SYS();
|
||||
QS_BEGIN_PRE_(QS_QEP_INIT_TRAN, qsId)
|
||||
QS_TIME_PRE_(); // time stamp
|
||||
@ -144,7 +155,8 @@ void QMsm::init(
|
||||
QS_FUN_PRE_(m_state.obj->stateHandler); // the new current state
|
||||
QS_END_PRE_()
|
||||
QS_MEM_APP();
|
||||
QS_CRIT_EXIT();
|
||||
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
#ifndef Q_UNSAFE
|
||||
m_temp.uint = ~m_state.uint;
|
||||
@ -182,6 +194,7 @@ void QMsm::dispatch(
|
||||
|
||||
// scan the state hierarchy up to the top state...
|
||||
QState r;
|
||||
std::int_fast8_t limit = MAX_NEST_DEPTH_; // loop hard limit
|
||||
do {
|
||||
r = (*t->stateHandler)(this, e); // call state handler function
|
||||
|
||||
@ -214,11 +227,15 @@ void QMsm::dispatch(
|
||||
|
||||
t = t->superstate; // advance to the superstate
|
||||
}
|
||||
} while (t != nullptr);
|
||||
--limit;
|
||||
} while ((t != nullptr) && (limit > 0));
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ASSERT_INCRIT(310, limit > 0);
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
if (r >= Q_RET_TRAN) { // any kind of tran. taken?
|
||||
#ifdef Q_SPY
|
||||
QMState const * const ts = t; // transition source for QS tracing
|
||||
QMState const * const ts = t; // tran. source for QS tracing
|
||||
|
||||
QF_CRIT_ENTRY();
|
||||
// the tran. source state must not be nullptr
|
||||
@ -226,6 +243,7 @@ void QMsm::dispatch(
|
||||
QF_CRIT_EXIT();
|
||||
#endif // Q_SPY
|
||||
|
||||
limit = MAX_NEST_DEPTH_; // loop hard limit
|
||||
do {
|
||||
// save the tran-action table before it gets clobbered
|
||||
QMTranActTable const * const tatbl = m_temp.tatbl;
|
||||
@ -292,10 +310,12 @@ void QMsm::dispatch(
|
||||
}
|
||||
|
||||
t = s; // set target to the current state
|
||||
--limit;
|
||||
} while ((r >= Q_RET_TRAN) && (limit > 0));
|
||||
|
||||
} while (r >= Q_RET_TRAN);
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ASSERT_INCRIT(320, limit > 0);
|
||||
|
||||
QS_CRIT_ENTRY();
|
||||
QS_MEM_SYS();
|
||||
QS_BEGIN_PRE_(QS_QEP_TRAN, qsId)
|
||||
QS_TIME_PRE_(); // time stamp
|
||||
@ -305,7 +325,8 @@ void QMsm::dispatch(
|
||||
QS_FUN_PRE_(s->stateHandler); // the new active state
|
||||
QS_END_PRE_()
|
||||
QS_MEM_APP();
|
||||
QS_CRIT_EXIT();
|
||||
|
||||
QF_CRIT_EXIT();
|
||||
}
|
||||
|
||||
#ifdef Q_SPY
|
||||
@ -351,12 +372,12 @@ void QMsm::dispatch(
|
||||
|
||||
//${QEP::QMsm::isIn} .........................................................
|
||||
bool QMsm::isIn(QStateHandler const state) noexcept {
|
||||
bool inState = false; // assume that this MSM is not in 'state'
|
||||
bool inState = false; // assume that this SM is not in 'state'
|
||||
|
||||
QMState const *s = m_state.obj;
|
||||
std::int_fast8_t limit = 6; // loop hard limit
|
||||
std::int_fast8_t limit = MAX_NEST_DEPTH_; // loop hard limit
|
||||
for (; (s != nullptr) && (limit > 0); --limit) {
|
||||
if (s->stateHandler == state) { // match found?
|
||||
if (s->stateHandler == state) { // match found?
|
||||
inState = true;
|
||||
break;
|
||||
}
|
||||
@ -367,7 +388,7 @@ bool QMsm::isIn(QStateHandler const state) noexcept {
|
||||
|
||||
QF_CRIT_STAT
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ENSURE_INCRIT(690, limit > 0);
|
||||
Q_ENSURE_INCRIT(490, limit > 0);
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
return inState;
|
||||
@ -375,12 +396,12 @@ bool QMsm::isIn(QStateHandler const state) noexcept {
|
||||
|
||||
//${QEP::QMsm::isInState} ....................................................
|
||||
bool QMsm::isInState(QMState const * const stateObj) const noexcept {
|
||||
bool inState = false; // assume that this MSM is not in 'state'
|
||||
bool inState = false; // assume that this SM is not in 'state'
|
||||
|
||||
QMState const *s = m_state.obj;
|
||||
std::int_fast8_t limit = 6; // loop hard limit
|
||||
std::int_fast8_t limit = MAX_NEST_DEPTH_; // loop hard limit
|
||||
for (; (s != nullptr) && (limit > 0); --limit) {
|
||||
if (s == stateObj) { // match found?
|
||||
if (s == stateObj) { // match found?
|
||||
inState = true;
|
||||
break;
|
||||
}
|
||||
@ -391,7 +412,7 @@ bool QMsm::isInState(QMState const * const stateObj) const noexcept {
|
||||
|
||||
QF_CRIT_STAT
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ENSURE_INCRIT(790, limit > 0);
|
||||
Q_ENSURE_INCRIT(590, limit > 0);
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
return inState;
|
||||
@ -403,7 +424,11 @@ QMState const * QMsm::childStateObj(QMState const * const parent) const noexcept
|
||||
bool isFound = false; // start with the child not found
|
||||
QMState const *s;
|
||||
|
||||
for (s = m_state.obj; s != nullptr; s = s->superstate) {
|
||||
std::int_fast8_t limit = MAX_NEST_DEPTH_; // loop hard limit
|
||||
for (s = m_state.obj;
|
||||
(s != nullptr) && (limit > 0);
|
||||
s = s->superstate)
|
||||
{
|
||||
if (s == parent) {
|
||||
isFound = true; // child is found
|
||||
break;
|
||||
@ -411,9 +436,19 @@ QMState const * QMsm::childStateObj(QMState const * const parent) const noexcept
|
||||
else {
|
||||
child = s;
|
||||
}
|
||||
--limit;
|
||||
}
|
||||
QF_CRIT_STAT
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ASSERT_INCRIT(610, limit > 0);
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
if (!isFound) { // still not found?
|
||||
for (s = m_temp.obj; s != nullptr; s = s->superstate) {
|
||||
limit = MAX_NEST_DEPTH_; // loop hard limit
|
||||
for (s = m_temp.obj;
|
||||
(s != nullptr) && (limit > 0);
|
||||
s = s->superstate)
|
||||
{
|
||||
if (s == parent) {
|
||||
isFound = true; // child is found
|
||||
break;
|
||||
@ -421,12 +456,12 @@ QMState const * QMsm::childStateObj(QMState const * const parent) const noexcept
|
||||
else {
|
||||
child = s;
|
||||
}
|
||||
--limit;
|
||||
}
|
||||
}
|
||||
|
||||
QF_CRIT_STAT
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ASSERT_INCRIT(890, isFound);
|
||||
Q_ENSURE_INCRIT(690, isFound && (limit > 0));
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
return child; // return the child
|
||||
@ -445,11 +480,13 @@ QState QMsm::execTatbl_(
|
||||
QF_CRIT_ENTRY();
|
||||
// precondition:
|
||||
// - the tran-action table pointer must not be NULL
|
||||
Q_REQUIRE_INCRIT(400, tatbl != nullptr);
|
||||
Q_REQUIRE_INCRIT(700, tatbl != nullptr);
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
QState r = Q_RET_NULL;
|
||||
for (QActionHandler const *a = &tatbl->act[0]; *a != nullptr; ++a) {
|
||||
std::int_fast8_t limit = MAX_TRAN_LENGTH_; // loop hard limit
|
||||
QActionHandler const *a = &tatbl->act[0];
|
||||
for (; (*a != nullptr) && (limit > 0); ++a) {
|
||||
r = (*(*a))(this); // call the action through the 'a' pointer
|
||||
#ifdef Q_SPY
|
||||
QS_CRIT_ENTRY();
|
||||
@ -493,7 +530,11 @@ QState QMsm::execTatbl_(
|
||||
QS_MEM_APP();
|
||||
QS_CRIT_EXIT();
|
||||
#endif // Q_SPY
|
||||
--limit;
|
||||
}
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ENSURE_INCRIT(790, *a == nullptr);
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
m_state.obj = (r >= Q_RET_TRAN)
|
||||
? m_temp.tatbl->target
|
||||
@ -515,7 +556,8 @@ void QMsm::exitToTranSource_(
|
||||
|
||||
// exit states from the current state to the tran. source state
|
||||
QMState const *s = cs;
|
||||
while (s != ts) {
|
||||
std::int_fast8_t limit = MAX_NEST_DEPTH_; // loop hard limit
|
||||
for (; (s != ts) && (limit > 0); --limit) {
|
||||
// exit action provided in state 's'?
|
||||
if (s->exitAction != nullptr) {
|
||||
// execute the exit action
|
||||
@ -536,10 +578,13 @@ void QMsm::exitToTranSource_(
|
||||
if (s == nullptr) { // reached the top of a submachine?
|
||||
s = m_temp.obj; // the superstate from QM_SM_EXIT()
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ASSERT_INCRIT(510, s != nullptr);
|
||||
Q_ASSERT_INCRIT(810, s != nullptr); // must be valid
|
||||
QF_CRIT_EXIT();
|
||||
}
|
||||
}
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ENSURE_INCRIT(890, limit > 0);
|
||||
QF_CRIT_EXIT();
|
||||
}
|
||||
|
||||
//${QEP::QMsm::enterHistory_} ................................................
|
||||
@ -568,11 +613,8 @@ QState QMsm::enterHistory_(
|
||||
QS_CRIT_EXIT();
|
||||
|
||||
std::int_fast8_t i = 0; // tran. entry path index
|
||||
while (s != ts) {
|
||||
while ((s != ts) && (i < MAX_ENTRY_DEPTH_)) {
|
||||
if (s->entryAction != nullptr) {
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ASSERT_INCRIT(620, i < MAX_ENTRY_DEPTH_);
|
||||
QF_CRIT_EXIT();
|
||||
epath[i] = s;
|
||||
++i;
|
||||
}
|
||||
@ -581,6 +623,9 @@ QState QMsm::enterHistory_(
|
||||
ts = s; // force exit from the for-loop
|
||||
}
|
||||
}
|
||||
QF_CRIT_ENTRY();
|
||||
Q_ASSERT_INCRIT(910, s == ts);
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
// retrace the entry path in reverse (desired) order...
|
||||
while (i > 0) {
|
||||
|
@ -65,6 +65,20 @@ Q_DEFINE_THIS_MODULE("qf_dyn")
|
||||
#endif
|
||||
//$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
//$define${QEP::QEvt::ctor} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||
namespace QP {
|
||||
|
||||
//${QEP::QEvt::ctor} .........................................................
|
||||
#ifdef QEVT_DYN_CTOR
|
||||
QEvt * QEvt::ctor(DynEvt const dummy) noexcept {
|
||||
Q_UNUSED_PAR(dummy);
|
||||
return this;
|
||||
}
|
||||
|
||||
#endif // def QEVT_DYN_CTOR
|
||||
|
||||
} // namespace QP
|
||||
//$enddef${QEP::QEvt::ctor} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
//$define${QF::QF-dyn} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||
namespace QP {
|
||||
namespace QF {
|
||||
@ -110,7 +124,15 @@ void poolInit(
|
||||
|
||||
//${QF::QF-dyn::poolGetMaxBlockSize} .........................................
|
||||
std::uint_fast16_t poolGetMaxBlockSize() noexcept {
|
||||
return QF_EPOOL_EVENT_SIZE_(priv_.ePool_[priv_.maxPool_ - 1U]);
|
||||
QF_CRIT_STAT
|
||||
QF_CRIT_ENTRY();
|
||||
QF_MEM_SYS();
|
||||
std::uint_fast16_t const max_size =
|
||||
QF_EPOOL_EVENT_SIZE_(priv_.ePool_[priv_.maxPool_ - 1U]);
|
||||
QF_MEM_APP();
|
||||
QF_CRIT_EXIT();
|
||||
|
||||
return max_size;
|
||||
}
|
||||
|
||||
//${QF::QF-dyn::getPoolMin} ..................................................
|
||||
|
508
src/qs/qs_rx.cpp
508
src/qs/qs_rx.cpp
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user