Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmr: add tmr_start_dbg #373

Merged
merged 2 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion include/re_tmr.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ struct tmr {
tmr_h *th; /**< Timeout handler */
void *arg; /**< Handler argument */
uint64_t jfs; /**< Jiffies for timeout */
char *file;
int line;
};


Expand All @@ -29,7 +31,22 @@ void tmr_debug(void);
int tmr_status(struct re_printf *pf, void *unused);

void tmr_init(struct tmr *tmr);
void tmr_start(struct tmr *tmr, uint64_t delay, tmr_h *th, void *arg);
void tmr_start_dbg(struct tmr *tmr, uint64_t delay, tmr_h *th, void *arg,
char *file, int line);

/**
* @def tmr_start(tmr, delay, th, arg)
*
* Start a timer
*
* @param tmr Timer to start
* @param delay Timer delay in [ms]
* @param th Timeout handler
* @param arg Handler argument
*/
#define tmr_start(tmr, delay, th, arg) \
tmr_start_dbg(tmr, delay, th, arg, __FILE__, __LINE__)

void tmr_cancel(struct tmr *tmr);
uint64_t tmr_get_expire(const struct tmr *tmr);

Expand Down
23 changes: 9 additions & 14 deletions src/tmr/tmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ int tmr_status(struct re_printf *pf, void *unused)

for (le = tmrl->head; le; le = le->next) {
const struct tmr *tmr = le->data;

err |= re_hprintf(pf, " %p: th=%p expire=%llums\n",
err |= re_hprintf(pf, " %p: th=%p expire=%llums file=%s:%d\n",
tmr, tmr->th,
(unsigned long long)tmr_get_expire(tmr));
(unsigned long long)tmr_get_expire(tmr),
tmr->file, tmr->line);
}

if (n > 100)
Expand Down Expand Up @@ -248,15 +248,8 @@ void tmr_init(struct tmr *tmr)
}


/**
* Start a timer
*
* @param tmr Timer to start
* @param delay Timer delay in [ms]
* @param th Timeout handler
* @param arg Handler argument
*/
void tmr_start(struct tmr *tmr, uint64_t delay, tmr_h *th, void *arg)
void tmr_start_dbg(struct tmr *tmr, uint64_t delay, tmr_h *th, void *arg,
char *file, int line)
{
struct list *tmrl = tmrl_get();
struct le *le;
Expand All @@ -268,8 +261,10 @@ void tmr_start(struct tmr *tmr, uint64_t delay, tmr_h *th, void *arg)
list_unlink(&tmr->le);
}

tmr->th = th;
tmr->arg = arg;
tmr->th = th;
tmr->arg = arg;
tmr->file = file;
tmr->line = line;

if (!th)
return;
Expand Down