Skip to content

function getfilesystemtime: change the way to convert FILE struct to __int64 - #89

Closed
slayercat wants to merge 1 commit into
php:masterfrom
slayercat:master
Closed

slayercat wants to merge 1 commit into
php:masterfrom
slayercat:master

Conversation

@slayercat

Copy link
Copy Markdown

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");
}

}

…uct 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."
@dsp

dsp commented Jun 6, 2012

Copy link
Copy Markdown
Member

@pierrejoye can you take a look at that please.

@php-pulls

Copy link
Copy Markdown

Comment on behalf of laruence at php.net:

merged

@php-pulls php-pulls closed this Jun 7, 2012
php-pulls pushed a commit that referenced this pull request Jun 15, 2014
zend_hash_get_current_key_zval_ex isn't defined in PHP 5.4. (used in phpdbg_watch.c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants