Skip to content

Commit 84f7661

Browse files
committed
8.1.4
1 parent 7d5095a commit 84f7661

20 files changed

Lines changed: 244 additions & 162 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ endif()
5050

5151
project(
5252
qpc
53-
VERSION "8.1.3"
53+
VERSION "8.1.4"
5454
DESCRIPTION "QPC library"
5555
LANGUAGES C ASM
5656
)

include/qequeue.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343

4444
// forward declarations (NOTE must be consistent with "qp.h")
4545
struct QEvt;
46-
typedef struct QEvt const * QEvtPtr;
46+
typedef struct {
47+
struct QEvt const *e;
48+
} QEvtPtr;
4749

4850
//============================================================================
4951
//! @class QEQueue

include/qp.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
#define QP_H_
3131

3232
//============================================================================
33-
#define QP_VERSION_STR "8.1.3"
34-
#define QP_VERSION 813U
35-
// <VER>=813 <DATE>=260309
36-
#define QP_RELEASE 0x64D7FC82U
33+
#define QP_VERSION_STR "8.1.4"
34+
#define QP_VERSION 814U
35+
// <VER>=814 <DATE>=260413
36+
#define QP_RELEASE 0x64C81E01U
3737

3838
//----------------------------------------------------------------------------
3939
// default configuration settings
@@ -132,7 +132,9 @@ bool QEvt_verify_(QEvt const * const me);
132132

133133
#ifndef QEQUEUE_H_
134134
// NOTE must be consistent with "qequeue.h"
135-
typedef QEvt const * QEvtPtr;
135+
typedef struct {
136+
QEvt const *e;
137+
} QEvtPtr;
136138
#endif
137139

138140
#define QEVT_DYNAMIC ((uint8_t)0)

ports/embos/qf_port.c

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,19 @@ bool QActive_post_(QActive * const me,
100100
Q_REQUIRE_INCRIT(100, e != (QEvt *)0);
101101

102102
// the number of free slots available in the embOS queue
103-
uint_fast16_t const nFree =
104-
(uint_fast16_t)(me->eQueue.maxMsg - me->eQueue.nofMsg);
105-
106-
bool status = ((margin == QF_NO_MARGIN) || (nFree > (QEQueueCtr)margin));
103+
QEQueueCtr const nFree =
104+
(QEQueueCtr)(me->eQueue.maxMsg - me->eQueue.nofMsg);
107105

106+
bool status = ((margin == QF_NO_MARGIN)
107+
|| (nFree > (QEQueueCtr)margin));
108108
if (status) { // should try to post the event?
109109
#if (QF_MAX_EPOOL > 0U)
110110
if (e->poolNum_ != 0U) { // is it a mutable event?
111111
QEvt_refCtr_inc_(e); // increment the reference counter
112112
}
113113
#endif // (QF_MAX_EPOOL > 0U)
114114

115+
// assume that event posting will be successful, see NOTE3
115116
QS_BEGIN_PRE(QS_QF_ACTIVE_POST, me->prio)
116117
QS_TIME_PRE(); // timestamp
117118
QS_OBJ_PRE(sender); // the sender object
@@ -122,15 +123,19 @@ bool QActive_post_(QActive * const me,
122123
QS_EQC_PRE(0U); // min # free entries (unknown)
123124
QS_END_PRE()
124125

125-
QF_CRIT_EXIT(); // exit crit.sect. before calling Zephyr API
126+
QF_CRIT_EXIT(); // exit crit.sect. before calling RTOS API
127+
128+
// post the following evtPtr to the RTOS queue, see NOTE3
129+
QEvtPtr const evtPtr = {
130+
e
131+
};
132+
status = (OS_MAILBOX_Put(&me->eQueue,
133+
(OS_CONST_PTR void *)&evtPtr) == '\0');
126134

127-
// post the event to the embOS event queue, see NOTE3
128-
status = (OS_MAILBOX_Put(&me->eQueue, (OS_CONST_PTR void *)&e) == '\0');
135+
QF_CRIT_ENTRY(); // re-enter crit.sec.
129136
}
130137

131138
if (!status) { // event NOT posted?
132-
QF_CRIT_ENTRY();
133-
134139
// posting is allowed to fail only when margin != QF_NO_MARGIN
135140
Q_ASSERT_INCRIT(130, margin != QF_NO_MARGIN);
136141

@@ -140,7 +145,7 @@ bool QActive_post_(QActive * const me,
140145
QS_SIG_PRE(e->sig); // the signal of the event
141146
QS_OBJ_PRE(me); // this active object (recipient)
142147
QS_2U8_PRE(e->poolNum_, e->refCtr_); // pool-Num & ref-Count
143-
QS_EQC_PRE(nFree); // # free entries available
148+
QS_EQC_PRE(nFree); // # free entries
144149
QS_EQC_PRE(margin); // margin requested
145150
QS_END_PRE()
146151

@@ -150,6 +155,9 @@ bool QActive_post_(QActive * const me,
150155
QF_gc(e); // recycle the event to avoid a leak
151156
#endif
152157
}
158+
else {
159+
QF_CRIT_EXIT();
160+
}
153161

154162
return status;
155163
}
@@ -179,11 +187,16 @@ void QActive_postLIFO_(QActive * const me, QEvt const * const e) {
179187

180188
QF_CRIT_EXIT(); // exit crit.sect. before calling RTOS API
181189

182-
char err = OS_MAILBOX_PutFront(&me->eQueue, (OS_CONST_PTR void *)&e);
190+
// post the following evtPtr to the RTOS queue, see NOTE3
191+
QEvtPtr const evtPtr = {
192+
e
193+
};
194+
char const err = OS_MAILBOX_PutFront(&me->eQueue,
195+
(OS_CONST_PTR void *)&evtPtr);
183196

184197
#ifndef Q_UNSAFE
185198
QF_CRIT_ENTRY();
186-
// LIFO posting to embOS mailbox must succeed, see NOTE3
199+
// LIFO posting to the RTOS queue must succeed, see NOTE3
187200
Q_ASSERT_INCRIT(230, err == '\0');
188201
QF_CRIT_EXIT();
189202
#else
@@ -194,21 +207,21 @@ void QActive_postLIFO_(QActive * const me, QEvt const * const e) {
194207
//! @private @memberof QActive
195208
QEvt const *QActive_get_(QActive * const me) {
196209
// wait for an event (forever)
197-
QEvtPtr e;
198-
OS_MAILBOX_GetBlocked(&me->eQueue, (void *)&e);
210+
QEvtPtr evtPtr;
211+
OS_MAILBOX_GetBlocked(&me->eQueue, (void *)&evtPtr);
199212

200213
QS_CRIT_STAT
201214
QS_CRIT_ENTRY();
202215
QS_BEGIN_PRE(QS_QF_ACTIVE_GET, me->prio)
203216
QS_TIME_PRE(); // timestamp
204-
QS_SIG_PRE(e->sig); // the signal of this event
217+
QS_SIG_PRE(evtPtr.e->sig); // the signal of this event
205218
QS_OBJ_PRE(me); // this active object
206-
QS_2U8_PRE(e->poolNum_, e->refCtr_); // pool-Num & ref-Count
219+
QS_2U8_PRE(evtPtr.e->poolNum_, evtPtr.e->refCtr_);
207220
QS_EQC_PRE(me->eQueue.maxMsg - me->eQueue.nofMsg); // # free entries
208221
QS_END_PRE()
209222
QS_CRIT_EXIT();
210223

211-
return e;
224+
return evtPtr.e;
212225
}
213226
//............................................................................
214227
//! @static @public @memberof QActive
@@ -243,7 +256,7 @@ void QActive_start(QActive * const me,
243256
(OS_UINT)qLen,
244257
(void *)&qSto[0]);
245258

246-
me->prio = (uint8_t)(prioSpec & 0xFFU); // QF-priority of the AO
259+
me->prio = (uint8_t)(prioSpec & 0xFFU); // QP-priority
247260
me->pthre = 0U; // preemption-threshold (not used for AO registration)
248261
QActive_register_(me); // make QF aware of this AO
249262

@@ -297,6 +310,7 @@ void QActive_setAttr(QActive *const me, uint32_t attr1, void const *attr2) {
297310
}
298311

299312
//============================================================================
313+
// QF customization
300314

301315
//............................................................................
302316
void QF_init(void) {
@@ -317,7 +331,7 @@ int_t QF_run(void) {
317331
QS_CRIT_EXIT();
318332
#endif // Q_SPY
319333

320-
OS_Start(); // start embOS multitasking
334+
OS_Start(); // start embOS multitasking (does NOT return)
321335

322336
return 0; // this unreachable return keeps the compiler happy
323337
}

ports/freertos/qf_port.c

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,19 @@ bool QActive_post_(QActive * const me,
9696
Q_REQUIRE_INCRIT(100, e != (QEvt *)0);
9797

9898
// the number of free slots available in the FreeRTOS queue
99-
uint_fast16_t const nFree =
100-
(uint_fast16_t)FREERTOS_QUEUE_GET_FREE(me);
101-
102-
// should we try to post the event?
103-
bool status = ((margin == QF_NO_MARGIN) || (nFree > (QEQueueCtr)margin));
99+
QEQueueCtr const nFree =
100+
(QEQueueCtr)FREERTOS_QUEUE_GET_FREE(me);
104101

102+
bool status = ((margin == QF_NO_MARGIN)
103+
|| (nFree > (QEQueueCtr)margin));
105104
if (status) { // should try to post the event?
106105
#if (QF_MAX_EPOOL > 0U)
107106
if (e->poolNum_ != 0U) { // is it a mutable event?
108107
QEvt_refCtr_inc_(e); // increment the reference counter
109108
}
110109
#endif // (QF_MAX_EPOOL > 0U)
111110

111+
// assume that event posting will be successful, see NOTE3
112112
QS_BEGIN_PRE(QS_QF_ACTIVE_POST, me->prio)
113113
QS_TIME_PRE(); // timestamp
114114
QS_OBJ_PRE(sender); // the sender object
@@ -121,14 +121,17 @@ bool QActive_post_(QActive * const me,
121121

122122
QF_CRIT_EXIT(); // exit crit.sect. before calling RTOS API
123123

124-
// post the event to the FreeRTOS event queue, see NOTE3
124+
// post the following evtPtr to the RTOS event queue, see NOTE3
125+
QEvtPtr const evtPtr = {
126+
e
127+
};
125128
status = (xQueueSendToBack(
126-
me->eQueue, (void const *)&e, (TickType_t)0) == pdPASS);
129+
me->eQueue, (void const *)&evtPtr, 0U) == pdPASS);
130+
131+
QF_CRIT_ENTRY(); // re-enter crit.sec.
127132
}
128133

129134
if (!status) { // event NOT posted?
130-
QF_CRIT_ENTRY();
131-
132135
// posting is allowed to fail only when margin != QF_NO_MARGIN
133136
Q_ASSERT_INCRIT(130, margin != QF_NO_MARGIN);
134137

@@ -138,7 +141,7 @@ bool QActive_post_(QActive * const me,
138141
QS_SIG_PRE(e->sig); // the signal of the event
139142
QS_OBJ_PRE(me); // this active object (recipient)
140143
QS_2U8_PRE(e->poolNum_, e->refCtr_); // pool-Num & ref-Count
141-
QS_EQC_PRE(nFree); // # free entries available
144+
QS_EQC_PRE(nFree); // # free entries
142145
QS_EQC_PRE(margin); // margin requested
143146
QS_END_PRE()
144147

@@ -148,6 +151,9 @@ bool QActive_post_(QActive * const me,
148151
QF_gc(e); // recycle the event to avoid a leak
149152
#endif
150153
}
154+
else {
155+
QF_CRIT_EXIT();
156+
}
151157

152158
return status;
153159
}
@@ -171,14 +177,18 @@ void QActive_postLIFO_(QActive * const me, QEvt const * const e) {
171177
QS_SIG_PRE(e->sig); // the signal of this event
172178
QS_OBJ_PRE(me); // this active object
173179
QS_2U8_PRE(e->poolNum_, e->refCtr_); // pool-Num & ref-Count
174-
QS_EQC_PRE(FREERTOS_QUEUE_GET_FREE(me)); // # free entries available
180+
QS_EQC_PRE(FREERTOS_QUEUE_GET_FREE(me)); // # free entries
175181
QS_EQC_PRE(0U); // min # free entries (unknown)
176182
QS_END_PRE()
177183

178184
QF_CRIT_EXIT(); // exit crit.sect. before calling RTOS API
179185

186+
// post the following evtPtr to the RTOS event queue, see NOTE3
187+
QEvtPtr const evtPtr = {
188+
e
189+
};
180190
BaseType_t const err =
181-
xQueueSendToFront(me->eQueue, (void const *)&e, (TickType_t)0);
191+
xQueueSendToFront(me->eQueue, (void const *)&evtPtr, 0U);
182192

183193
#ifndef Q_UNSAFE
184194
QF_CRIT_ENTRY();
@@ -193,8 +203,9 @@ void QActive_postLIFO_(QActive * const me, QEvt const * const e) {
193203
//! @private @memberof QActive
194204
QEvt const *QActive_get_(QActive * const me) {
195205
// wait for an event (forever)
196-
QEvtPtr e;
197-
BaseType_t const err = xQueueReceive(me->eQueue, (void *)&e, portMAX_DELAY);
206+
QEvtPtr evtPtr;
207+
BaseType_t const err = xQueueReceive(me->eQueue,
208+
(void *)&evtPtr, portMAX_DELAY);
198209

199210
QF_CRIT_STAT
200211
QF_CRIT_ENTRY();
@@ -207,15 +218,15 @@ QEvt const *QActive_get_(QActive * const me) {
207218

208219
QS_BEGIN_PRE(QS_QF_ACTIVE_GET, me->prio)
209220
QS_TIME_PRE(); // timestamp
210-
QS_SIG_PRE(e->sig); // the signal of this event
221+
QS_SIG_PRE(evtPtr.e->sig); // the signal of this event
211222
QS_OBJ_PRE(me); // this active object
212-
QS_2U8_PRE(e->poolNum_, e->refCtr_); // pool-Num & ref-Count
223+
QS_2U8_PRE(evtPtr.e->poolNum_, evtPtr.e->refCtr_);
213224
QS_EQC_PRE(FREERTOS_QUEUE_GET_FREE(me)); // # free entries available
214225
QS_END_PRE()
215226

216227
QF_CRIT_EXIT();
217228

218-
return e;
229+
return evtPtr.e;
219230
}
220231
//............................................................................
221232
//! @static @public @memberof QActive
@@ -343,12 +354,12 @@ bool QActive_postFromISR_(QActive * const me,
343354
Q_REQUIRE_INCRIT(600, e != (QEvt *)0);
344355

345356
// the number of free slots available in the FreeRTOS queue
346-
uint_fast16_t const nFree =
347-
(uint_fast16_t)FREERTOS_QUEUE_GET_FREE(me);
357+
QEQueueCtr const nFree =
358+
(QEQueueCtr)FREERTOS_QUEUE_GET_FREE(me);
348359

349360
// should we try to post the event?
350-
bool status = ((margin == QF_NO_MARGIN) || (nFree > (QEQueueCtr)margin));
351-
361+
bool status = ((margin == QF_NO_MARGIN)
362+
|| (nFree > (QEQueueCtr)margin));
352363
if (status) { // should try to post the event?
353364
#if (QF_MAX_EPOOL > 0U)
354365
if (e->poolNum_ != 0U) { // is it a mutable event?
@@ -369,14 +380,17 @@ bool QActive_postFromISR_(QActive * const me,
369380
// exit crit.sect. before calling RTOS API
370381
portCLEAR_INTERRUPT_MASK_FROM_ISR(uxSavedInterruptStatus);
371382

372-
// post the event to the FreeRTOS event queue, see NOTE3
383+
// post the following evtPtr to the RTOS event queue, see NOTE3
384+
QEvtPtr const evtPtr = {
385+
e
386+
};
373387
status = (xQueueSendToBackFromISR(me->eQueue,
374-
(void const *)&e, pxHigherPriorityTaskWoken) == pdPASS);
375-
}
388+
(void const *)&evtPtr, pxHigherPriorityTaskWoken) == pdPASS);
376389

377-
if (!status) { // event NOT posted?
378390
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
391+
}
379392

393+
if (!status) { // event NOT posted?
380394
// posting is allowed to fail only when margin != QF_NO_MARGIN
381395
Q_ASSERT_INCRIT(630, margin != QF_NO_MARGIN);
382396

@@ -396,6 +410,9 @@ bool QActive_postFromISR_(QActive * const me,
396410
QF_gcFromISR(e); // recycle the event to avoid a leak
397411
#endif
398412
}
413+
else {
414+
portCLEAR_INTERRUPT_MASK_FROM_ISR(uxSavedInterruptStatus);
415+
}
399416

400417
return status;
401418
}

ports/posix-qv/qf_port.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ int QF_run(void) {
268268
#endif
269269

270270
QF_CRIT_ENTRY();
271-
if (a->eQueue.frontEvt == (QEvt *)0) { // empty queue?
271+
if (a->eQueue.frontEvt.e == (QEvt *)0) { // empty queue?
272272
QPSet_remove(&QF_readySet_, p);
273273
}
274274
}

ports/posix/qp_port.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void QF_onClockTick(void);
9797

9898
// QF event queue customization for POSIX...
9999
#define QACTIVE_EQUEUE_WAIT_(me_) do { \
100-
while ((me_)->eQueue.frontEvt == (QEvt *)0) { \
100+
while ((me_)->eQueue.frontEvt.e == (QEvt *)0) { \
101101
Q_ASSERT_INCRIT(400, QF_critSectNest_ == 1); \
102102
--QF_critSectNest_; \
103103
pthread_cond_wait(&(me_)->osObject, &QF_critSectMutex_); \

ports/qube/qube.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static void handle_evts(void) {
206206
QF_gc(e); // check if the event is garbage, and collect it if so
207207
QS_FLUSH();
208208
#endif
209-
if (a->eQueue.frontEvt == (QEvt*)0) { // empty queue?
209+
if (a->eQueue.frontEvt.e == (QEvt*)0) { // empty queue?
210210
QPSet_remove(&QF_readySet_, p);
211211
}
212212
}

0 commit comments

Comments
 (0)