mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
improved system time function determination
It doesn't need to LoadLibrary and all that stuff every time, but once on the first access. Also the functions which are not directly used inlined now.
This commit is contained in:
parent
e60b7207db
commit
bc33171ac6
1 changed files with 7 additions and 8 deletions
13
win32/time.c
13
win32/time.c
|
@ -27,7 +27,9 @@
|
|||
|
||||
typedef VOID (WINAPI *MyGetSystemTimeAsFileTime)(LPFILETIME lpSystemTimeAsFileTime);
|
||||
|
||||
static MyGetSystemTimeAsFileTime get_time_func(void)
|
||||
static MyGetSystemTimeAsFileTime timefunc = NULL;
|
||||
|
||||
static zend_always_inline MyGetSystemTimeAsFileTime get_time_func(void)
|
||||
{
|
||||
MyGetSystemTimeAsFileTime timefunc = NULL;
|
||||
HMODULE hMod = LoadLibrary("kernel32.dll");
|
||||
|
@ -45,19 +47,16 @@ static MyGetSystemTimeAsFileTime get_time_func(void)
|
|||
return timefunc;
|
||||
}
|
||||
|
||||
int getfilesystemtime(struct timeval *tv)
|
||||
static zend_always_inline int getfilesystemtime(struct timeval *tv)
|
||||
{
|
||||
FILETIME ft;
|
||||
unsigned __int64 ff = 0;
|
||||
MyGetSystemTimeAsFileTime timefunc;
|
||||
ULARGE_INTEGER fft;
|
||||
|
||||
if (!timefunc) {
|
||||
timefunc = get_time_func();
|
||||
if (timefunc) {
|
||||
timefunc(&ft);
|
||||
} else {
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
}
|
||||
timefunc(&ft);
|
||||
|
||||
/*
|
||||
* Do not cast a pointer to a FILETIME structure to either a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue