From cf204e72ea5fd6e4be8b3295cb148fde5fdd47d2 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Tue, 16 Feb 2016 10:07:00 +0000 Subject: Tree reorganization. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8900 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/rt/src/chsem.c | 84 +++++++++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'os/rt/src/chsem.c') diff --git a/os/rt/src/chsem.c b/os/rt/src/chsem.c index 4a891b521..7f88a480c 100644 --- a/os/rt/src/chsem.c +++ b/os/rt/src/chsem.c @@ -98,8 +98,8 @@ void chSemObjectInit(semaphore_t *sp, cnt_t n) { chDbgCheck((sp != NULL) && (n >= (cnt_t)0)); - queue_init(&sp->s_queue); - sp->s_cnt = n; + queue_init(&sp->queue); + sp->cnt = n; } /** @@ -149,14 +149,14 @@ void chSemResetI(semaphore_t *sp, cnt_t n) { chDbgCheckClassI(); chDbgCheck((sp != NULL) && (n >= (cnt_t)0)); - chDbgAssert(((sp->s_cnt >= (cnt_t)0) && queue_isempty(&sp->s_queue)) || - ((sp->s_cnt < (cnt_t)0) && queue_notempty(&sp->s_queue)), + chDbgAssert(((sp->cnt >= (cnt_t)0) && queue_isempty(&sp->queue)) || + ((sp->cnt < (cnt_t)0) && queue_notempty(&sp->queue)), "inconsistent semaphore"); - cnt = sp->s_cnt; - sp->s_cnt = n; + cnt = sp->cnt; + sp->cnt = n; while (++cnt <= (cnt_t)0) { - chSchReadyI(queue_lifo_remove(&sp->s_queue))->p_u.rdymsg = MSG_RESET; + chSchReadyI(queue_lifo_remove(&sp->queue))->u.rdymsg = MSG_RESET; } } @@ -198,16 +198,16 @@ msg_t chSemWaitS(semaphore_t *sp) { chDbgCheckClassS(); chDbgCheck(sp != NULL); - chDbgAssert(((sp->s_cnt >= (cnt_t)0) && queue_isempty(&sp->s_queue)) || - ((sp->s_cnt < (cnt_t)0) && queue_notempty(&sp->s_queue)), + chDbgAssert(((sp->cnt >= (cnt_t)0) && queue_isempty(&sp->queue)) || + ((sp->cnt < (cnt_t)0) && queue_notempty(&sp->queue)), "inconsistent semaphore"); - if (--sp->s_cnt < (cnt_t)0) { - currp->p_u.wtsemp = sp; - sem_insert(currp, &sp->s_queue); + if (--sp->cnt < (cnt_t)0) { + currp->u.wtsemp = sp; + sem_insert(currp, &sp->queue); chSchGoSleepS(CH_STATE_WTSEM); - return currp->p_u.rdymsg; + return currp->u.rdymsg; } return MSG_OK; @@ -265,18 +265,18 @@ msg_t chSemWaitTimeoutS(semaphore_t *sp, systime_t time) { chDbgCheckClassS(); chDbgCheck(sp != NULL); - chDbgAssert(((sp->s_cnt >= (cnt_t)0) && queue_isempty(&sp->s_queue)) || - ((sp->s_cnt < (cnt_t)0) && queue_notempty(&sp->s_queue)), + chDbgAssert(((sp->cnt >= (cnt_t)0) && queue_isempty(&sp->queue)) || + ((sp->cnt < (cnt_t)0) && queue_notempty(&sp->queue)), "inconsistent semaphore"); - if (--sp->s_cnt < (cnt_t)0) { + if (--sp->cnt < (cnt_t)0) { if (TIME_IMMEDIATE == time) { - sp->s_cnt++; + sp->cnt++; return MSG_TIMEOUT; } - currp->p_u.wtsemp = sp; - sem_insert(currp, &sp->s_queue); + currp->u.wtsemp = sp; + sem_insert(currp, &sp->queue); return chSchGoSleepTimeoutS(CH_STATE_WTSEM, time); } @@ -294,13 +294,13 @@ msg_t chSemWaitTimeoutS(semaphore_t *sp, systime_t time) { void chSemSignal(semaphore_t *sp) { chDbgCheck(sp != NULL); - chDbgAssert(((sp->s_cnt >= (cnt_t)0) && queue_isempty(&sp->s_queue)) || - ((sp->s_cnt < (cnt_t)0) && queue_notempty(&sp->s_queue)), + chDbgAssert(((sp->cnt >= (cnt_t)0) && queue_isempty(&sp->queue)) || + ((sp->cnt < (cnt_t)0) && queue_notempty(&sp->queue)), "inconsistent semaphore"); chSysLock(); - if (++sp->s_cnt <= (cnt_t)0) { - chSchWakeupS(queue_fifo_remove(&sp->s_queue), MSG_OK); + if (++sp->cnt <= (cnt_t)0) { + chSchWakeupS(queue_fifo_remove(&sp->queue), MSG_OK); } chSysUnlock(); } @@ -320,15 +320,15 @@ void chSemSignalI(semaphore_t *sp) { chDbgCheckClassI(); chDbgCheck(sp != NULL); - chDbgAssert(((sp->s_cnt >= (cnt_t)0) && queue_isempty(&sp->s_queue)) || - ((sp->s_cnt < (cnt_t)0) && queue_notempty(&sp->s_queue)), + chDbgAssert(((sp->cnt >= (cnt_t)0) && queue_isempty(&sp->queue)) || + ((sp->cnt < (cnt_t)0) && queue_notempty(&sp->queue)), "inconsistent semaphore"); - if (++sp->s_cnt <= (cnt_t)0) { + if (++sp->cnt <= (cnt_t)0) { /* Note, it is done this way in order to allow a tail call on chSchReadyI().*/ - thread_t *tp = queue_fifo_remove(&sp->s_queue); - tp->p_u.rdymsg = MSG_OK; + thread_t *tp = queue_fifo_remove(&sp->queue); + tp->u.rdymsg = MSG_OK; (void) chSchReadyI(tp); } } @@ -350,13 +350,13 @@ void chSemAddCounterI(semaphore_t *sp, cnt_t n) { chDbgCheckClassI(); chDbgCheck((sp != NULL) && (n > (cnt_t)0)); - chDbgAssert(((sp->s_cnt >= (cnt_t)0) && queue_isempty(&sp->s_queue)) || - ((sp->s_cnt < (cnt_t)0) && queue_notempty(&sp->s_queue)), + chDbgAssert(((sp->cnt >= (cnt_t)0) && queue_isempty(&sp->queue)) || + ((sp->cnt < (cnt_t)0) && queue_notempty(&sp->queue)), "inconsistent semaphore"); while (n > (cnt_t)0) { - if (++sp->s_cnt <= (cnt_t)0) { - chSchReadyI(queue_fifo_remove(&sp->s_queue))->p_u.rdymsg = MSG_OK; + if (++sp->cnt <= (cnt_t)0) { + chSchReadyI(queue_fifo_remove(&sp->queue))->u.rdymsg = MSG_OK; } n--; } @@ -379,23 +379,23 @@ msg_t chSemSignalWait(semaphore_t *sps, semaphore_t *spw) { msg_t msg; chDbgCheck((sps != NULL) && (spw != NULL)); - chDbgAssert(((sps->s_cnt >= (cnt_t)0) && queue_isempty(&sps->s_queue)) || - ((sps->s_cnt < (cnt_t)0) && queue_notempty(&sps->s_queue)), + chDbgAssert(((sps->cnt >= (cnt_t)0) && queue_isempty(&sps->queue)) || + ((sps->cnt < (cnt_t)0) && queue_notempty(&sps->queue)), "inconsistent semaphore"); - chDbgAssert(((spw->s_cnt >= (cnt_t)0) && queue_isempty(&spw->s_queue)) || - ((spw->s_cnt < (cnt_t)0) && queue_notempty(&spw->s_queue)), + chDbgAssert(((spw->cnt >= (cnt_t)0) && queue_isempty(&spw->queue)) || + ((spw->cnt < (cnt_t)0) && queue_notempty(&spw->queue)), "inconsistent semaphore"); chSysLock(); - if (++sps->s_cnt <= (cnt_t)0) { - chSchReadyI(queue_fifo_remove(&sps->s_queue))->p_u.rdymsg = MSG_OK; + if (++sps->cnt <= (cnt_t)0) { + chSchReadyI(queue_fifo_remove(&sps->queue))->u.rdymsg = MSG_OK; } - if (--spw->s_cnt < (cnt_t)0) { + if (--spw->cnt < (cnt_t)0) { thread_t *ctp = currp; - sem_insert(ctp, &spw->s_queue); - ctp->p_u.wtsemp = spw; + sem_insert(ctp, &spw->queue); + ctp->u.wtsemp = spw; chSchGoSleepS(CH_STATE_WTSEM); - msg = ctp->p_u.rdymsg; + msg = ctp->u.rdymsg; } else { chSchRescheduleS(); -- cgit v1.2.3