From 7d2486a57ad2f63c30d00d1d4302e82e10467633 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Tue, 3 Oct 2017 08:50:33 +0000 Subject: Mailboxes refactory for consistency. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10747 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/common/oslib/include/chfactory.h | 2 +- os/common/oslib/include/chfifo.h | 10 +++++----- os/common/oslib/include/chmboxes.h | 26 +++++++++++++------------- 3 files changed, 19 insertions(+), 19 deletions(-) (limited to 'os/common/oslib/include') diff --git a/os/common/oslib/include/chfactory.h b/os/common/oslib/include/chfactory.h index a18dfbefa..acb8c79a4 100644 --- a/os/common/oslib/include/chfactory.h +++ b/os/common/oslib/include/chfactory.h @@ -285,7 +285,7 @@ extern "C" { void chFactoryReleaseSemaphore(dyn_semaphore_t *dsp); #endif #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXIGEN__) - dyn_mailbox_t *chFactoryCreateMailbox(const char *name, cnt_t n); + dyn_mailbox_t *chFactoryCreateMailbox(const char *name, size_t n); dyn_mailbox_t *chFactoryFindMailbox(const char *name); void chFactoryReleaseMailbox(dyn_mailbox_t *dmp); #endif diff --git a/os/common/oslib/include/chfifo.h b/os/common/oslib/include/chfifo.h index 494689f2f..8727fff84 100644 --- a/os/common/oslib/include/chfifo.h +++ b/os/common/oslib/include/chfifo.h @@ -127,7 +127,7 @@ static inline void chMailObjectInit(objects_fifo_t *ofp, size_t objsize, chGuardedPoolObjectInit(&ofp->free, objsize); chGuardedPoolLoadArray(&ofp->free, objbuf, objn); - chMBObjectInit(&ofp->mbx, msgbuf, (cnt_t)objn); /* TODO: make this a size_t, no more sems there.*/ + chMBObjectInit(&ofp->mbx, msgbuf, objn); } /** @@ -223,7 +223,7 @@ static inline void chFifoSendObjectS(objects_fifo_t *ofp, void *objp) { msg_t msg; - msg = chMBPostS(&ofp->mbx, (msg_t)objp, TIME_IMMEDIATE); + msg = chMBPostTimeoutS(&ofp->mbx, (msg_t)objp, TIME_IMMEDIATE); chDbgAssert(msg == MSG_OK, "post failed"); } @@ -240,7 +240,7 @@ static inline void chFifoSendObject(objects_fifo_t *ofp, void *objp) { msg_t msg; - msg = chMBPost(&ofp->mbx, (msg_t)objp, TIME_IMMEDIATE); + msg = chMBPostTimeout(&ofp->mbx, (msg_t)objp, TIME_IMMEDIATE); chDbgAssert(msg == MSG_OK, "post failed"); } @@ -281,7 +281,7 @@ static inline msg_t chFifoReceiveObjectTimeoutS(objects_fifo_t *ofp, void **objpp, systime_t timeout) { - return chMBFetchS(&ofp->mbx, (msg_t *)objpp, timeout); + return chMBFetchTimeoutS(&ofp->mbx, (msg_t *)objpp, timeout); } /** @@ -304,7 +304,7 @@ static inline msg_t chFifoReceiveObjectTimeout(objects_fifo_t *ofp, void **objpp, systime_t timeout) { - return chMBFetch(&ofp->mbx, (msg_t *)objpp, timeout); + return chMBFetchTimeout(&ofp->mbx, (msg_t *)objpp, timeout); } #endif /* CH_CFG_USE_FIFO == TRUE */ diff --git a/os/common/oslib/include/chmboxes.h b/os/common/oslib/include/chmboxes.h index c31948296..e6ffd7b82 100644 --- a/os/common/oslib/include/chmboxes.h +++ b/os/common/oslib/include/chmboxes.h @@ -60,7 +60,7 @@ typedef struct { after the buffer. */ msg_t *wrptr; /**< @brief Write pointer. */ msg_t *rdptr; /**< @brief Read pointer. */ - cnt_t cnt; /**< @brief Messages in queue. */ + size_t cnt; /**< @brief Messages in queue. */ bool reset; /**< @brief True in reset state. */ threads_queue_t qw; /**< @brief Queued writers. */ threads_queue_t qr; /**< @brief Queued readers. */ @@ -84,7 +84,7 @@ typedef struct { (msg_t *)(buffer) + size, \ (msg_t *)(buffer), \ (msg_t *)(buffer), \ - (cnt_t)0, \ + (size_t)0, \ false, \ _THREADS_QUEUE_DATA(name.qw), \ _THREADS_QUEUE_DATA(name.qr), \ @@ -109,17 +109,17 @@ typedef struct { #ifdef __cplusplus extern "C" { #endif - void chMBObjectInit(mailbox_t *mbp, msg_t *buf, cnt_t n); + void chMBObjectInit(mailbox_t *mbp, msg_t *buf, size_t n); void chMBReset(mailbox_t *mbp); void chMBResetI(mailbox_t *mbp); - msg_t chMBPost(mailbox_t *mbp, msg_t msg, systime_t timeout); - msg_t chMBPostS(mailbox_t *mbp, msg_t msg, systime_t timeout); + msg_t chMBPostTimeout(mailbox_t *mbp, msg_t msg, systime_t timeout); + msg_t chMBPostTimeoutS(mailbox_t *mbp, msg_t msg, systime_t timeout); msg_t chMBPostI(mailbox_t *mbp, msg_t msg); - msg_t chMBPostAhead(mailbox_t *mbp, msg_t msg, systime_t timeout); - msg_t chMBPostAheadS(mailbox_t *mbp, msg_t msg, systime_t timeout); + msg_t chMBPostAheadTimeout(mailbox_t *mbp, msg_t msg, systime_t timeout); + msg_t chMBPostAheadTimeoutS(mailbox_t *mbp, msg_t msg, systime_t timeout); msg_t chMBPostAheadI(mailbox_t *mbp, msg_t msg); - msg_t chMBFetch(mailbox_t *mbp, msg_t *msgp, systime_t timeout); - msg_t chMBFetchS(mailbox_t *mbp, msg_t *msgp, systime_t timeout); + msg_t chMBFetchTimeout(mailbox_t *mbp, msg_t *msgp, systime_t timeout); + msg_t chMBFetchTimeoutS(mailbox_t *mbp, msg_t *msgp, systime_t timeout); msg_t chMBFetchI(mailbox_t *mbp, msg_t *msgp); #ifdef __cplusplus } @@ -137,11 +137,11 @@ extern "C" { * * @iclass */ -static inline cnt_t chMBGetSizeI(const mailbox_t *mbp) { +static inline size_t chMBGetSizeI(const mailbox_t *mbp) { /*lint -save -e9033 [10.8] Perfectly safe pointers arithmetic.*/ - return (cnt_t)(mbp->top - mbp->buffer); + return (size_t)(mbp->top - mbp->buffer); /*lint -restore*/ } @@ -154,7 +154,7 @@ static inline cnt_t chMBGetSizeI(const mailbox_t *mbp) { * * @iclass */ -static inline cnt_t chMBGetUsedCountI(const mailbox_t *mbp) { +static inline size_t chMBGetUsedCountI(const mailbox_t *mbp) { chDbgCheckClassI(); @@ -169,7 +169,7 @@ static inline cnt_t chMBGetUsedCountI(const mailbox_t *mbp) { * * @iclass */ -static inline cnt_t chMBGetFreeCountI(const mailbox_t *mbp) { +static inline size_t chMBGetFreeCountI(const mailbox_t *mbp) { chDbgCheckClassI(); -- cgit v1.2.3