diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-02-18 12:58:35 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-02-18 12:58:35 +0000 |
commit | 4c2be4a8e9211f53e3b460de2ad5e9d3e4be70c8 (patch) | |
tree | ff9d69f7b2528008d5410895cf979cf158e918fb /src/include/queues.h | |
parent | 6b6e5b95fb78af5f4c018c74b54b15a82b32d812 (diff) | |
download | ChibiOS-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/include/queues.h')
-rw-r--r-- | src/include/queues.h | 56 |
1 files changed, 28 insertions, 28 deletions
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" { |