[Win32] Use GetSystemTimeAsFileTime() instead of time() and

2005-03-29  Tor Lillqvist  <tml@novell.com>

	* glib/gmain.c (g_get_current_time): [Win32] Use
	GetSystemTimeAsFileTime() instead of time() and
	GetTickCount(). Much simpler.
This commit is contained in:
Tor Lillqvist 2005-03-29 08:24:48 +00:00 committed by Tor Lillqvist
parent 52013430a4
commit 8ced6d2478
5 changed files with 23 additions and 22 deletions

View File

@ -1,11 +1,13 @@
2005-03-29 Tor Lillqvist <tml@novell.com> 2005-03-29 Tor Lillqvist <tml@novell.com>
* glib/gmain.c (g_poll): If the event fired, assign * glib/gmain.c (g_poll): [Win32] If the event fired, assign
f->revents=f->events. We can't know whether the upper layer using f->revents=f->events. We can't know whether the upper layer using
the event actually is readable, writeable or what, so say that all the event actually is readable, writeable or what, so say that all
the conditions hold. Remove the ResetEvent() call that has been the conditions hold. Remove the ResetEvent() call that has been
ifdeffed out anyway for a long time. Remove an "#ifdef 1" and ifdeffed out anyway for a long time. Remove an "#ifdef 1" and
#endif pair of lines, that code is not optional. #endif pair of lines, that code is not optional.
(g_get_current_time): [Win32] Use GetSystemTimeAsFileTime()
instead of time() and GetTickCount(). Much simpler.
2005-03-28 Matthias Clasen <mclasen@redhat.com> 2005-03-28 Matthias Clasen <mclasen@redhat.com>

View File

@ -1,11 +1,13 @@
2005-03-29 Tor Lillqvist <tml@novell.com> 2005-03-29 Tor Lillqvist <tml@novell.com>
* glib/gmain.c (g_poll): If the event fired, assign * glib/gmain.c (g_poll): [Win32] If the event fired, assign
f->revents=f->events. We can't know whether the upper layer using f->revents=f->events. We can't know whether the upper layer using
the event actually is readable, writeable or what, so say that all the event actually is readable, writeable or what, so say that all
the conditions hold. Remove the ResetEvent() call that has been the conditions hold. Remove the ResetEvent() call that has been
ifdeffed out anyway for a long time. Remove an "#ifdef 1" and ifdeffed out anyway for a long time. Remove an "#ifdef 1" and
#endif pair of lines, that code is not optional. #endif pair of lines, that code is not optional.
(g_get_current_time): [Win32] Use GetSystemTimeAsFileTime()
instead of time() and GetTickCount(). Much simpler.
2005-03-28 Matthias Clasen <mclasen@redhat.com> 2005-03-28 Matthias Clasen <mclasen@redhat.com>

View File

@ -1,11 +1,13 @@
2005-03-29 Tor Lillqvist <tml@novell.com> 2005-03-29 Tor Lillqvist <tml@novell.com>
* glib/gmain.c (g_poll): If the event fired, assign * glib/gmain.c (g_poll): [Win32] If the event fired, assign
f->revents=f->events. We can't know whether the upper layer using f->revents=f->events. We can't know whether the upper layer using
the event actually is readable, writeable or what, so say that all the event actually is readable, writeable or what, so say that all
the conditions hold. Remove the ResetEvent() call that has been the conditions hold. Remove the ResetEvent() call that has been
ifdeffed out anyway for a long time. Remove an "#ifdef 1" and ifdeffed out anyway for a long time. Remove an "#ifdef 1" and
#endif pair of lines, that code is not optional. #endif pair of lines, that code is not optional.
(g_get_current_time): [Win32] Use GetSystemTimeAsFileTime()
instead of time() and GetTickCount(). Much simpler.
2005-03-28 Matthias Clasen <mclasen@redhat.com> 2005-03-28 Matthias Clasen <mclasen@redhat.com>

View File

@ -1,11 +1,13 @@
2005-03-29 Tor Lillqvist <tml@novell.com> 2005-03-29 Tor Lillqvist <tml@novell.com>
* glib/gmain.c (g_poll): If the event fired, assign * glib/gmain.c (g_poll): [Win32] If the event fired, assign
f->revents=f->events. We can't know whether the upper layer using f->revents=f->events. We can't know whether the upper layer using
the event actually is readable, writeable or what, so say that all the event actually is readable, writeable or what, so say that all
the conditions hold. Remove the ResetEvent() call that has been the conditions hold. Remove the ResetEvent() call that has been
ifdeffed out anyway for a long time. Remove an "#ifdef 1" and ifdeffed out anyway for a long time. Remove an "#ifdef 1" and
#endif pair of lines, that code is not optional. #endif pair of lines, that code is not optional.
(g_get_current_time): [Win32] Use GetSystemTimeAsFileTime()
instead of time() and GetTickCount(). Much simpler.
2005-03-28 Matthias Clasen <mclasen@redhat.com> 2005-03-28 Matthias Clasen <mclasen@redhat.com>

View File

@ -1689,26 +1689,19 @@ g_get_current_time (GTimeVal *result)
result->tv_sec = r.tv_sec; result->tv_sec = r.tv_sec;
result->tv_usec = r.tv_usec; result->tv_usec = r.tv_usec;
#else #else
/* Avoid calling time() except for the first time. FILETIME ft;
* GetTickCount() should be pretty fast and low-level? guint64 *time64 = (guint64 *) &ft;
* I could also use ftime() but it seems unnecessarily overheady.
GetSystemTimeAsFileTime (&ft);
/* Convert from 100s of nanoseconds since 1601-01-01
* to Unix epoch. Yes, this is Y2038 unsafe.
*/ */
static DWORD start_tick = 0; *time64 -= G_GINT64_CONSTANT (116444736000000000);
static time_t start_time; *time64 /= 10;
DWORD tick;
g_return_if_fail (result != NULL); result->tv_sec = *time64 / 1000000;
result->tv_usec = *time64 % 1000000;
if (start_tick == 0)
{
start_tick = GetTickCount ();
time (&start_time);
}
tick = GetTickCount ();
result->tv_sec = (tick - start_tick) / 1000 + start_time;
result->tv_usec = ((tick - start_tick) % 1000) * 1000;
#endif #endif
} }