diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-09-10 11:25:17 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-09-10 11:25:17 (GMT) |
commit | ff0ed3e71cb828103cf21442231686f1b348479b (patch) | |
tree | 6918618d057babbba11f3620e5da0b2083d7accc /Python/pytime.c | |
parent | 1efbebaac2a29ae42f3de8d74071ea2eda660711 (diff) | |
download | cpython-ff0ed3e71cb828103cf21442231686f1b348479b.zip cpython-ff0ed3e71cb828103cf21442231686f1b348479b.tar.gz cpython-ff0ed3e71cb828103cf21442231686f1b348479b.tar.bz2 |
New try to fix test_time.test_AsSecondsDouble() on x86 buildbots.
Use volatile keyword in _PyTime_AsSecondsDouble()
Diffstat (limited to 'Python/pytime.c')
-rw-r--r-- | Python/pytime.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/pytime.c b/Python/pytime.c index 9470636..c82d598 100644 --- a/Python/pytime.c +++ b/Python/pytime.c @@ -332,16 +332,21 @@ _PyTime_FromMillisecondsObject(_PyTime_t *t, PyObject *obj, _PyTime_round_t roun double _PyTime_AsSecondsDouble(_PyTime_t t) { + /* volatile avoids optimization changing how numbers are rounded */ + volatile double d; + if (t % SEC_TO_NS == 0) { _PyTime_t secs; /* Divide using integers to avoid rounding issues on the integer part. 1e-9 cannot be stored exactly in IEEE 64-bit. */ secs = t / SEC_TO_NS; - return (double)secs; + d = (double)secs; } else { - return (double)t / 1e9; + d = (double)t; + d /= 1e9; } + return d; } PyObject * |