This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 7cd59d01dfdab87e6047ba1ad04ad4351a685b44 (commit) from 6fd76586229a017bd0883e58bb9db1e79d29aca9 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/7cd59d01dfdab87e6047ba1ad04ad4351a685...
commit 7cd59d01dfdab87e6047ba1ad04ad4351a685b44 Author: Cyril Hrubis metan@ucw.cz Date: Fri Jun 28 10:46:03 2013 +0200
input: timers: Fix well_balaced().
Replace the table with explicit formula (I had there typos anyway).
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/demos/c_simple/timers.c b/demos/c_simple/timers.c index cb8c587..4e863c9 100644 --- a/demos/c_simple/timers.c +++ b/demos/c_simple/timers.c @@ -38,14 +38,17 @@ uint32_t callback3() return random() % 30 + 1; }
+#define MAX 10 + int main(void) { GP_TIMER_DECLARE(oneshot, 30, 0, "Oneshot", callback1, NULL); GP_TIMER_DECLARE(recurrent, 0, 4, "Recurrent", callback1, NULL); GP_TIMER_DECLARE(random, 10, 0, "Random", callback3, NULL); + GP_Timer timers[MAX]; GP_Timer *queue = NULL; uint64_t now; - int ret; + int i, ret;
GP_SetDebugLevel(10);
@@ -53,6 +56,17 @@ int main(void) GP_TimerQueueInsert(&queue, 0, &recurrent); GP_TimerQueueInsert(&queue, 0, &random);
+ for (i = 0; i < MAX; i++) { + timers[i].expires = MAX - i; + timers[i].period = 0; + timers[i].Callback = callback1; + timers[i].priv = NULL; + sprintf(timers[i].id, "Timer%i", MAX - i); + GP_TimerQueueInsert(&queue, 0, &timers[i]); + } + + GP_TimerQueueDump(queue); + for (now = 0; now < 100; now += 3) { printf("NOW %un", (unsigned int) now); printf("-------------------------------------n"); diff --git a/libs/input/GP_Timer.c b/libs/input/GP_Timer.c index 519bfe6..3f4adfe 100644 --- a/libs/input/GP_Timer.c +++ b/libs/input/GP_Timer.c @@ -65,26 +65,7 @@ static int timer_cmp(GP_Timer *t1, GP_Timer *t2) */ static int well_balanced(unsigned int sons) { - switch (sons) { - case 0: - case 2: - case 6: - case 15: - case 30: - case 62: - case 126: - case 254: - case 510: - case 1022: - case 2046: - case 4092: - case 8190: - case 16382: - case 32766: - return 1; - default: - return 0; - } + return !((sons + 2) & (sons + 1)); }
static GP_Timer *swap_left(GP_Timer *heap) @@ -161,7 +142,7 @@ static GP_Timer *rem_last(GP_Timer *heap, GP_Timer **last) return heap; }
-static GP_Timer *buble_down(GP_Timer *heap) +static GP_Timer *bubble_down(GP_Timer *heap) { GP_Timer *right = heap->right; GP_Timer *left = heap->left; @@ -172,13 +153,13 @@ static GP_Timer *buble_down(GP_Timer *heap)
if (right && timer_cmp(heap, right)) { swap_right(heap); - right->right = buble_down(heap); + right->right = bubble_down(heap); return right; }
if (left && timer_cmp(heap, left)) { swap_left(heap); - left->left = buble_down(heap); + left->left = bubble_down(heap); return left; }
@@ -201,7 +182,7 @@ static GP_Timer *pop(GP_Timer *heap) last->right = heap->right; last->sons = heap->sons;
- return buble_down(last); + return bubble_down(last); }
void GP_TimerQueueInsert(GP_Timer **heap, uint64_t now, GP_Timer *timer)
-----------------------------------------------------------------------
Summary of changes: demos/c_simple/timers.c | 16 +++++++++++++++- libs/input/GP_Timer.c | 29 +++++------------------------ 2 files changed, 20 insertions(+), 25 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.