2005-03-20 Tor Lillqvist <tml@novell.com>
+ * glib/gtimer.c: On Win32, use GetSystemTimeAsFileTime() instead
+ of GetTickCount(). (#159507)
+
* glib/gmessages.c (g_log_default_handler)
* glib/gutils.c (g_get_prgname): Move the Win32 code that asks the
program name from the system to g_get_prgname(). Do output the pid
2005-03-20 Tor Lillqvist <tml@novell.com>
+ * glib/gtimer.c: On Win32, use GetSystemTimeAsFileTime() instead
+ of GetTickCount(). (#159507)
+
* glib/gmessages.c (g_log_default_handler)
* glib/gutils.c (g_get_prgname): Move the Win32 code that asks the
program name from the system to g_get_prgname(). Do output the pid
2005-03-20 Tor Lillqvist <tml@novell.com>
+ * glib/gtimer.c: On Win32, use GetSystemTimeAsFileTime() instead
+ of GetTickCount(). (#159507)
+
* glib/gmessages.c (g_log_default_handler)
* glib/gutils.c (g_get_prgname): Move the Win32 code that asks the
program name from the system to g_get_prgname(). Do output the pid
2005-03-20 Tor Lillqvist <tml@novell.com>
+ * glib/gtimer.c: On Win32, use GetSystemTimeAsFileTime() instead
+ of GetTickCount(). (#159507)
+
* glib/gmessages.c (g_log_default_handler)
* glib/gutils.c (g_get_prgname): Move the Win32 code that asks the
program name from the system to g_get_prgname(). Do output the pid
struct _GTimer
{
#ifdef G_OS_WIN32
- DWORD start;
- DWORD end;
+ guint64 start;
+ guint64 end;
#else /* !G_OS_WIN32 */
struct timeval start;
struct timeval end;
#ifdef G_OS_WIN32
# define GETTIME(v) \
- v = GetTickCount ()
+ GetSystemTimeAsFileTime ((FILETIME *)&v)
#else /* !G_OS_WIN32 */
# define GETTIME(v) \
gettimeofday (&v, NULL)
g_timer_continue (GTimer *timer)
{
#ifdef G_OS_WIN32
- DWORD elapsed;
+ guint64 elapsed;
#else
struct timeval elapsed;
#endif /* G_OS_WIN32 */
gulong *microseconds)
{
gdouble total;
-#ifndef G_OS_WIN32
+#ifdef G_OS_WIN32
+ gint64 elapsed;
+#else
struct timeval elapsed;
#endif /* G_OS_WIN32 */
#ifdef G_OS_WIN32
if (timer->active)
- timer->end = GetTickCount ();
+ GETTIME (timer->end);
- /* Check for wraparound, which happens every 49.7 days. */
- if (timer->end < timer->start)
- total = (UINT_MAX - (timer->start - timer->end - 1)) / 1000.0;
- else
- total = (timer->end - timer->start) / 1000.0;
+ elapsed = timer->end - timer->start;
+
+ total = elapsed / 1e7;
if (microseconds)
- {
- if (timer->end < timer->start)
- *microseconds =
- ((UINT_MAX - (timer->start - timer->end - 1)) % 1000) * 1000;
- else
- *microseconds =
- ((timer->end - timer->start) % 1000) * 1000;
- }
+ *microseconds = (elapsed / 10) % 1000000;
#else /* !G_OS_WIN32 */
if (timer->active)
gettimeofday (&timer->end, NULL);