summaryrefslogtreecommitdiff
path: root/glib
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2000-08-31 20:55:16 +0000
committerTor Lillqvist <tml@src.gnome.org>2000-08-31 20:55:16 +0000
commita7e60b75765df7817f6c0f4e86b8939ba988e826 (patch)
tree087d66fd1f0cb05050727b0eaf5295a29208685a /glib
parent55cd16c99323958546409e5feb60bdd6363583d6 (diff)
downloadglib-a7e60b75765df7817f6c0f4e86b8939ba988e826.tar.gz
Simplify, use GetSystemTimeAsFileTime().
2000-08-31 Tor Lillqvist <tml@iki.fi> * gmain.c (g_get_current_time): (Win32): Simplify, use GetSystemTimeAsFileTime().
Diffstat (limited to 'glib')
-rw-r--r--glib/gmain.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/glib/gmain.c b/glib/gmain.c
index 0258570f3..dafd09a42 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -629,26 +629,15 @@ g_get_current_time (GTimeVal *result)
result->tv_sec = r.tv_sec;
result->tv_usec = r.tv_usec;
#else
- /* Avoid calling time() except for the first time.
- * GetTickCount() should be pretty fast and low-level?
- * I could also use ftime() but it seems unnecessarily overheady.
- */
- static DWORD start_tick = 0;
- static time_t start_time;
- DWORD tick;
-
- g_return_if_fail (result != NULL);
-
- if (start_tick == 0)
- {
- start_tick = GetTickCount ();
- time (&start_time);
- }
+ FILETIME filetime;
+ gint64 t;
- tick = GetTickCount ();
+ GetSystemTimeAsFileTime (&filetime);
+ t = ((gint64) filetime.dwLowDateTime) +
+ ((gint64) filetime.dwHighDateTime) * G_GINT64_CONSTANT (0x100000000);
- result->tv_sec = (tick - start_tick) / 1000 + start_time;
- result->tv_usec = ((tick - start_tick) % 1000) * 1000;
+ result->tv_sec = (t - G_GINT64_CONSTANT (0x19db1ded53e8000)) / 10000000;
+ result->tv_usec = (t % 10000000) / 10;
#endif
}