Skip to content

Commit 3a0099d

Browse files
update to qpcpp v7.2.1
1 parent 54d545d commit 3a0099d

File tree

9 files changed

+48
-45
lines changed

9 files changed

+48
-45
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ be compatible with this code.
5555
* qpcpp (pulled in as a git submodule)
5656
* After cloning this repository, do not forget to:
5757
* `git submodule init`
58-
* `git submodule update`
58+
* `git submodule update --recursive`
59+
* NOTE: As of January 2023, qpcpp is also using submodules. Developers
60+
may need to perform similar steps within the externals/qpcpp/
61+
directory as well.
5962
* CppUTest (version 3.8-7, the default in Ubuntu 20.04)
6063
* CMake and associated build tools were used to develop
6164
and prove out this project.

examples/hwLockCtrlService/include/hwLockCtrlService.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Service final : public QP::QActive {
4747
enum DirectSignals { PING = PubSub::MAX_PUB_SIG, MAX_DIRECT_SIG };
4848

4949
Service();
50-
~Service() override = default;
50+
~Service() = default;
5151

5252
Service(const Service&) = delete;
5353
Service& operator=(const Service&) = delete;

test_support/cpputest-qpcpp-port/include/cmsTestPublishedEventRecorder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class PublishedEventRecorder final : public DefaultDummyActiveObject {
141141
}
142142
else {
143143
// record the event
144-
m_recordedEvents.post(e, QP::QF_NO_MARGIN, 0);
144+
m_recordedEvents.post(e, QP::QF::NO_MARGIN, 0);
145145
}
146146
}
147147
}

test_support/cpputest-qpcpp-port/include/qf_port.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,16 @@
3838
#ifndef QF_PORT_HPP
3939
#define QF_PORT_HPP
4040

41+
// provide QP::QHsm virtual destructor
42+
#define Q_HSM_XTOR 1
43+
4144
// event queue and thread types
4245
#define QF_EQUEUE_TYPE QEQueue
4346
// QF_OS_OBJECT_TYPE not used
4447
// QF_THREAD_TYPE not used
4548

49+
#define QF_EPOOL_TYPE_ QMPool
50+
4651
// The maximum number of active objects in the application
4752
#define QF_MAX_ACTIVE 64U
4853

@@ -69,7 +74,6 @@
6974
#include "qep_port.hpp" // QEP port
7075
#include "qequeue.hpp" // POSIX-QV needs event-queue
7176
#include "qmpool.hpp" // POSIX-QV needs memory-pool
72-
#include "qpset.hpp" // POSIX-QV needs priority-set
7377
#include "qf.hpp" // QF platform-independent public interface
7478

7579
namespace QP {

test_support/cpputest-qpcpp-port/src/cms_cpputest_qf_ctrl.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <cstdint>
3131
#include <vector>
3232
#include "CppUTest/TestHarness.h"
33+
#include "qf_pkg.hpp"
3334

3435
namespace cms {
3536
namespace test {
@@ -99,6 +100,8 @@ void Teardown()
99100

100101
l_ticksPerSecond = 0;
101102

103+
QF::stop();
104+
102105
// No test should complete with allocated events sitting
103106
// in a memory pool. However, the QP Pool class
104107
// is rather private. Ideally that
@@ -107,7 +110,13 @@ void Teardown()
107110
// internally will perform the memory check, as it has
108111
// friend access.
109112
if (l_memPoolOption == MemPoolTeardownOption::CHECK_FOR_LEAKS) {
110-
QF::stop();
113+
for (size_t i = 0; i < l_pubSubEventMemPoolConfigs->size(); ++i) {
114+
115+
const size_t poolNumOfEvents = l_pubSubEventMemPoolConfigs->at(i).config.numberOfEvents;
116+
117+
CHECK_TRUE_TEXT(poolNumOfEvents == QP::QF::ePool_[i].getNFree(),
118+
"A leak was detected in an internal QF event pool!")
119+
}
111120
}
112121

113122
if (l_pubSubEventMemPoolConfigs != nullptr) {
@@ -137,7 +146,7 @@ void MoveTimeForward(const std::chrono::milliseconds& duration)
137146
ONCE, static_cast<LoopCounter_t>(duration.count() / millisecondsPerTick));
138147

139148
for (LoopCounter_t i = 0; i < ticks; ++i) {
140-
QP::QF::tickX_(0U);
149+
QP::QTimeEvt::tick_(0, nullptr);
141150
ProcessEvents();
142151
}
143152
}
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
2-
#include "CppUTest/TestHarness.h"
31
#include "qpcpp.hpp"
42

53
namespace QP {
64

7-
extern QMPool QF_pool_[QF_MAX_EPOOL];
8-
extern std::uint_fast8_t QF_maxPool_;
9-
105
void QF::onCleanup()
116
{
12-
for (int i = 0; i < QF_maxPool_; ++i) {
13-
CHECK_TRUE_TEXT(QF_pool_[i].m_nTot == QF_pool_[i].m_nFree,
14-
"A leak was detected in an internal QF event pool!")
15-
}
7+
//Event pool leak detection moved, nothing to do here now.
168
}
179

1810
} // namespace QP

test_support/cpputest-qpcpp-port/src/cpputest_qf_port.cpp

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ QPSet cpputest_readySet_; // ready set of active objects
2626
//****************************************************************************
2727
void QF::init()
2828
{
29-
QF_maxPool_ = static_cast<uint_fast8_t>(0);
30-
bzero(&QF::timeEvtHead_[0],
31-
static_cast<uint_fast16_t>(sizeof(QF::timeEvtHead_)));
32-
bzero(&active_[0], static_cast<uint_fast16_t>(sizeof(active_)));
29+
QF::maxPool_ = static_cast<uint_fast8_t>(0);
30+
bzero(&QP::QTimeEvt::timeEvtHead_[0], sizeof(QP::QTimeEvt::timeEvtHead_));
31+
bzero(&QP::QActive::registry_[0], sizeof(QP::QActive::registry_));
3332
}
3433

3534
#if PURPOSEFULLY_NOT_IMPLEMENTED_
@@ -44,7 +43,7 @@ void QF_runUntilNoReadyActiveObjects()
4443
{
4544
while (cpputest_readySet_.notEmpty()) {
4645
std::uint_fast8_t p = cpputest_readySet_.findMax();
47-
QActive* a = QF::active_[p];
46+
QActive* a = QP::QActive::registry_[p];
4847

4948
// the active object 'a' must still be registered in QF
5049
// (e.g., it must not be stopped)
@@ -57,7 +56,7 @@ void QF_runUntilNoReadyActiveObjects()
5756
}
5857

5958
if (a->m_eQueue.isEmpty()) { /* empty queue? */
60-
cpputest_readySet_.rmove(p);
59+
cpputest_readySet_.remove(p);
6160
}
6261
}
6362
}
@@ -69,32 +68,32 @@ void QF::stop()
6968
}
7069

7170
//****************************************************************************
72-
void QActive::start(std::uint_fast8_t const priority, QEvt const** const qSto,
73-
std::uint_fast16_t const qLen, void* const stkSto,
74-
std::uint_fast16_t const stkSize, void const* const par)
71+
void QActive::start( QPrioSpec const prioSpec,
72+
QEvt const * * const qSto, std::uint_fast16_t const qLen,
73+
void * const stkSto, std::uint_fast16_t const stkSize,
74+
void const * const par)
7575
{
76-
(void)stkSize; // unused parameter in the cpputest port
76+
// unused parameters in the cpputest port
77+
Q_UNUSED_PAR(stkSto);
78+
Q_UNUSED_PAR(stkSize);
7779

78-
Q_REQUIRE_ID(
79-
600, (0U < priority) /* priority...*/
80-
&& (priority <= QF_MAX_ACTIVE) /*.. in range */
81-
&& (stkSto == nullptr)); // stack storage must NOT be provided
82-
m_eQueue.init(qSto, qLen);
80+
m_prio = static_cast<std::uint8_t>(prioSpec & 0xFFU); // QF-priority
81+
m_pthre = static_cast<std::uint8_t>(prioSpec >> 8U); // preemption-thre.
82+
register_(); // make QF aware of this AO
8383

84-
m_prio =
85-
static_cast<std::uint8_t>(priority); // set the QF priority of this AO
86-
QF::add_(this); // make QF aware of this AO
84+
m_eQueue.init(qSto, qLen);
8785

88-
this->init(par, m_prio); // execute initial transition (virtual call)
86+
this->init(par, m_prio); // execute initial transition (virtual call)
87+
QS_FLUSH(); // flush the QS trace buffer to the host
8988
}
9089

9190
//............................................................................
9291
#ifdef QF_ACTIVE_STOP
9392
void QActive::stop()
9493
{
9594
unsubscribeAll();
96-
cpputest_readySet_.rmove(m_prio);
97-
QF::remove_(this);
95+
cpputest_readySet_.remove(m_prio);
96+
unregister_();
9897
}
9998
#endif
10099

test_support/cpputest-qpcpp-port/test/cms_cpputest_qf_ctrlTests.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@
2525
#include "cms_cpputest_qf_ctrl.hpp"
2626
#include "qpcpp.hpp"
2727
#include "CppUTest/TestHarness.h"
28-
29-
namespace QP {
30-
extern QMPool QF_pool_[QF_MAX_EPOOL];
31-
extern std::uint_fast8_t QF_maxPool_;
32-
} // namespace QP
28+
#include "qf_pkg.hpp"
3329

3430
using namespace cms::test;
3531

@@ -46,14 +42,14 @@ TEST_GROUP(qf_ctrlTests)
4642

4743
void ConfirmNumberOfPools(uint32_t poolCount)
4844
{
49-
CHECK_EQUAL(poolCount, QP::QF_maxPool_);
45+
CHECK_EQUAL(poolCount, QP::QF::maxPool_);
5046
}
5147

5248
void ConfirmPoolEventSize(uint32_t poolIndex, uint32_t blockSize)
5349
{
5450
CHECK_TRUE(poolIndex < QF_MAX_EPOOL);
55-
CHECK_TRUE(poolIndex < QP::QF_maxPool_);
56-
CHECK_EQUAL(blockSize, QP::QF_pool_[poolIndex].getBlockSize());
51+
CHECK_TRUE(poolIndex < QP::QF::maxPool_);
52+
CHECK_EQUAL(blockSize, QP::QF::ePool_[poolIndex].getBlockSize());
5753
}
5854
};
5955

utilities/test/backedQueueTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ TEST(BackedQueueTests, can_push_up_to_max_events)
8484
// fill up the queue
8585
static QP::QEvt testEvent {5, 0, 0};
8686
for (size_t i = 0; i < underTest->capacity(); ++i) {
87-
underTest->post(&testEvent, QP::QF_NO_MARGIN, 0);
87+
underTest->post(&testEvent, QP::QF::NO_MARGIN, 0);
8888
}
8989

9090
// confirm full

0 commit comments

Comments
 (0)