summaryrefslogtreecommitdiff
path: root/win32/time.c
diff options
context:
space:
mode:
authorKalle Sommer Nielsen <kalle@php.net>2016-08-11 02:09:50 +0200
committerKalle Sommer Nielsen <kalle@php.net>2016-08-11 02:09:50 +0200
commit36b050c2c517b1b9bc1c67e07722d01f6eed6aa4 (patch)
treed632892c91d96d42cc6c5dd9733fb1902420a52f /win32/time.c
parentec2dd0217dc536079cb4aec4c045f5ea894409d6 (diff)
downloadphp-git-36b050c2c517b1b9bc1c67e07722d01f6eed6aa4.tar.gz
Get rid of these slow calls to LoadLibrary()/GetProcAddress() calls on Windows, we require Windows Vista as bare minimum for PHP anyway, so it does not make any sense to do this slow emulation anyway.
GD: - PrintWindow() is available as of Windows XP, it requires linking to User32.lib, which config.w32 for ext/gd already. CLI: - The borrowed functions from PostgreSQL to set the titles of the console window uses SetConsoleTitle() and GetConsoleTitle(), both are available as of Windows 2000 from Kernel32.lib which we already are linking against. Standard: - The disk space utility functions uses GetDiskFreeSpaceExA() which is available as of Windows XP, again links to Kernel32.lib. - The symlink() PHP function uses CreateSymbolicLinkA() which is available from Windows Vista, again from Kernel32.lib. - php_get_windows_name() in info.c uses GetNativeSystemInfo() which is available as of Windows XP and GetProductInfo() which is available as of Windows Vista, both are again from Kernel32.lib. Notes: - ext/interbase & ext/pdo_firebird uses GetProcAddress(), I'm not entirely sure how to handle this one. - ext/sqlite3, this is apart of the bundled libsqlite3, I don't really wanna play around with our bundled libs and make it a bigger issue for those who maintain and upgrade them. - ext/readline, the call to GetProcAddress() here does not do any system calls, so it is left as is. - win32/ioutil.c uses GetProcAddress(), but the function it attempts to load (PathCchCanonicalizeEx()) is only available from Windows 8 and greater (Pathcch.lib linkage). - win32/time.c uses GetSystemTimePreciseAsFileTime() which is available from Windows 8 and greater to get the current system date and time which the highest possible precision and falls back to GetSystemTimeAsFileTime() (available as of Windows 2000), again Kernel32.lib, the GetSystemTimePreciseAsFileTime() is left in a GetProcAddress().
Diffstat (limited to 'win32/time.c')
-rw-r--r--win32/time.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/win32/time.c b/win32/time.c
index dfcc46a59b..9063ebf629 100644
--- a/win32/time.c
+++ b/win32/time.c
@@ -38,11 +38,14 @@ static zend_always_inline MyGetSystemTimeAsFileTime get_time_func(void)
if (hMod) {
/* Max possible resolution <1us, win8/server2012 */
timefunc = (MyGetSystemTimeAsFileTime)GetProcAddress(hMod, "GetSystemTimePreciseAsFileTime");
+ }
+
+ /* Lower the refcount */
+ FreeLibrary(hMod);
- if(!timefunc) {
- /* 100ns blocks since 01-Jan-1641 */
- timefunc = (MyGetSystemTimeAsFileTime)GetProcAddress(hMod, "GetSystemTimeAsFileTime");
- }
+ if(!timefunc) {
+ /* 100ns blocks since 01-Jan-1641 */
+ timefunc = (MyGetSystemTimeAsFileTime) GetSystemTimeAsFileTime;
}
return timefunc;