mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 07:56:17 +01:00
MSDN says: "Do not cast a pointer to a FILETIME structure to either a
2008-08-04 Tor Lillqvist <tml@novell.com> * glib/gmain.c (g_get_current_time): MSDN says: "Do not cast a pointer to a FILETIME structure to either a LARGE_INTEGER* or __int64* value because it can cause alignment faults on 64-bit Windows." So don't do that then. Indeed the code did work randomly on Win64 when compiled with optimisation. svn path=/trunk/; revision=7308
This commit is contained in:
parent
81481e8436
commit
c9211d68fc
@ -1,3 +1,11 @@
|
||||
2008-08-04 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
* glib/gmain.c (g_get_current_time): MSDN says: "Do not cast a
|
||||
pointer to a FILETIME structure to either a LARGE_INTEGER* or
|
||||
__int64* value because it can cause alignment faults on 64-bit
|
||||
Windows." So don't do that then. Indeed the code did work randomly
|
||||
on Win64 when compiled with optimisation.
|
||||
|
||||
2008-08-04 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
* glib/giowin32.c
|
||||
|
11
glib/gmain.c
11
glib/gmain.c
@ -1717,20 +1717,21 @@ g_get_current_time (GTimeVal *result)
|
||||
result->tv_usec = r.tv_usec;
|
||||
#else
|
||||
FILETIME ft;
|
||||
guint64 *time64 = (guint64 *) &ft;
|
||||
guint64 time64;
|
||||
|
||||
g_return_if_fail (result != NULL);
|
||||
|
||||
GetSystemTimeAsFileTime (&ft);
|
||||
memmove (&time64, &ft, sizeof (FILETIME));
|
||||
|
||||
/* Convert from 100s of nanoseconds since 1601-01-01
|
||||
* to Unix epoch. Yes, this is Y2038 unsafe.
|
||||
*/
|
||||
*time64 -= G_GINT64_CONSTANT (116444736000000000);
|
||||
*time64 /= 10;
|
||||
time64 -= G_GINT64_CONSTANT (116444736000000000);
|
||||
time64 /= 10;
|
||||
|
||||
result->tv_sec = *time64 / 1000000;
|
||||
result->tv_usec = *time64 % 1000000;
|
||||
result->tv_sec = time64 / 1000000;
|
||||
result->tv_usec = time64 % 1000000;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user