diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/debug.h | 1 | ||||
-rw-r--r-- | src/include/mailboxes.h | 19 | ||||
-rw-r--r-- | src/include/queues.h | 56 |
3 files changed, 44 insertions, 32 deletions
diff --git a/src/include/debug.h b/src/include/debug.h index ac9034a8b..0526e58a7 100644 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -86,6 +86,7 @@ extern "C" { #endif
#if CH_DBG_ENABLE_TRACE
extern TraceBuffer trace_buffer;
+ void trace_init(void);
void chDbgTrace(Thread *otp, Thread *ntp);
#endif
#if CH_DBG_ENABLE_ASSERTS
diff --git a/src/include/mailboxes.h b/src/include/mailboxes.h index 03623e7bc..58e386e9f 100644 --- a/src/include/mailboxes.h +++ b/src/include/mailboxes.h @@ -52,22 +52,33 @@ extern "C" { #endif
/**
- * Verifies if the mailbox has space for an immediate message.
+ * Returns the mailbox buffer size.
+ * @param[in] mbp the pointer to an initialized Mailbox object
+ */
+#define chMBSize(mbp) \
+ ((mbp)->mb_top - (mbp)->mb_buffer)
+
+/**
+ * Returns the free space into the mailbox.
* @param[in] mbp the pointer to an initialized Mailbox object
* @return The number of empty message slots.
* @note Can be invoked in any system state but if invoked out of a locked
* state then the returned value may change after reading.
+ * @note The returned value can be less than zero when there are waiting
+ * threads on the internal semaphore.
*/
-#define chMBHasSpace(mbp) chSemGetCounterI(&(mbp)->mb_emptysem)
+#define chMBGetEmpty(mbp) chSemGetCounterI(&(mbp)->mb_emptysem)
/**
- * Verifies if the mailbox has incoming messages.
+ * Returns the number of messages into the mailbox.
* @param[in] mbp the pointer to an initialized Mailbox object
* @return The number of queued messages.
* @note Can be invoked in any system state but if invoked out of a locked
* state then the returned value may change after reading.
+ * @note The returned value can be less than zero when there are waiting
+ * threads on the internal semaphore.
*/
-#define chMBContainsMessages(mbp) chSemGetCounterI(&(mbp)->mb_fullsem)
+#define chMBGetFull(mbp) chSemGetCounterI(&(mbp)->mb_fullsem)
/**
* Returns the next message in the queue without removing it.
diff --git a/src/include/queues.h b/src/include/queues.h index 36495f1a7..eea80e804 100644 --- a/src/include/queues.h +++ b/src/include/queues.h @@ -58,29 +58,27 @@ typedef struct { } Queue; /** Returns the queue's buffer size. */ -#define chQSize(q) \ - ((q)->q_top - (q)->q_buffer) +#define chQSize(q) ((q)->q_top - (q)->q_buffer) -/** Returns the used space if used on an Input Queue and the empty space if - * used on an Output Queue. */ -#define chQSpace(q) \ - ((q)->q_sem.s_cnt) +/** + * Returns the used space if used on an Input Queue and the empty space if + * used on an Output Queue. + * @note The returned value can be less than zero when there are waiting + * threads on the internal semaphore. + */ +#define chQSpace(q) chSemGetCounterI(&(q)->q_sem) /** Evaluates to TRUE if the specified Input Queue is empty. */ -#define chIQIsEmpty(q) \ - (chQSpace(q) <= 0) +#define chIQIsEmpty(q) (chQSpace(q) <= 0) /** Evaluates to TRUE if the specified Input Queue is full. */ -#define chIQIsFull(q) \ - (chQSpace(q) >= chQSize(q)) +#define chIQIsFull(q) (chQSpace(q) >= chQSize(q)) /** Evaluates to TRUE if the specified Output Queue is empty. */ -#define chOQIsEmpty(q) \ - (chQSpace(q) >= chQSize(q)) +#define chOQIsEmpty(q) (chQSpace(q) >= chQSize(q)) /** Evaluates to TRUE if the specified Output Queue is full. */ -#define chOQIsFull(q) \ - (chQSpace(q) <= 0) +#define chOQIsFull(q) (chQSpace(q) <= 0) #ifdef __cplusplus extern "C" { @@ -131,28 +129,30 @@ typedef struct { } HalfDuplexQueue; /** Returns the queue's buffer size. */ -#define chHDQSize(q) \ - ((q)->hdq_top - (q)->hdq_buffer) +#define chHDQSize(q) ((q)->hdq_top - (q)->hdq_buffer) -/** Returns the queue space when in transmission mode. */ -#define chHDQEmptySpace(q) \ - ((q)->hdq_osem.s_cnt) +/** + * Returns the queue space when in transmission mode. + * @note The returned value can be less than zero when there are waiting + * threads on the internal semaphore. + */ +#define chHDQEmptySpace(q) chSemGetCounterI(&(q)->hdq_osem) -/** Returns the number of the bytes in the queue when in receive mode. */ -#define chHDQFilledSpace(q) \ - ((q)->hdq_isem.s_cnt) +/** + * Returns the number of the bytes in the queue when in receive mode. + * @note The returned value can be less than zero when there are waiting + * threads on the internal semaphore. + */ +#define chHDQFilledSpace(q) chSemGetCounterI(&(q)->hdq_isem) /** Evaluates to TRUE if the queue is in transmit mode. */ -#define chHDQIsTransmitting(q) \ - (chHDQEmptySpace(q) < chHDQSize(q)) +#define chHDQIsTransmitting(q) (chHDQEmptySpace(q) < chHDQSize(q)) /** Evaluates to TRUE if the queue is in receive mode. */ -#define chHDQIsReceiving(q) \ - (chHDQEmptySpaceQ(q) >= chHDQSize(q)) +#define chHDQIsReceiving(q) (chHDQEmptySpaceQ(q) >= chHDQSize(q)) /** Evaluates to TRUE if the receive queue is full. */ -#define chHDQIsFullReceive(q) \ - (chHDQFilledSpace(q) >= chHDQSize(q)) +#define chHDQIsFullReceive(q) (chHDQFilledSpace(q) >= chHDQSize(q)) #ifdef __cplusplus extern "C" { |