summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-04-14 09:47:47 +0000
committerJens Arnold <amiconn@rockbox.org>2007-04-14 09:47:47 +0000
commit0b7bb31453762f354af30210d1981f5dec3cdc19 (patch)
tree2af3ee3a98a3e9e2179421a367f12d2b97f7320d /firmware
parent9bfa237869ec3a75776926de7ffd4e7a1c4e03b9 (diff)
downloadrockbox-0b7bb31453762f354af30210d1981f5dec3cdc19.tar.gz
rockbox-0b7bb31453762f354af30210d1981f5dec3cdc19.tar.bz2
rockbox-0b7bb31453762f354af30210d1981f5dec3cdc19.zip
Simplification, queue pointers don't wrap (except at INT_MAX, but the calculation is still correct in this case). Implemented queue_count() for the simulator.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13154 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/kernel.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/firmware/kernel.c b/firmware/kernel.c
index 310832c8af..b073915c04 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -345,7 +345,7 @@ intptr_t queue_send(struct event_queue *q, long id, intptr_t data)
{
int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
unsigned int wr;
-
+
lock_cores();
wr = q->write++ & QUEUE_LENGTH_MASK;
@@ -495,23 +495,20 @@ void queue_remove_from_head(struct event_queue *q, long id)
int queue_count(const struct event_queue *q)
{
int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
- int result = 0;
+ int result;
#if NUM_CORES > 1
if (!q->irq_safe)
lock_cores();
#endif
- if (q->read <= q->write)
- result = q->write - q->read;
- else
- result = QUEUE_LENGTH - (q->read - q->write);
-
+ result = q->write - q->read;
+
#if NUM_CORES > 1
if (!q->irq_safe)
unlock_cores();
#endif
-
+
set_irq_level(oldlevel);
return result;