glib/gthread.c (gettime) GetSystemTimeAsFileTime() returns 100s of
authorTor Lillqvist <tml@novell.com>
Tue, 16 Jan 2007 13:57:05 +0000 (13:57 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Tue, 16 Jan 2007 13:57:05 +0000 (13:57 +0000)
2007-01-16  Tor Lillqvist  <tml@novell.com>

* glib/gthread.c (gettime)
* gthread-win32.c (g_gettime_win32_impl):
GetSystemTimeAsFileTime() returns 100s of nanoseconds since 1601,
so offset to Unix epoch (1970) and multiply by 100 to get
nanoseconds which is what we want.

svn path=/trunk/; revision=5277

ChangeLog
glib/gthread.c
gthread/ChangeLog
gthread/gthread-win32.c

index 2980b23e6b3d54e8321706c4d9b8885c43a4cfa1..aa1993e9465e831d9421614f22655f267e5d5b94 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,8 @@
 2007-01-16  Tor Lillqvist  <tml@novell.com>
 
        * glib/gthread.c (gettime): GetSystemTimeAsFileTime() returns 100s
-       of nanoseconds, so multiply by 100 to get nanoseconds which is
-       what we want.
+       of nanoseconds since 1601, so offset to Unix epoch (1970) and
+       multiply by 100 to get nanoseconds which is what we want.
 
 2007-01-15  Tor Lillqvist  <tml@novell.com>
 
index 683ad4a47c920dd22bc040cc2ff7bd519e1bc222..116c2af25e9de6457ae116324dc06d60b0d9438d 100644 (file)
@@ -554,7 +554,12 @@ gettime (void)
 #ifdef G_OS_WIN32
   guint64 v;
 
+  /* Returns 100s of nanoseconds since start of 1601 */
   GetSystemTimeAsFileTime ((FILETIME *)&v);
+
+  /* Offset to Unix epoch */
+  v -= G_GINT64_CONSTANT (116444736000000000);
+  /* Convert to nanoseconds */
   v *= 100;
 
   return v;
index 82222eb80f5d8f0159d4254dfcee2046353bdb0f..f86b7fced628ff8d428d8fca4d273bf6dd8c41ce 100644 (file)
@@ -1,8 +1,9 @@
 2007-01-16  Tor Lillqvist  <tml@novell.com>
 
        * gthread-win32.c (g_gettime_win32_impl):
-       GetSystemTimeAsFileTime() returns 100s of nanoseconds, so multiply
-       by 100 to get nanoseconds which is what we want.
+       GetSystemTimeAsFileTime() returns 100s of nanoseconds since 1601,
+       so offset to Unix epoch (1970) and multiply by 100 to get
+       nanoseconds which is what we want.
 
 2006-12-28  Tor Lillqvist  <tml@novell.com>
 
index d55e265bb57f99b7af9a23aefda2c3d92e6f6777..78e2ecda41feff5b4c9f1e9a7776db6ea6dcb35a 100644 (file)
@@ -550,7 +550,12 @@ g_gettime_win32_impl (void)
 {
   guint64 v;
 
+  /* Returns 100s of nanoseconds since start of 1601 */
   GetSystemTimeAsFileTime ((FILETIME *)&v);
+
+  /* Offset to Unix epoch */
+  v -= G_GINT64_CONSTANT (116444736000000000);
+  /* Convert to nanoseconds */
   v *= 100;
 
   return v;