Author: Tobias Weber <tobias_webe...@gmx.de>
Branch: c8-overheads-instrumentation
Changeset: r2035:3a7fb0854cc6
Date: 2017-03-29 12:08 +0200
http://bitbucket.org/pypy/stmgc/changeset/3a7fb0854cc6/

Log:    Fix overflow of nanoseconds when summing up measurements

diff --git a/c8/stm/timing.h b/c8/stm/timing.h
--- a/c8/stm/timing.h
+++ b/c8/stm/timing.h
@@ -18,7 +18,11 @@
                            sec_diff -= 1;                                   \
                        }                                                    \
                        duration.tv_sec += sec_diff;                         \
-                       duration.tv_nsec += nanosec_diff;
+                       duration.tv_nsec += nanosec_diff;                    \
+                       if (duration.tv_nsec >= 1000000000) {                \
+                           duration.tv_sec += 1;                            \
+                           duration.tv_nsec -= 1000000000;                  \
+                       }
 
 #define pause_timer() clock_gettime(CLOCK_MONOTONIC_RAW, &stop);            \
                       get_duration()
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to