php/php-src — pull request #89 by slayercat (2012-05-23 12:40:20+00:00)
Title: function getfilesystemtime: change the way to convert FILE struct to __int64 

The direct convert from FILE struct to __int64 is unsafe.

via http://technet.microsoft.com/en-us/library/ms724284(v=vs.85).aspx

"Do not cast a pointer to a FILETIME structure to either a
ULARGE_INTEGER* or __int64* value because it can cause alignment faults on 64-bit Windows."

In my computer(windows 7 32bit), either way works fine. but i just believe it's necessary to avoid the Possible problems .

long long getfilesystemtime_old()
{
FILETIME ft;
__int64 ff;
ULARGE_INTEGER convFromft;
GetSystemTimeAsFileTime(&ft);
ff = *(__int64*)(&ft);
return ff;
}

long long getfilesystemtime()
{
FILETIME ft;
__int64 ff;
ULARGE_INTEGER convFromft;
GetSystemTimeAsFileTime(&ft);
convFromft.HighPart=ft.dwHighDateTime;
convFromft.LowPart=ft.dwLowDateTime;
ff=convFromft.QuadPart;

return ff;
}

int _tmain(int argc, _TCHAR* argv[])
{
if(getfilesystemtime()==getfilesystemtime_old())
{
printf("good");
}

}