diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-07 01:12:20 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-07 01:12:20 +0000 |
commit | 46e4dcf09d288c0771c4aa4bae9babb21e89bf58 (patch) | |
tree | ab2be4f4d867d1616a11a8f11acd8a2cd60b7235 /eval.c | |
parent | ac6eedd93287969bfc215ae0645b76d75c0ade45 (diff) |
merge revision(s) 18355:
* eval.c (timeofday): use monotonic clock. based on a patch
from zimbatm <zimbatm@oree.ch> in [ruby-core:16627].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@21359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -72,6 +72,8 @@ char *strrchr _((const char*,const char)); #include <unistd.h> #endif +#include <time.h> + #ifdef __BEOS__ #include <net/socket.h> #endif @@ -10363,6 +10365,13 @@ static double timeofday() { struct timeval tv; +#ifdef CLOCK_MONOTONIC + struct timespec tp; + + if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) { + return (double)tp.tv_sec + (double)tp.tv_nsec * 1e-9; + } +#endif gettimeofday(&tv, NULL); return (double)tv.tv_sec + (double)tv.tv_usec * 1e-6; } |