From 1839edf64ad0a4b6d96a5dd5ce24ab8075954dc6 Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Sat, 27 Oct 2007 18:08:18 +0000 Subject: 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 --- uisimulator/sdl/kernel.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'uisimulator/sdl/kernel.c') 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) return ( q->read == q->write ); } +bool queue_peek(struct event_queue *q, struct queue_event *ev) +{ + if (q->read == q->write) + return false; + + bool have_msg = false; + + int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); + + if (q->read != q->write) + { + *ev = q->events[q->read & QUEUE_LENGTH_MASK]; + have_msg = true; + } + + set_irq_level(oldlevel); + + return have_msg; +} + void queue_clear(struct event_queue* q) { int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); -- cgit v1.2.3