BUGFIX: Fixed long-standing bug with timer values, wrongly using CLOCKS_PER_SEC.

This commit is contained in:
Cas Cremers 2010-11-10 23:13:29 +01:00
parent 5c53d4bb9e
commit 6b3d572e3b

View File

@ -27,6 +27,7 @@
#ifdef linux
#include <time.h>
#include <unistd.h>
#include <sys/times.h>
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;