summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2015-02-22 21:24:23 +0100
committerAndreas Rumpf <rumpf_a@web.de>2015-02-22 21:24:23 +0100
commit890dcabbde506e9545278311918b00d8e1d7b710 (patch)
tree70ad5df4133776cd115b7a58b9128400c778a996 /lib
parent63c6bc9c69496094b50756aa55b9c6fdffb44f03 (diff)
parentc41e0bdbe32f1f08951aef6e746265775b1ecba8 (diff)
downloadNim-890dcabbde506e9545278311918b00d8e1d7b710.tar.gz
Merge pull request #2194 from GrundleTrundle/windows_timer_sub
Fix for timer overflow when using nimprofiler with 32bit Windows target.
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/nimprof.nim2
-rw-r--r--lib/system/timers.nim4
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/pure/nimprof.nim b/lib/pure/nimprof.nim
index 3598cdd3a..cce2a20ae 100644
--- a/lib/pure/nimprof.nim
+++ b/lib/pure/nimprof.nim
@@ -132,7 +132,7 @@ else:
   proc hook(st: TStackTrace) {.nimcall.} =
     if interval == 0:
       hookAux(st, 1)
-    elif getTicks() - t0 > interval:
+    elif int64(t0) == 0 or getTicks() - t0 > interval:
       hookAux(st, 1)
       t0 = getTicks()
 
diff --git a/lib/system/timers.nim b/lib/system/timers.nim
index e58ff7adc..e5de791ac 100644
--- a/lib/system/timers.nim
+++ b/lib/system/timers.nim
@@ -27,9 +27,9 @@ when defined(windows):
   proc `-`(a, b: TTicks): TNanos =
     var frequency: int64
     QueryPerformanceFrequency(frequency)
-    var performanceCounterRate = 1000000000.0 / toFloat(frequency.int)
+    var performanceCounterRate = 1e+9'f64 / float64(frequency)
 
-    result = ((a.int64 - b.int64).int.toFloat * performanceCounterRate).TNanos
+    result = TNanos(float64(a.int64 - b.int64) * performanceCounterRate)
 
 elif defined(macosx):
   type
ass="k">let s: seq[int] = @[0, 1, 2, 3, 4, 5, 6] #s[1..3] = @[]