summaryrefslogtreecommitdiff
path: root/src/cairo-time.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-05-20 10:54:07 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-05-20 10:55:25 +0100
commitdad69ce4d5568f94621ae60ccdcc683d5bbd0efd (patch)
tree392206b8748574540132eb3c5b655809b51fe46a /src/cairo-time.c
parent5a7a9c93e7f807ae8ee7504ff308e9676dbe8d25 (diff)
win32: Fix return value for cairo_time_get
Without uint64_t we need to construct a cairo_int64_t from the struct of smaller 32-bit types rather than just casting the larger 64-bit value. Reported-by: Hakki Dogusan <dogusanh@tr.net> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-time.c')
-rw-r--r--src/cairo-time.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/cairo-time.c b/src/cairo-time.c
index 9a594e8e..a0003fbf 100644
--- a/src/cairo-time.c
+++ b/src/cairo-time.c
@@ -103,6 +103,25 @@ _cairo_time_1s (void)
return freq.QuadPart;
}
+#ifndef HAVE_UINT64_T
+static cairo_always_inline cairo_time_t
+_cairo_time_from_large_integer (LARGE_INTEGER t)
+{
+ cairo_int64_t r;
+
+ r = _cairo_int64_lsl (_cairo_int32_to_int64 (t.HighPart), 32);
+ r = _cairo_int64_add (r, _cairo_int32_to_int64 (t.LowPart));
+
+ return r;
+}
+#else
+static cairo_always_inline cairo_time_t
+_cairo_time_from_large_integer (LARGE_INTEGER t)
+{
+ return t.QuadPart;
+}
+#endif
+
cairo_time_t
_cairo_time_get (void)
{
@@ -110,7 +129,7 @@ _cairo_time_get (void)
QueryPerformanceCounter (&t);
- return t.QuadPart;
+ return _cairo_time_from_large_integer(t);
}
#elif defined(CAIRO_CLOCK)