From 273eb5297498a6e04e5ffe29db27e287a8f8595e Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Thu, 26 Oct 2006 01:10:08 +0300 Subject: GetTimeInMillis: simplify monotonic test We don't actually need to get the CPU clock ID, which means we don't need the monotonic_usable test. Since there's now only one branch, the compiler will treat that as likely, so we don't need xproto 7.0.9 anymore. The fallthrough to gettimeofday() is preserved. (cherry picked from 004d00e6689f452fc9fdf91f5ffc6d6aed697d54 commit) --- os/utils.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'os') diff --git a/os/utils.c b/os/utils.c index 379291c9d..7d258a444 100644 --- a/os/utils.c +++ b/os/utils.c @@ -268,8 +268,6 @@ int auditTrailLevel = 1; _X_EXPORT Bool Must_have_memory = FALSE; -static int monotonic_usable = -1; - #ifdef AIXV3 int SyncOn = 0; extern int SelectWaitTime; @@ -550,22 +548,11 @@ _X_EXPORT CARD32 GetTimeInMillis(void) { struct timeval tv; + #ifdef MONOTONIC_CLOCK struct timespec tp; - int spare = 0; - - if (_X_UNLIKELY(monotonic_usable == -1)) { - if (clock_gettime(0, &tp) == 0 && - clock_getcpuclockid(0, &spare) == 0) - monotonic_usable = 1; - else - monotonic_usable = 0; - } - - if (_X_LIKELY(monotonic_usable == 1)) { - if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) - return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000); - } + if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) + return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000); #endif X_GETTIMEOFDAY(&tv); -- cgit v1.2.3