diff options
author | Jens Arnold <amiconn@rockbox.org> | 2007-04-14 09:47:47 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2007-04-14 09:47:47 +0000 |
commit | 0b7bb31453762f354af30210d1981f5dec3cdc19 (patch) | |
tree | 2af3ee3a98a3e9e2179421a367f12d2b97f7320d | |
parent | 9bfa237869ec3a75776926de7ffd4e7a1c4e03b9 (diff) | |
download | rockbox-0b7bb31453762f354af30210d1981f5dec3cdc19.tar.gz 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
-rw-r--r-- | apps/gui/list.c | 4 | ||||
-rw-r--r-- | firmware/kernel.c | 13 | ||||
-rw-r--r-- | uisimulator/sdl/kernel.c | 5 |
3 files changed, 10 insertions, 12 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c index bd63021369..e3b0d6afe5 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c | |||
@@ -943,9 +943,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, | |||
943 | case ACTION_STD_PREV: | 943 | case ACTION_STD_PREV: |
944 | case ACTION_STD_PREVREPEAT: | 944 | case ACTION_STD_PREVREPEAT: |
945 | gui_synclist_select_previous(lists); | 945 | gui_synclist_select_previous(lists); |
946 | #ifndef SIMULATOR | ||
947 | if (queue_count(&button_queue) < FRAMEDROP_TRIGGER) | 946 | if (queue_count(&button_queue) < FRAMEDROP_TRIGGER) |
948 | #endif | ||
949 | gui_synclist_draw(lists); | 947 | gui_synclist_draw(lists); |
950 | yield(); | 948 | yield(); |
951 | return ACTION_STD_PREV; | 949 | return ACTION_STD_PREV; |
@@ -953,9 +951,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, | |||
953 | case ACTION_STD_NEXT: | 951 | case ACTION_STD_NEXT: |
954 | case ACTION_STD_NEXTREPEAT: | 952 | case ACTION_STD_NEXTREPEAT: |
955 | gui_synclist_select_next(lists); | 953 | gui_synclist_select_next(lists); |
956 | #ifndef SIMULATOR | ||
957 | if (queue_count(&button_queue) < FRAMEDROP_TRIGGER) | 954 | if (queue_count(&button_queue) < FRAMEDROP_TRIGGER) |
958 | #endif | ||
959 | gui_synclist_draw(lists); | 955 | gui_synclist_draw(lists); |
960 | yield(); | 956 | yield(); |
961 | return ACTION_STD_NEXT; | 957 | return ACTION_STD_NEXT; |
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) | |||
345 | { | 345 | { |
346 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); | 346 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); |
347 | unsigned int wr; | 347 | unsigned int wr; |
348 | 348 | ||
349 | lock_cores(); | 349 | lock_cores(); |
350 | 350 | ||
351 | wr = q->write++ & QUEUE_LENGTH_MASK; | 351 | wr = q->write++ & QUEUE_LENGTH_MASK; |
@@ -495,23 +495,20 @@ void queue_remove_from_head(struct event_queue *q, long id) | |||
495 | int queue_count(const struct event_queue *q) | 495 | int queue_count(const struct event_queue *q) |
496 | { | 496 | { |
497 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); | 497 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); |
498 | int result = 0; | 498 | int result; |
499 | 499 | ||
500 | #if NUM_CORES > 1 | 500 | #if NUM_CORES > 1 |
501 | if (!q->irq_safe) | 501 | if (!q->irq_safe) |
502 | lock_cores(); | 502 | lock_cores(); |
503 | #endif | 503 | #endif |
504 | 504 | ||
505 | if (q->read <= q->write) | 505 | result = q->write - q->read; |
506 | result = q->write - q->read; | 506 | |
507 | else | ||
508 | result = QUEUE_LENGTH - (q->read - q->write); | ||
509 | |||
510 | #if NUM_CORES > 1 | 507 | #if NUM_CORES > 1 |
511 | if (!q->irq_safe) | 508 | if (!q->irq_safe) |
512 | unlock_cores(); | 509 | unlock_cores(); |
513 | #endif | 510 | #endif |
514 | 511 | ||
515 | set_irq_level(oldlevel); | 512 | set_irq_level(oldlevel); |
516 | 513 | ||
517 | return result; | 514 | return result; |
diff --git a/uisimulator/sdl/kernel.c b/uisimulator/sdl/kernel.c index 8918ff7e12..98d509f6a6 100644 --- a/uisimulator/sdl/kernel.c +++ b/uisimulator/sdl/kernel.c | |||
@@ -281,6 +281,11 @@ void queue_remove_from_head(struct event_queue *q, long id) | |||
281 | set_irq_level(oldlevel); | 281 | set_irq_level(oldlevel); |
282 | } | 282 | } |
283 | 283 | ||
284 | int queue_count(const struct event_queue *q) | ||
285 | { | ||
286 | return q->write - q->read; | ||
287 | } | ||
288 | |||
284 | void switch_thread(bool save_context, struct thread_entry **blocked_list) | 289 | void switch_thread(bool save_context, struct thread_entry **blocked_list) |
285 | { | 290 | { |
286 | (void)save_context; | 291 | (void)save_context; |