[Python-checkins] cpython: New try to fix test_time.test_AsSecondsDouble() on x86 buildbots.
victor.stinner
python-checkins at python.org
Thu Sep 10 13:25:58 CEST 2015
https://hg.python.org/cpython/rev/fa66577f6807
changeset: 97853:fa66577f6807
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu Sep 10 13:25:17 2015 +0200
summary:
New try to fix test_time.test_AsSecondsDouble() on x86 buildbots.
Use volatile keyword in _PyTime_AsSecondsDouble()
files:
Python/pytime.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/Python/pytime.c b/Python/pytime.c
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -332,16 +332,21 @@
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 *
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list