Commit 81c726be authored by Aurelio Colosimo's avatar Aurelio Colosimo

fixed bugged timer handling (caused seg faults)

parent 87e9c057
...@@ -43,7 +43,9 @@ int posix_timer_init(struct pp_instance *ppi) ...@@ -43,7 +43,9 @@ int posix_timer_init(struct pp_instance *ppi)
int posix_timer_start(uint32_t interval, struct pp_timer *tm) int posix_timer_start(uint32_t interval, struct pp_timer *tm)
{ {
time((time_t*)&tm->start); time_t now;
now = time(NULL);
tm->start = (uint32_t)now;
tm->interval = interval; tm->interval = interval;
return 0; return 0;
...@@ -59,16 +61,16 @@ int posix_timer_stop(struct pp_timer *tm) ...@@ -59,16 +61,16 @@ int posix_timer_stop(struct pp_timer *tm)
int posix_timer_expired(struct pp_timer *tm) int posix_timer_expired(struct pp_timer *tm)
{ {
uint32_t now; time_t now;
if (tm->start == 0) { if (tm->start == 0) {
PP_PRINTF("Warning: posix_timer_expired: timer not started\n"); PP_PRINTF("%p Warning: posix_timer_expired: timer not started\n",tm);
return 0; return 0;
} }
time((time_t*)&now); now = time(NULL);
if (tm->start + tm->interval < now) if (tm->start + tm->interval < (uint32_t)now)
return 1; return 1;
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment