BUGFIX: Fixed long-standing bug with timer values, wrongly using CLOCKS_PER_SEC.
This commit is contained in:
parent
5c53d4bb9e
commit
6b3d572e3b
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <sys/times.h>
|
#include <sys/times.h>
|
||||||
static clock_t endwait = 0;
|
static clock_t endwait = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -44,7 +45,7 @@ set_time_limit (int seconds)
|
|||||||
{
|
{
|
||||||
time_max_seconds = seconds;
|
time_max_seconds = seconds;
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
endwait = seconds * CLOCKS_PER_SEC;
|
endwait = seconds * sysconf (_SC_CLK_TCK);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -77,7 +78,7 @@ passed_time_limit ()
|
|||||||
struct tms t;
|
struct tms t;
|
||||||
|
|
||||||
times (&t);
|
times (&t);
|
||||||
if (t.tms_utime > endwait)
|
if ((t.tms_utime + t.tms_stime) > endwait)
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user