constantine/helpers/timers.nim

15 lines
371 B
Nim
Raw Normal View History

2020-03-20 22:03:52 +00:00
when defined(i386) or defined(amd64):
import x86
export getTicks
# This doesn't always work unfortunately ...
proc volatilize(x: ptr byte) {.codegenDecl: "$# $#(char const volatile *x)", inline.} =
discard
template preventOptimAway*[T](x: var T) =
volatilize(cast[ptr byte](unsafeAddr x))
template preventOptimAway*[T](x: T) =
volatilize(cast[ptr byte](x))