aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-02-18 12:58:35 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-02-18 12:58:35 +0000
commit4c2be4a8e9211f53e3b460de2ad5e9d3e4be70c8 (patch)
treeff9d69f7b2528008d5410895cf979cf158e918fb /src
parent6b6e5b95fb78af5f4c018c74b54b15a82b32d812 (diff)
downloadChibiOS-4c2be4a8e9211f53e3b460de2ad5e9d3e4be70c8.tar.gz
ChibiOS-4c2be4a8e9211f53e3b460de2ad5e9d3e4be70c8.tar.bz2
ChibiOS-4c2be4a8e9211f53e3b460de2ad5e9d3e4be70c8.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@781 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src')
-rw-r--r--src/chdebug.c1
-rw-r--r--src/include/debug.h1
-rw-r--r--src/include/mailboxes.h19
-rw-r--r--src/include/queues.h56
4 files changed, 45 insertions, 32 deletions
diff --git a/src/chdebug.c b/src/chdebug.c
index 63d5090ee..a3873cb60 100644
--- a/src/chdebug.c
+++ b/src/chdebug.c
@@ -40,6 +40,7 @@ void trace_init(void) {
trace_buffer.tb_size = TRACE_BUFFER_SIZE;
trace_buffer.tb_ptr = &trace_buffer.tb_buffer[0];
}
+
/**
* @brief Inserts in the circular debug trace buffer a context switch record.
*
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" {