Mercurial > dropbear
comparison dbutil.c @ 930:8f04e36622c0
Fix monotonic_now() on OS X
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 21 Mar 2014 22:16:42 +0800 |
parents | 7cd89d4e0335 |
children | d93a6bcf616f |
comparison
equal
deleted
inserted
replaced
929:9d40ed1da686 | 930:8f04e36622c0 |
---|---|
960 syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &ts); | 960 syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &ts); |
961 } | 961 } |
962 return ts.tv_sec; | 962 return ts.tv_sec; |
963 #elif defined(HAVE_MACH_ABSOLUTE_TIME) | 963 #elif defined(HAVE_MACH_ABSOLUTE_TIME) |
964 /* OS X, see https://developer.apple.com/library/mac/qa/qa1398/_index.html */ | 964 /* OS X, see https://developer.apple.com/library/mac/qa/qa1398/_index.html */ |
965 mach_timebase_info_data_t timebase_info; | 965 static mach_timebase_info_data_t timebase_info; |
966 if (timebase_info.denom == 0) { | 966 if (timebase_info.denom == 0) { |
967 mach_timebase_info(&timebase_info); | 967 mach_timebase_info(&timebase_info); |
968 } | 968 } |
969 return mach_absolute_time() * timebase_info.numer / timebase_info.denom | 969 return mach_absolute_time() * timebase_info.numer / timebase_info.denom |
970 / 1e9; | 970 / 1e9; |