diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-14 13:10:25 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-14 13:10:25 +0000 |
commit | a03ea378e79048ac188c8e4211ed2305e4643558 (patch) | |
tree | ff0d275b5770262fc9a3aa89028465eeb3cfae64 /mjit.c | |
parent | 93f7a11539dd1102a524b686d66a0aa5576be103 (diff) |
prefer clock_gettime
* configure.ac: clock_gettime or gettimeofday must exist.
* process.c (rb_clock_gettime): prefer clock_gettime over
gettimeofday, as the latter is obsolete in SUSv4.
* random.c (fill_random_seed): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'mjit.c')
-rw-r--r-- | mjit.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -222,10 +222,22 @@ static void remove_file(const char *filename); static double real_ms_time(void) { +#ifdef HAVE_CLOCK_GETTIME + struct timespec tv; +# ifdef CLOCK_MONOTONIC + const clockid_t c = CLOCK_MONOTONIC; +# else + const clockid_t c = CLOCK_REALTIME; +# endif + + clock_gettime(c, &tv); + return tv.tv_nsec / 1000000.0 + tv.tv_sec * 1000.0; +#else struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_usec / 1000.0 + tv.tv_sec * 1000.0; +#endif } /* Make and return copy of STR in the heap. */ |