Commit Graph

32 Commits

Author SHA1 Message Date
Christoph M. Becker
ec2655f88b
Voidify getfilesystemtime() (GH-15413)
The function always returned 0, and the return values was never used,
so we declare it to return void.

While we're at it, we also fix the space indentation of the comment.
2024-08-14 21:09:26 +02:00
Christoph M. Becker
25afbdb09e
GetSystemTimePreciseAsFileTime() is now always available (GH-15400)
* GetSystemTimePreciseAsFileTime() is now always available

As of PHP 8.3.0, we require Windows Server 2012 or Windows 8 as bare
minimum.  Since GetSystemTimePreciseAsFileTime() is always available on
these Windows versions[1], there is no more need for the workaround
described in dllmain.c; we just can call the function directly.

[1] <https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime>
2024-08-14 20:00:27 +02:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Peter Kokot
8d3f8ca12a Remove unused Git attributes ident
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.

In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.

This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
2018-07-25 00:53:25 +02:00
Anatol Belski
7dcfa839c9 Remove inappropriate FreeLibrary call 2018-06-11 13:49:42 +02:00
Anatol Belski
a56700043e vim folds and modelines 2017-07-04 16:08:48 +02:00
Kalle Sommer Nielsen
13e076f446 We do not need to check the return value of php_win32_init_gettimeofday() anymore, as the symbol is always going to be available to us 2016-08-11 04:35:51 +02:00
Kalle Sommer Nielsen
ff1a3cecae The call to FreeLibrary() should be within the if, so we don't pass INVALID_HANDLE_VALUE to it, in case LoadLibrary() fails 2016-08-11 04:13:34 +02:00
Kalle Sommer Nielsen
36b050c2c5 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().
2016-08-11 02:09:50 +02:00
Anatol Belski
06332e6706 introduced DllMain for the main php DLL
The particular need on this is because of the current situation
with determining the background functionality for the
gettimeofday. DllMain allows to initialize stuff before the DLL
can be actually used. Thus, we use different time API on win7
and win8 and later, so the function pointer needs to be
initialized before anything in the DLL could even demand it.

The change also opens the door for the further optimizations,
as now we're able to do the very basic initializations for the
whole DLL before it could ever start to live. Fe on this way the
TLS initialization could be done, when utilizing the
DLL_THREAD_ATTACH/DETACH case. Whether it's really usable in
portable way should be synced with other platforms.

Be aware that it's dangerous as it possibly causes dead locks.
So to use with care. One willing to add items to DllMain should
better read the documentation twice and even then try to defer
the necessary action.
2015-06-02 15:56:32 +02:00
Anatol Belski
514aa4ef53 remove dead code 2015-05-20 19:14:06 +02:00
Anatol Belski
a6190359ad add vim modelines 2015-05-20 19:14:05 +02:00
Stanislav Malyshev
b7a7b1a624 trailing whitespace removal 2015-01-10 15:07:38 -08:00
Anatol Belski
bc33171ac6 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.
2014-12-23 13:00:30 +01:00
Anatol Belski
b022e54bd1 Fixed possible precision loss in microtime
This is related to the fix for bug #64370. MSVC natively supports __int64 type,
so calculating with 32 bit ints is neither necessary nor reliable. Therefore
an older piece of code is reused.
2013-03-23 17:40:06 +01:00
Anatol Belski
b903d2d6cd Backported patch for #64370 2013-03-15 19:04:40 +01:00
Xinchen Hui
6ecc9f1d9d Remove unused codes 2012-06-07 14:31:35 +08:00
slayercat
d9810af45a based on microsoft's description,the direct convert from FILETIME 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."
2012-06-07 14:28:05 +08:00
Gustavo André dos Santos Lopes
3332c5be08 - Fixed bug #53297 (gettimeofday implementation in php/win32/time.c can return
1 million microsecs). (ped at 7gods dot org)
- Moved line out of order in NEWS.
2010-11-12 18:37:02 +00:00
Pierre Joye
274dad3b83 - MFH:
- add nanosleep
 - expose nanosleep and usleep
 - [DOC] time_ nanosleep and time_ sleep_ until available on windows
 - change nanosleep signature to match posix one
2009-01-19 02:35:22 +00:00
Kalle Sommer Nielsen
49494bed8b MFH:
* Last _WIN32_WINNT macro redef
* Include <config.w32.h> where _WIN32_WINNT was
2008-08-14 23:29:25 +00:00
Kalle Sommer Nielsen
540326c31f MFH:
* Remove NTDDI_VERSION declaring and use the one in config.w32.h
* Remove another _WIN32_WINNT macro redef in win32/time.c
2008-08-13 22:40:39 +00:00
Wez Furlong
cde7423cde Misc. win32 thread safety fixes. 2004-07-29 02:59:44 +00:00
Wez Furlong
848684fa96 make usleep actually work properly 2004-01-13 02:07:04 +00:00
Wez Furlong
7a7713eaeb Fix build for new usleep implementation.
NB: we now depend on windows 98 and later;
windows 95 does not have these timing functions.
2003-11-29 22:59:33 +00:00
Wez Furlong
dd60413c61 implement usleep for win32 2003-11-29 22:48:42 +00:00
Edin Kadribasic
2183565321 Allow dynamically compiled extensions to use gettimeofday() on win32. 2002-06-23 23:22:33 +00:00
James Moore
a97e0e1964 Fix for time.c under win32. Patch By: "Vanhanen, Reijo" <Reijo.Vanhanen@helsoft.fi>
@- microtime under windows now returns accurate values (James)
2001-02-04 15:52:32 +00:00
Stig Bakken
117a2fba07 * fixed some #if/#ifdef issues
* hand-patched in php3 changes from 3.0.6 to HEAD in these files:
   fopen-wrappers.[ch] ext/standard/file.[ch] ext/standard/fsock.[ch]
   ext/standard/php3_string.h ext/standard/string.c
* added some new file/socket macros for more readable code:
   FP_FGETS(buf,len,sock,fp,issock)
   FP_FREAD(buf,len,sock,fp,issock)
   FP_FEOF(sock,fp,issock)
   FP_FGETC(sock,fp,issock)
1999-06-16 17:06:53 +00:00
Zeev Suraski
0818d96c97 A lot of cleanups... Removed old thread-safe code and other redundant code and files 1999-04-24 00:12:00 +00:00
Zeev Suraski
6f7c0edee3 Remove tls.[ch] 1999-04-23 20:06:01 +00:00
Zeev Suraski
aceaabceff PHP 4.0 1999-04-07 21:05:13 +00:00