From 6b3d572e3b833ad46c05f35cf4b76caab40b2e5a Mon Sep 17 00:00:00 2001 From: Cas Cremers Date: Wed, 10 Nov 2010 23:13:29 +0100 Subject: [PATCH] BUGFIX: Fixed long-standing bug with timer values, wrongly using CLOCKS_PER_SEC. --- src/timer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/timer.c b/src/timer.c index 1545c11..495f540 100644 --- a/src/timer.c +++ b/src/timer.c @@ -27,6 +27,7 @@ #ifdef linux #include +#include #include static clock_t endwait = 0; #endif @@ -44,7 +45,7 @@ set_time_limit (int seconds) { time_max_seconds = seconds; #ifdef linux - endwait = seconds * CLOCKS_PER_SEC; + endwait = seconds * sysconf (_SC_CLK_TCK); #endif } else @@ -77,7 +78,7 @@ passed_time_limit () struct tms t; times (&t); - if (t.tms_utime > endwait) + if ((t.tms_utime + t.tms_stime) > endwait) return 1; else return 0;