From 579c7a3df4d548a01f367aef33ba922d5682a4cf Mon Sep 17 00:00:00 2001 From: jifl Date: Thu, 19 Jun 2008 15:31:12 +0000 Subject: [PATCH] sys_jiffies(): set sec and usec correctly from gettimeofday(), and avoid sec overflow --- ports/unix/sys_arch.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ports/unix/sys_arch.c b/ports/unix/sys_arch.c index bdc36a5..57f0a8d 100644 --- a/ports/unix/sys_arch.c +++ b/ports/unix/sys_arch.c @@ -587,10 +587,12 @@ unsigned long sys_jiffies(void) { struct timeval tv; - unsigned long sec = tv.tv_sec; - long usec = tv.tv_usec; + unsigned long sec; + long usec; gettimeofday(&tv,NULL); + sec = tv.tv_sec - starttime.tv_sec; + usec = tv.tv_usec; if (sec >= (MAX_JIFFY_OFFSET / HZ)) return MAX_JIFFY_OFFSET;