Unify kernel list management for ticks, registered queues and timeout objects by using NULL-terminated lists of pointers. Redo timeout API a bit to simplify it and integrate it. Should give some small binsize reduction accross the board but more if timeout objects are being included.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19808 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2009-01-21 02:44:20 +00:00
parent a7ec73cddd
commit 580d91f097
5 changed files with 122 additions and 120 deletions

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Björn Stenberg
* Copyright (C) 2002 by Björn Stenberg
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -204,12 +204,15 @@ extern volatile long current_tick;
static inline void call_tick_tasks(void)
{
extern void (*tick_funcs[MAX_NUM_TICK_TASKS+1])(void);
int i;
void (**p)(void) = tick_funcs;
void (*fn)(void);
current_tick++;
for (i = 0; tick_funcs[i] != NULL; i++)
tick_funcs[i]();
for(fn = *p; fn != NULL; fn = *(++p))
{
fn();
}
}
#endif
@ -229,18 +232,16 @@ struct timeout;
/* timeout callback type
* tmo - pointer to struct timeout associated with event
* return next interval or <= 0 to stop event
*/
typedef bool (* timeout_cb_type)(struct timeout *tmo);
#define MAX_NUM_TIMEOUTS 8
typedef int (* timeout_cb_type)(struct timeout *tmo);
struct timeout
{
/* for use by callback/internal - read/write */
timeout_cb_type callback;/* callback - returning false cancels */
int ticks; /* timeout period in ticks */
intptr_t data; /* data passed to callback */
/* internal use - read-only */
const struct timeout * const next; /* next timeout in list */
const long expires; /* expiration tick */
long expires; /* expiration tick */
};
void timeout_register(struct timeout *tmo, timeout_cb_type callback,