Re-enabled timer logging if LWIP_DEBUG_TIMERNAMES!=0 (without function pointers, only function names), changed parameter names from 'h' to 'handler'

This commit is contained in:
goldsimon 2010-06-29 19:55:21 +00:00
parent 272270c7f4
commit 0f74a57267
2 changed files with 31 additions and 32 deletions

View File

@ -253,15 +253,15 @@ void sys_timeouts_init(void)
* - by calling sys_check_timeouts() (NO_SYS==1 only) * - by calling sys_check_timeouts() (NO_SYS==1 only)
* *
* @param msecs time in milliseconds after that the timer should expire * @param msecs time in milliseconds after that the timer should expire
* @param h callback function to call when msecs have elapsed * @param handler callback function to call when msecs have elapsed
* @param arg argument to pass to the callback function * @param arg argument to pass to the callback function
*/ */
#if LWIP_DEBUG_TIMERNAMES #if LWIP_DEBUG_TIMERNAMES
void void
sys_timeout_debug(u32_t msecs, sys_timeout_handler h, void *arg, const char* handler_name) sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name)
#else /* LWIP_DEBUG_TIMERNAMES */ #else /* LWIP_DEBUG_TIMERNAMES */
void void
sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg) sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg)
#endif /* LWIP_DEBUG_TIMERNAMES */ #endif /* LWIP_DEBUG_TIMERNAMES */
{ {
struct sys_timeo *timeout, *t; struct sys_timeo *timeout, *t;
@ -272,11 +272,13 @@ sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
return; return;
} }
timeout->next = NULL; timeout->next = NULL;
timeout->h = h; timeout->h = handler;
timeout->arg = arg; timeout->arg = arg;
timeout->time = msecs; timeout->time = msecs;
#if LWIP_DEBUG_TIMERNAMES #if LWIP_DEBUG_TIMERNAMES
timeout->handler_name = handler_name; timeout->handler_name = handler_name;
LWIP_DEBUGF(TIMERS_DEBUG, ("sys_timeout: %p msecs=%"U32_F" handler=%s arg=%p\n",
(void *)timeout, msecs, handler_name, (void *)arg));
#endif /* LWIP_DEBUG_TIMERNAMES */ #endif /* LWIP_DEBUG_TIMERNAMES */
if (next_timeout == NULL) { if (next_timeout == NULL) {
@ -308,13 +310,13 @@ sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
* entry, even though the timeout has not triggered yet. * entry, even though the timeout has not triggered yet.
* *
* @note This function only works as expected if there is only one timeout * @note This function only works as expected if there is only one timeout
* calling 'h' in the list of timeouts. * calling 'handler' in the list of timeouts.
* *
* @param h callback function that would be called by the timeout * @param handler callback function that would be called by the timeout
* @param arg callback argument that would be passed to h * @param arg callback argument that would be passed to handler
*/ */
void void
sys_untimeout(sys_timeout_handler h, void *arg) sys_untimeout(sys_timeout_handler handler, void *arg)
{ {
struct sys_timeo *prev_t, *t; struct sys_timeo *prev_t, *t;
@ -323,7 +325,7 @@ sys_untimeout(sys_timeout_handler h, void *arg)
} }
for (t = next_timeout, prev_t = NULL; t != NULL; prev_t = t, t = t->next) { for (t = next_timeout, prev_t = NULL; t != NULL; prev_t = t, t = t->next) {
if ((t->h == h) && (t->arg == arg)) { if ((t->h == handler) && (t->arg == arg)) {
/* We have a match */ /* We have a match */
/* Unlink from previous in list */ /* Unlink from previous in list */
if (prev_t == NULL) { if (prev_t == NULL) {
@ -355,13 +357,10 @@ sys_check_timeouts(void)
{ {
struct sys_timeo *tmptimeout; struct sys_timeo *tmptimeout;
u32_t diff; u32_t diff;
sys_timeout_handler h; sys_timeout_handler handler;
void *arg; void *arg;
int had_one; int had_one;
u32_t now; u32_t now;
#if LWIP_DEBUG_TIMERNAMES
const char *handler_name;
#endif /* LWIP_DEBUG_TIMERNAMES */
now = sys_now(); now = sys_now();
if (next_timeout) { if (next_timeout) {
@ -377,13 +376,18 @@ sys_check_timeouts(void)
timeouts_last_time = now; timeouts_last_time = now;
diff -= tmptimeout->time; diff -= tmptimeout->time;
next_timeout = tmptimeout->next; next_timeout = tmptimeout->next;
h = tmptimeout->h; handler = tmptimeout->h;
arg = tmptimeout->arg; arg = tmptimeout->arg;
#if LWIP_DEBUG_TIMERNAMES #if LWIP_DEBUG_TIMERNAMES
handler_name = tmptimeout->handler_name; if (handler != NULL) {
LWIP_DEBUGF(TIMERS_DEBUG, ("sct calling h=%s arg=%p\n",
tmptimeout->handler_name, arg));
}
#endif /* LWIP_DEBUG_TIMERNAMES */ #endif /* LWIP_DEBUG_TIMERNAMES */
memp_free(MEMP_SYS_TIMEOUT, tmptimeout); memp_free(MEMP_SYS_TIMEOUT, tmptimeout);
if (h != NULL) h(arg); if (handler != NULL) {
handler(arg);
}
} }
/* repeat until all expired timers have been called */ /* repeat until all expired timers have been called */
}while(had_one); }while(had_one);
@ -415,11 +419,8 @@ sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg)
{ {
u32_t time_needed; u32_t time_needed;
struct sys_timeo *tmptimeout; struct sys_timeo *tmptimeout;
sys_timeout_handler h; sys_timeout_handler handler;
void *arg; void *arg;
#if LWIP_DEBUG_TIMERNAMES
const char *handler_name;
#endif /* LWIP_DEBUG_TIMERNAMES */
again: again:
if (!next_timeout) { if (!next_timeout) {
@ -437,22 +438,20 @@ sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg)
deallocate the memory allocated for the timeout. */ deallocate the memory allocated for the timeout. */
tmptimeout = next_timeout; tmptimeout = next_timeout;
next_timeout = tmptimeout->next; next_timeout = tmptimeout->next;
h = tmptimeout->h; handler = tmptimeout->h;
arg = tmptimeout->arg; arg = tmptimeout->arg;
#if LWIP_DEBUG_TIMERNAMES #if LWIP_DEBUG_TIMERNAMES
handler_name = tmptimeout->handler_name; if (handler != NULL) {
LWIP_DEBUGF(TIMERS_DEBUG, ("stmf calling h=%s arg=%p\n",
tmptimeout->handler_name, arg));
}
#endif /* LWIP_DEBUG_TIMERNAMES */ #endif /* LWIP_DEBUG_TIMERNAMES */
memp_free(MEMP_SYS_TIMEOUT, tmptimeout); memp_free(MEMP_SYS_TIMEOUT, tmptimeout);
if (h != NULL) { if (handler != NULL) {
#if LWIP_DEBUG_TIMERNAMES
LWIP_DEBUGF(TIMERS_DEBUG, ("stmf calling h=%p(%p) (%s)\n", *(void**)&h, arg, handler_name));
#else /* LWIP_DEBUG_TIMERNAMES */
LWIP_DEBUGF(TIMERS_DEBUG, ("stmf calling h=%p(%p)\n", *(void**)&h, arg));
#endif /* LWIP_DEBUG_TIMERNAMES */
/* For LWIP_TCPIP_CORE_LOCKING, lock the core before calling the /* For LWIP_TCPIP_CORE_LOCKING, lock the core before calling the
timeout handler function. */ timeout handler function. */
LOCK_TCPIP_CORE(); LOCK_TCPIP_CORE();
h(arg); handler(arg);
UNLOCK_TCPIP_CORE(); UNLOCK_TCPIP_CORE();
} }
LWIP_TCPIP_THREAD_ALIVE(); LWIP_TCPIP_THREAD_ALIVE();

View File

@ -75,13 +75,13 @@ struct sys_timeo {
void sys_timeouts_init(void); void sys_timeouts_init(void);
#if LWIP_DEBUG_TIMERNAMES #if LWIP_DEBUG_TIMERNAMES
void sys_timeout_debug(u32_t msecs, sys_timeout_handler h, void *arg, const char* handler_name); void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name);
#define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler) #define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler)
#else /* LWIP_DEBUG_TIMERNAMES */ #else /* LWIP_DEBUG_TIMERNAMES */
void sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg); void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg);
#endif /* LWIP_DEBUG_TIMERNAMES */ #endif /* LWIP_DEBUG_TIMERNAMES */
void sys_untimeout(sys_timeout_handler h, void *arg); void sys_untimeout(sys_timeout_handler handler, void *arg);
#if NO_SYS #if NO_SYS
void sys_check_timeouts(void); void sys_check_timeouts(void);
void sys_restart_timeouts(void); void sys_restart_timeouts(void);