diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2012-03-28 00:50:46 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2012-03-28 00:50:46 (GMT) |
commit | 74eb6c0e8bcdab65ac10f5a0a880768eef15a601 (patch) | |
tree | 54fd16e2f3f9de87a50be94054ddceecad24358a /Modules/timemodule.c | |
parent | 650365b1633891fb8281b375e54ae13201e05a73 (diff) | |
download | cpython-74eb6c0e8bcdab65ac10f5a0a880768eef15a601.zip cpython-74eb6c0e8bcdab65ac10f5a0a880768eef15a601.tar.gz cpython-74eb6c0e8bcdab65ac10f5a0a880768eef15a601.tar.bz2 |
Document the fact that mach_timebase_info() cannot fail
And call mach_absolute_time() after mach_timebase_info().
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r-- | Modules/timemodule.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index b32c9df..c99c0a9 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -768,13 +768,17 @@ steady_clock(int strict) #if defined(MS_WINDOWS) && !defined(__BORLANDC__) return win32_clock(!strict); #elif defined(__APPLE__) - uint64_t time = mach_absolute_time(); + static mach_timebase_info_data_t timebase; + uint64_t time; double secs; - static mach_timebase_info_data_t timebase; - if (timebase.denom == 0) - mach_timebase_info(&timebase); + if (timebase.denom == 0) { + /* According to the Technical Q&A QA1398, mach_timebase_info() cannot + fail: https://developer.apple.com/library/mac/#qa/qa1398/ */ + (void)mach_timebase_info(&timebase); + } + time = mach_absolute_time(); secs = (double)time * timebase.numer / timebase.denom * 1e-9; return PyFloat_FromDouble(secs); |