diff options
author | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-10-27 18:08:18 +0000 |
---|---|---|
committer | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-10-27 18:08:18 +0000 |
commit | 1839edf64ad0a4b6d96a5dd5ce24ab8075954dc6 (patch) | |
tree | 6b31c67e9168ae2c47eba9f3205f69bdd1328d42 /uisimulator | |
parent | 41add08c5edb9d3de7e223e860cef035b41a3b01 (diff) | |
download | rockbox-1839edf64ad0a4b6d96a5dd5ce24ab8075954dc6.tar.gz rockbox-1839edf64ad0a4b6d96a5dd5ce24ab8075954dc6.zip |
Add queue_peek to the kernel (written by Mike Sevakis), and use it to improve upon my previous commit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15336 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator')
-rw-r--r-- | uisimulator/sdl/kernel.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/uisimulator/sdl/kernel.c b/uisimulator/sdl/kernel.c index 96654d50ac..220d069721 100644 --- a/uisimulator/sdl/kernel.c +++ b/uisimulator/sdl/kernel.c | |||
@@ -405,6 +405,26 @@ bool queue_empty(const struct event_queue* q) | |||
405 | return ( q->read == q->write ); | 405 | return ( q->read == q->write ); |
406 | } | 406 | } |
407 | 407 | ||
408 | bool queue_peek(struct event_queue *q, struct queue_event *ev) | ||
409 | { | ||
410 | if (q->read == q->write) | ||
411 | return false; | ||
412 | |||
413 | bool have_msg = false; | ||
414 | |||
415 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
416 | |||
417 | if (q->read != q->write) | ||
418 | { | ||
419 | *ev = q->events[q->read & QUEUE_LENGTH_MASK]; | ||
420 | have_msg = true; | ||
421 | } | ||
422 | |||
423 | set_irq_level(oldlevel); | ||
424 | |||
425 | return have_msg; | ||
426 | } | ||
427 | |||
408 | void queue_clear(struct event_queue* q) | 428 | void queue_clear(struct event_queue* q) |
409 | { | 429 | { |
410 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); | 430 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); |