mirror of https://github.com/rusefi/ChibiOS.git
Made code compatible with -Wcast-align=strict.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14649 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
5c471d4429
commit
491a4891fb
|
@ -136,7 +136,7 @@ ASMXSRC = $(ALLXASMSRC)
|
|||
INCDIR = $(CONFDIR) $(ALLINC) $(TESTINC)
|
||||
|
||||
# Define C warning options here.
|
||||
CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes
|
||||
CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes -Wcast-align=strict
|
||||
|
||||
# Define C++ warning options here.
|
||||
CPPWARN = -Wall -Wextra -Wundef
|
||||
|
|
|
@ -597,8 +597,8 @@ struct port_context {
|
|||
* by an @p port_intctx structure.
|
||||
*/
|
||||
#define PORT_SETUP_CONTEXT(tp, wbase, wtop, pf, arg) do { \
|
||||
(tp)->ctx.sp = (struct port_intctx *)((uint8_t *)(wtop) - \
|
||||
sizeof (struct port_intctx)); \
|
||||
(tp)->ctx.sp = (struct port_intctx *)(void *) \
|
||||
((uint8_t *)(wtop) - sizeof (struct port_intctx)); \
|
||||
(tp)->ctx.sp->r4 = (uint32_t)(pf); \
|
||||
(tp)->ctx.sp->r5 = (uint32_t)(arg); \
|
||||
(tp)->ctx.sp->lr = (uint32_t)__port_thread_start; \
|
||||
|
|
|
@ -153,7 +153,7 @@ void ibqPostFullBufferI(input_buffers_queue_t *ibqp, size_t size) {
|
|||
osalDbgAssert(!ibqIsFullI(ibqp), "buffers queue full");
|
||||
|
||||
/* Writing size field in the buffer.*/
|
||||
*((size_t *)ibqp->bwrptr) = size;
|
||||
*((size_t *)(void *)ibqp->bwrptr) = size;
|
||||
|
||||
/* Posting the buffer in the queue.*/
|
||||
ibqp->bcounter++;
|
||||
|
@ -238,7 +238,7 @@ msg_t ibqGetFullBufferTimeout(input_buffers_queue_t *ibqp,
|
|||
|
||||
/* Setting up the "current" buffer and its boundary.*/
|
||||
ibqp->ptr = ibqp->brdptr + sizeof (size_t);
|
||||
ibqp->top = ibqp->ptr + *((size_t *)ibqp->brdptr);
|
||||
ibqp->top = ibqp->ptr + *((size_t *)(void *)ibqp->brdptr);
|
||||
|
||||
return MSG_OK;
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ uint8_t *obqGetFullBufferI(output_buffers_queue_t *obqp,
|
|||
}
|
||||
|
||||
/* Buffer size.*/
|
||||
*sizep = *((size_t *)obqp->brdptr);
|
||||
*sizep = *((size_t *)(void *)obqp->brdptr);
|
||||
|
||||
return obqp->brdptr + sizeof (size_t);
|
||||
}
|
||||
|
@ -630,7 +630,7 @@ void obqPostFullBufferS(output_buffers_queue_t *obqp, size_t size) {
|
|||
osalDbgAssert(!obqIsFullI(obqp), "buffers queue full");
|
||||
|
||||
/* Writing size field in the buffer.*/
|
||||
*((size_t *)obqp->bwrptr) = size;
|
||||
*((size_t *)(void *)obqp->bwrptr) = size;
|
||||
|
||||
/* Posting the buffer in the queue.*/
|
||||
obqp->bcounter--;
|
||||
|
@ -804,7 +804,7 @@ bool obqTryFlushI(output_buffers_queue_t *obqp) {
|
|||
if (size > 0U) {
|
||||
|
||||
/* Writing size field in the buffer.*/
|
||||
*((size_t *)obqp->bwrptr) = size;
|
||||
*((size_t *)(void *)obqp->bwrptr) = size;
|
||||
|
||||
/* Posting the buffer in the queue.*/
|
||||
obqp->bcounter--;
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
/**
|
||||
* @brief Kernel version string.
|
||||
*/
|
||||
#define CH_KERNEL_VERSION "7.0.0"
|
||||
#define CH_KERNEL_VERSION "7.0.1"
|
||||
|
||||
/**
|
||||
* @brief Kernel version major number.
|
||||
|
@ -63,7 +63,7 @@
|
|||
/**
|
||||
* @brief Kernel version patch number.
|
||||
*/
|
||||
#define CH_KERNEL_PATCH 0
|
||||
#define CH_KERNEL_PATCH 1
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
|
|
@ -194,6 +194,18 @@ typedef struct ch_os_instance os_instance_t;
|
|||
#define unlikely(x) x
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Safe cast of a queue pointer to a thread pointer.
|
||||
* @note Casting to a thread pointer should always be performed using
|
||||
* this macro. Casting to threads pointer is allowed by design
|
||||
* and this is the single check point for this operation.
|
||||
*
|
||||
* @param[in] p pointer to a queue/list structure
|
||||
* @return The pointer to the thread containing the queue/list
|
||||
* element.
|
||||
*/
|
||||
#define threadref(p) ((thread_t *)(void *)(p))
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -178,7 +178,7 @@ static inline void ch_sch_prio_insert(ch_queue_t *qp, ch_queue_t *tp) {
|
|||
do {
|
||||
cp = cp->next;
|
||||
} while ((cp != qp) &&
|
||||
(((thread_t *)cp)->hdr.pqueue.prio >= ((thread_t *)tp)->hdr.pqueue.prio));
|
||||
(threadref(cp)->hdr.pqueue.prio >= threadref(tp)->hdr.pqueue.prio));
|
||||
tp->next = cp;
|
||||
tp->prev = cp->prev;
|
||||
tp->prev->next = tp;
|
||||
|
|
|
@ -533,7 +533,7 @@ static inline void chSysNotifyInstance(os_instance_t *oip) {
|
|||
*/
|
||||
static inline thread_t *chSysGetIdleThreadX(void) {
|
||||
|
||||
return (thread_t *)currcore->rlist.pqueue.prev;
|
||||
return threadref(currcore->rlist.pqueue.prev);
|
||||
}
|
||||
#endif /* CH_CFG_NO_IDLE_THREAD == FALSE */
|
||||
|
||||
|
|
|
@ -496,7 +496,7 @@ static inline void chThdDoDequeueNextI(threads_queue_t *tqp, msg_t msg) {
|
|||
|
||||
chDbgAssert(ch_queue_notempty(&tqp->queue), "empty queue");
|
||||
|
||||
tp = (thread_t *)ch_queue_fifo_remove(&tqp->queue);
|
||||
tp = threadref(ch_queue_fifo_remove(&tqp->queue));
|
||||
|
||||
chDbgAssert(tp->state == CH_STATE_QUEUED, "invalid state");
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ void chCondSignal(condition_variable_t *cp) {
|
|||
|
||||
chSysLock();
|
||||
if (ch_queue_notempty(&cp->queue)) {
|
||||
chSchWakeupS((thread_t *)ch_queue_fifo_remove(&cp->queue), MSG_OK);
|
||||
chSchWakeupS(threadref(ch_queue_fifo_remove(&cp->queue)), MSG_OK);
|
||||
}
|
||||
chSysUnlock();
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ void chCondSignalI(condition_variable_t *cp) {
|
|||
chDbgCheck(cp != NULL);
|
||||
|
||||
if (ch_queue_notempty(&cp->queue)) {
|
||||
thread_t *tp = (thread_t *)ch_queue_fifo_remove(&cp->queue);
|
||||
thread_t *tp = threadref(ch_queue_fifo_remove(&cp->queue));
|
||||
tp->u.rdymsg = MSG_OK;
|
||||
(void) chSchReadyI(tp);
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ void chCondBroadcastI(condition_variable_t *cp) {
|
|||
ready list in FIFO order. The wakeup message is set to @p MSG_RESET in
|
||||
order to make a chCondBroadcast() detectable from a chCondSignal().*/
|
||||
while (ch_queue_notempty(&cp->queue)) {
|
||||
chSchReadyI((thread_t *)ch_queue_fifo_remove(&cp->queue))->u.rdymsg = MSG_RESET;
|
||||
chSchReadyI(threadref(ch_queue_fifo_remove(&cp->queue)))->u.rdymsg = MSG_RESET;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -83,16 +83,15 @@ thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size,
|
|||
const char *name, tprio_t prio,
|
||||
tfunc_t pf, void *arg) {
|
||||
thread_t *tp;
|
||||
void *wsp;
|
||||
void *wbase, *wend;
|
||||
|
||||
wsp = chHeapAllocAligned(heapp, size, PORT_WORKING_AREA_ALIGN);
|
||||
if (wsp == NULL) {
|
||||
wbase = chHeapAllocAligned(heapp, size, PORT_WORKING_AREA_ALIGN);
|
||||
if (wbase == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
wend = (void *)((uint8_t *)wbase + size);
|
||||
|
||||
thread_descriptor_t td = THD_DESCRIPTOR(name, wsp,
|
||||
(stkalign_t *)((uint8_t *)wsp + size),
|
||||
prio, pf, arg);
|
||||
thread_descriptor_t td = THD_DESCRIPTOR(name, wbase, wend, prio, pf, arg);
|
||||
|
||||
#if CH_DBG_FILL_THREADS == TRUE
|
||||
__thd_memfill((uint8_t *)wsp,
|
||||
|
@ -140,18 +139,17 @@ thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size,
|
|||
thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, const char *name,
|
||||
tprio_t prio, tfunc_t pf, void *arg) {
|
||||
thread_t *tp;
|
||||
void *wsp;
|
||||
void *wbase, *wend;
|
||||
|
||||
chDbgCheck(mp != NULL);
|
||||
|
||||
wsp = chPoolAlloc(mp);
|
||||
if (wsp == NULL) {
|
||||
wbase = chPoolAlloc(mp);
|
||||
if (wbase == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
wend = (void *)((uint8_t *)wbase + mp->object_size);
|
||||
|
||||
thread_descriptor_t td = THD_DESCRIPTOR(name, wsp,
|
||||
(stkalign_t *)((uint8_t *)wsp + mp->object_size),
|
||||
prio, pf, arg);
|
||||
thread_descriptor_t td = THD_DESCRIPTOR(name, wbase, wend, prio, pf, arg);
|
||||
|
||||
#if CH_DBG_FILL_THREADS == TRUE
|
||||
__thd_memfill((uint8_t *)wsp,
|
||||
|
|
|
@ -121,7 +121,7 @@ thread_t *chMsgWaitS(void) {
|
|||
if (!chMsgIsPendingI(currtp)) {
|
||||
chSchGoSleepS(CH_STATE_WTMSG);
|
||||
}
|
||||
tp = (thread_t *)ch_queue_fifo_remove(&currtp->msgqueue);
|
||||
tp = threadref(ch_queue_fifo_remove(&currtp->msgqueue));
|
||||
tp->state = CH_STATE_SNDMSG;
|
||||
|
||||
return tp;
|
||||
|
@ -160,7 +160,7 @@ thread_t *chMsgWaitTimeoutS(sysinterval_t timeout) {
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
tp = (thread_t *)ch_queue_fifo_remove(&currtp->msgqueue);
|
||||
tp = threadref(ch_queue_fifo_remove(&currtp->msgqueue));
|
||||
tp->state = CH_STATE_SNDMSG;
|
||||
|
||||
return tp;
|
||||
|
@ -188,7 +188,7 @@ thread_t *chMsgPollS(void) {
|
|||
thread_t *tp = NULL;
|
||||
|
||||
if (chMsgIsPendingI(currtp)) {
|
||||
tp = (thread_t *)ch_queue_fifo_remove(&currtp->msgqueue);
|
||||
tp = threadref(ch_queue_fifo_remove(&currtp->msgqueue));
|
||||
tp->state = CH_STATE_SNDMSG;
|
||||
}
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ void chMtxLockS(mutex_t *mp) {
|
|||
tp->state = CH_STATE_CURRENT;
|
||||
#endif
|
||||
/* Re-enqueues tp with its new priority on the ready list.*/
|
||||
(void) chSchReadyI((thread_t *)ch_queue_dequeue(&tp->hdr.queue));
|
||||
(void) chSchReadyI(threadref(ch_queue_dequeue(&tp->hdr.queue)));
|
||||
break;
|
||||
default:
|
||||
/* Nothing to do for other states.*/
|
||||
|
@ -359,8 +359,8 @@ void chMtxUnlock(mutex_t *mp) {
|
|||
greater priority than the current thread base priority then the
|
||||
final priority will have at least that priority.*/
|
||||
if (chMtxQueueNotEmptyS(lmp) &&
|
||||
(((thread_t *)lmp->queue.next)->hdr.pqueue.prio > newprio)) {
|
||||
newprio = ((thread_t *)lmp->queue.next)->hdr.pqueue.prio;
|
||||
((threadref(lmp->queue.next))->hdr.pqueue.prio > newprio)) {
|
||||
newprio = (threadref(lmp->queue.next))->hdr.pqueue.prio;
|
||||
}
|
||||
lmp = lmp->next;
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ void chMtxUnlock(mutex_t *mp) {
|
|||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
mp->cnt = (cnt_t)1;
|
||||
#endif
|
||||
tp = (thread_t *)ch_queue_fifo_remove(&mp->queue);
|
||||
tp = threadref(ch_queue_fifo_remove(&mp->queue));
|
||||
mp->owner = tp;
|
||||
mp->next = tp->mtxlist;
|
||||
tp->mtxlist = mp;
|
||||
|
@ -445,8 +445,8 @@ void chMtxUnlockS(mutex_t *mp) {
|
|||
greater priority than the current thread base priority then the
|
||||
final priority will have at least that priority.*/
|
||||
if (chMtxQueueNotEmptyS(lmp) &&
|
||||
(((thread_t *)lmp->queue.next)->hdr.pqueue.prio > newprio)) {
|
||||
newprio = ((thread_t *)lmp->queue.next)->hdr.pqueue.prio;
|
||||
((threadref(lmp->queue.next))->hdr.pqueue.prio > newprio)) {
|
||||
newprio = threadref(lmp->queue.next)->hdr.pqueue.prio;
|
||||
}
|
||||
lmp = lmp->next;
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ void chMtxUnlockS(mutex_t *mp) {
|
|||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
mp->cnt = (cnt_t)1;
|
||||
#endif
|
||||
tp = (thread_t *)ch_queue_fifo_remove(&mp->queue);
|
||||
tp = threadref(ch_queue_fifo_remove(&mp->queue));
|
||||
mp->owner = tp;
|
||||
mp->next = tp->mtxlist;
|
||||
tp->mtxlist = mp;
|
||||
|
@ -499,7 +499,7 @@ void chMtxUnlockAllS(void) {
|
|||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
mp->cnt = (cnt_t)1;
|
||||
#endif
|
||||
tp = (thread_t *)ch_queue_fifo_remove(&mp->queue);
|
||||
tp = threadref(ch_queue_fifo_remove(&mp->queue));
|
||||
mp->owner = tp;
|
||||
mp->next = tp->mtxlist;
|
||||
tp->mtxlist = mp;
|
||||
|
|
|
@ -132,7 +132,7 @@ thread_t *chRegFirstThread(void) {
|
|||
chSysLock();
|
||||
p = (uint8_t *)REG_HEADER(currcore)->next;
|
||||
/*lint -save -e413 [1.3] Safe to subtract a calculated offset.*/
|
||||
tp = (thread_t *)(p - __CH_OFFSETOF(thread_t, rqueue));
|
||||
tp = threadref((p - __CH_OFFSETOF(thread_t, rqueue)));
|
||||
/*lint -restore*/
|
||||
#if CH_CFG_USE_DYNAMIC == TRUE
|
||||
tp->refs++;
|
||||
|
@ -168,7 +168,7 @@ thread_t *chRegNextThread(thread_t *tp) {
|
|||
else {
|
||||
uint8_t *p = (uint8_t *)nqp;
|
||||
/*lint -save -e413 [1.3] Safe to subtract a calculated offset.*/
|
||||
ntp = (thread_t *)(p - __CH_OFFSETOF(thread_t, rqueue));
|
||||
ntp = threadref((p - __CH_OFFSETOF(thread_t, rqueue)));
|
||||
/*lint -restore*/
|
||||
|
||||
chDbgAssert(ntp->refs < (trefs_t)255, "too many references");
|
||||
|
|
|
@ -77,8 +77,8 @@ static thread_t *__sch_ready_behind(thread_t *tp) {
|
|||
tp->state = CH_STATE_READY;
|
||||
|
||||
/* Insertion in the priority queue.*/
|
||||
return (thread_t *)ch_pqueue_insert_behind(&tp->owner->rlist.pqueue,
|
||||
&tp->hdr.pqueue);
|
||||
return threadref(ch_pqueue_insert_behind(&tp->owner->rlist.pqueue,
|
||||
&tp->hdr.pqueue));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,8 +110,8 @@ static thread_t *__sch_ready_ahead(thread_t *tp) {
|
|||
tp->state = CH_STATE_READY;
|
||||
|
||||
/* Insertion in the priority queue.*/
|
||||
return (thread_t *)ch_pqueue_insert_ahead(&tp->owner->rlist.pqueue,
|
||||
&tp->hdr.pqueue);
|
||||
return threadref(ch_pqueue_insert_ahead(&tp->owner->rlist.pqueue,
|
||||
&tp->hdr.pqueue));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,7 +130,7 @@ static void __sch_reschedule_behind(void) {
|
|||
thread_t *ntp;
|
||||
|
||||
/* Picks the first thread from the ready queue and makes it current.*/
|
||||
ntp = (thread_t *)ch_pqueue_remove_highest(&oip->rlist.pqueue);
|
||||
ntp = threadref(ch_pqueue_remove_highest(&oip->rlist.pqueue));
|
||||
ntp->state = CH_STATE_CURRENT;
|
||||
__instance_set_currthread(oip, ntp);
|
||||
|
||||
|
@ -166,7 +166,7 @@ static void __sch_reschedule_ahead(void) {
|
|||
thread_t *ntp;
|
||||
|
||||
/* Picks the first thread from the ready queue and makes it current.*/
|
||||
ntp = (thread_t *)ch_pqueue_remove_highest(&oip->rlist.pqueue);
|
||||
ntp = threadref(ch_pqueue_remove_highest(&oip->rlist.pqueue));
|
||||
ntp->state = CH_STATE_CURRENT;
|
||||
__instance_set_currthread(oip, ntp);
|
||||
|
||||
|
@ -186,7 +186,7 @@ static void __sch_reschedule_ahead(void) {
|
|||
* Timeout wakeup callback.
|
||||
*/
|
||||
static void __sch_wakeup(virtual_timer_t *vtp, void *p) {
|
||||
thread_t *tp = (thread_t *)p;
|
||||
thread_t *tp = threadref(p);
|
||||
|
||||
(void)vtp;
|
||||
|
||||
|
@ -249,7 +249,7 @@ void ch_sch_prio_insert(ch_queue_t *qp, ch_queue_t *tp) {
|
|||
do {
|
||||
cp = cp->next;
|
||||
} while ((cp != qp) &&
|
||||
(((thread_t *)cp)->hdr.pqueue.prio >= ((thread_t *)tp)->hdr.pqueue.prio));
|
||||
(threadref(cp)->hdr.pqueue.prio >= threadref(tp)->hdr.pqueue.prio));
|
||||
tp->next = cp;
|
||||
tp->prev = cp->prev;
|
||||
tp->prev->next = tp;
|
||||
|
@ -318,7 +318,7 @@ void chSchGoSleepS(tstate_t newstate) {
|
|||
#endif
|
||||
|
||||
/* Next thread in ready list becomes current.*/
|
||||
ntp = (thread_t *)ch_pqueue_remove_highest(&oip->rlist.pqueue);
|
||||
ntp = threadref(ch_pqueue_remove_highest(&oip->rlist.pqueue));
|
||||
ntp->state = CH_STATE_CURRENT;
|
||||
__instance_set_currthread(oip, ntp);
|
||||
|
||||
|
@ -516,7 +516,7 @@ void chSchDoPreemption(void) {
|
|||
thread_t *ntp;
|
||||
|
||||
/* Picks the first thread from the ready queue and makes it current.*/
|
||||
ntp = (thread_t *)ch_pqueue_remove_highest(&oip->rlist.pqueue);
|
||||
ntp = threadref(ch_pqueue_remove_highest(&oip->rlist.pqueue));
|
||||
ntp->state = CH_STATE_CURRENT;
|
||||
__instance_set_currthread(oip, ntp);
|
||||
|
||||
|
@ -626,7 +626,7 @@ thread_t *chSchSelectFirstI(void) {
|
|||
thread_t *ntp;
|
||||
|
||||
/* Picks the first thread from the ready queue and makes it current.*/
|
||||
ntp = (thread_t *)ch_pqueue_remove_highest(&oip->rlist.pqueue);
|
||||
ntp = threadref(ch_pqueue_remove_highest(&oip->rlist.pqueue));
|
||||
ntp->state = CH_STATE_CURRENT;
|
||||
__instance_set_currthread(oip, ntp);
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ void chSemResetWithMessageI(semaphore_t *sp, cnt_t n, msg_t msg) {
|
|||
|
||||
sp->cnt = n;
|
||||
while (ch_queue_notempty(&sp->queue)) {
|
||||
chSchReadyI((thread_t *)ch_queue_lifo_remove(&sp->queue))->u.rdymsg = msg;
|
||||
chSchReadyI(threadref(ch_queue_lifo_remove(&sp->queue)))->u.rdymsg = msg;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ void chSemSignal(semaphore_t *sp) {
|
|||
((sp->cnt < (cnt_t)0) && ch_queue_notempty(&sp->queue)),
|
||||
"inconsistent semaphore");
|
||||
if (++sp->cnt <= (cnt_t)0) {
|
||||
chSchWakeupS((thread_t *)ch_queue_fifo_remove(&sp->queue), MSG_OK);
|
||||
chSchWakeupS(threadref(ch_queue_fifo_remove(&sp->queue)), MSG_OK);
|
||||
}
|
||||
chSysUnlock();
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ void chSemSignalI(semaphore_t *sp) {
|
|||
if (++sp->cnt <= (cnt_t)0) {
|
||||
/* Note, it is done this way in order to allow a tail call on
|
||||
chSchReadyI().*/
|
||||
thread_t *tp = (thread_t *)ch_queue_fifo_remove(&sp->queue);
|
||||
thread_t *tp = threadref(ch_queue_fifo_remove(&sp->queue));
|
||||
tp->u.rdymsg = MSG_OK;
|
||||
(void) chSchReadyI(tp);
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ void chSemAddCounterI(semaphore_t *sp, cnt_t n) {
|
|||
|
||||
while (n > (cnt_t)0) {
|
||||
if (++sp->cnt <= (cnt_t)0) {
|
||||
chSchReadyI((thread_t *)ch_queue_fifo_remove(&sp->queue))->u.rdymsg = MSG_OK;
|
||||
chSchReadyI(threadref(ch_queue_fifo_remove(&sp->queue)))->u.rdymsg = MSG_OK;
|
||||
}
|
||||
n--;
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ msg_t chSemSignalWait(semaphore_t *sps, semaphore_t *spw) {
|
|||
((spw->cnt < (cnt_t)0) && ch_queue_notempty(&spw->queue)),
|
||||
"inconsistent semaphore");
|
||||
if (++sps->cnt <= (cnt_t)0) {
|
||||
chSchReadyI((thread_t *)ch_queue_fifo_remove(&sps->queue))->u.rdymsg = MSG_OK;
|
||||
chSchReadyI(threadref(ch_queue_fifo_remove(&sps->queue)))->u.rdymsg = MSG_OK;
|
||||
}
|
||||
if (--spw->cnt < (cnt_t)0) {
|
||||
thread_t *currtp = chThdGetSelfX();
|
||||
|
|
|
@ -183,8 +183,8 @@ thread_t *chThdCreateSuspendedI(const thread_descriptor_t *tdp) {
|
|||
/* The thread structure is laid out in the upper part of the thread
|
||||
workspace. The thread position structure is aligned to the required
|
||||
stack alignment because it represents the stack top.*/
|
||||
tp = (thread_t *)((uint8_t *)tdp->wend -
|
||||
MEM_ALIGN_NEXT(sizeof (thread_t), PORT_STACK_ALIGN));
|
||||
tp = threadref(((uint8_t *)tdp->wend -
|
||||
MEM_ALIGN_NEXT(sizeof (thread_t), PORT_STACK_ALIGN)));
|
||||
|
||||
#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE)
|
||||
/* Stack boundary.*/
|
||||
|
@ -358,8 +358,8 @@ thread_t *chThdCreateStatic(void *wsp, size_t size,
|
|||
/* The thread structure is laid out in the upper part of the thread
|
||||
workspace. The thread position structure is aligned to the required
|
||||
stack alignment because it represents the stack top.*/
|
||||
tp = (thread_t *)((uint8_t *)wsp + size -
|
||||
MEM_ALIGN_NEXT(sizeof (thread_t), PORT_STACK_ALIGN));
|
||||
tp = threadref(((uint8_t *)wsp + size -
|
||||
MEM_ALIGN_NEXT(sizeof (thread_t), PORT_STACK_ALIGN)));
|
||||
|
||||
#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE)
|
||||
/* Stack boundary.*/
|
||||
|
@ -521,7 +521,7 @@ void chThdExitS(msg_t msg) {
|
|||
#if CH_CFG_USE_WAITEXIT == TRUE
|
||||
/* Waking up any waiting thread.*/
|
||||
while (unlikely(ch_list_notempty(&currtp->waiting))) {
|
||||
(void) chSchReadyI((thread_t *)ch_list_unlink(&currtp->waiting));
|
||||
(void) chSchReadyI(threadref(ch_list_unlink(&currtp->waiting)));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue