Skip to content

Commit 0522400

Browse files
committed
Add win32_api patch
1 parent 9912b74 commit 0522400

6 files changed

Lines changed: 99 additions & 10 deletions

File tree

patches/Readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ vcruntime140 | Windows | 必须 Nessesary | 禁用sfx启动时GetModuleHandle(vc
1313
win32 | Windows | 必须 Nessesary | 修改构建系统以静态构建 Modify build system for build sfx file
1414
zend_stream | Windows | 必须 Nessesary | 修改构建系统以静态构建 Modify build system for build sfx file
1515
comctl32 | Windows | 可选 Optional | 添加comctl32.dll manifest以启用[visual style](https://learn.microsoft.com/en-us/windows/win32/controls/visual-styles-overview) (会让窗口控件好看一些) Add manifest dependency for comctl32 to enable [visual style](https://learn.microsoft.com/en-us/windows/win32/controls/visual-styles-overview) (makes window control looks modern)
16+
win32_api | Windows | 必须 Necessary | 修复一些win32 api的声明 Fix declarations of some win32 apis
1617

1718
## Usage
1819

@@ -85,3 +86,10 @@ This bypasses many hard-coded cli SAPI name checks.
8586
允许Windows的cli静态构建,不是给micro用的
8687

8788
This allows the Windows cli SAPI to be built fully statically. It is not a patch for micro.
89+
90+
### win32_api
91+
92+
修复一些win32 api的声明,避免编译警告。这些修改已经在新版本 PHP (>=8.4)中合并,但保证旧版本也能用,这些补丁仍然需要
93+
94+
This fixes declarations of some win32 apis to avoid compilation warnings. These changes have been merged into newer versions of PHP (>=8.4), but to ensure that older versions can still be used, these patches are still needed.
95+

patches/cli_static_80.patch

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@ index 0ad53e813c..a8cc1bee29 100644
33
--- a/sapi/cli/php_cli.c
44
+++ b/sapi/cli/php_cli.c
55
@@ -97,7 +97,7 @@ PHPAPI extern char *php_ini_scanned_files;
6-
6+
77
#if defined(PHP_WIN32)
88
#if defined(ZTS)
99
-ZEND_TSRMLS_CACHE_DEFINE()
1010
+//ZEND_TSRMLS_CACHE_DEFINE()
1111
#endif
1212
static DWORD orig_cp = 0;
1313
#endif
14-
@@ -1160,6 +1160,11 @@ int main(int argc, char *argv[])
14+
@@ -1160,6 +1160,10 @@ int main(int argc, char *argv[])
1515
#endif
1616
{
1717
#if defined(PHP_WIN32)
18-
+ php_win32_init_gettimeofday();
1918
+ if (!php_win32_ioutil_init()) {
2019
+ fprintf(stderr, "ioutil initialization failed");
2120
+ return 1;

patches/win32_api_80.patch

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
diff --git a/win32/dllmain.c b/win32/dllmain.c
2+
index a507f1e1..ab625bf3 100644
3+
--- a/win32/dllmain.c
4+
+++ b/win32/dllmain.c
5+
@@ -38,20 +38,6 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID dummy)
6+
switch (reason)
7+
{
8+
case DLL_PROCESS_ATTACH:
9+
- /*
10+
- * We do not need to check the return value of php_win32_init_gettimeofday()
11+
- * because the symbol bare minimum symbol we need is always available on our
12+
- * lowest supported platform.
13+
- *
14+
- * On Windows 8 or greater, we use a more precise symbol to obtain the system
15+
- * time, which is dynamically. The fallback allows us to proper support
16+
- * Vista/7/Server 2003 R2/Server 2008/Server 2008 R2.
17+
- *
18+
- * Instead simply initialize the global in win32/time.c for gettimeofday()
19+
- * use later on
20+
- */
21+
- php_win32_init_gettimeofday();
22+
-
23+
ret = ret && php_win32_ioutil_init();
24+
if (!ret) {
25+
fprintf(stderr, "ioutil initialization failed");
26+
diff --git a/win32/time.c b/win32/time.c
27+
index d1fe5145..57db914e 100644
28+
--- a/win32/time.c
29+
+++ b/win32/time.c
30+
@@ -23,42 +23,13 @@
31+
#include <errno.h>
32+
#include "php_win32_globals.h"
33+
34+
-typedef VOID (WINAPI *MyGetSystemTimeAsFileTime)(LPFILETIME lpSystemTimeAsFileTime);
35+
-
36+
-static MyGetSystemTimeAsFileTime timefunc = NULL;
37+
-
38+
-#ifdef PHP_EXPORTS
39+
-static zend_always_inline MyGetSystemTimeAsFileTime get_time_func(void)
40+
-{/*{{{*/
41+
- MyGetSystemTimeAsFileTime timefunc = NULL;
42+
- HMODULE hMod = GetModuleHandle("kernel32.dll");
43+
-
44+
- if (hMod) {
45+
- /* Max possible resolution <1us, win8/server2012 */
46+
- timefunc = (MyGetSystemTimeAsFileTime)GetProcAddress(hMod, "GetSystemTimePreciseAsFileTime");
47+
- }
48+
-
49+
- if(!timefunc) {
50+
- /* 100ns blocks since 01-Jan-1641 */
51+
- timefunc = (MyGetSystemTimeAsFileTime) GetSystemTimeAsFileTime;
52+
- }
53+
-
54+
- return timefunc;
55+
-}/*}}}*/
56+
-
57+
-void php_win32_init_gettimeofday(void)
58+
-{/*{{{*/
59+
- timefunc = get_time_func();
60+
-}/*}}}*/
61+
-#endif
62+
-
63+
static zend_always_inline int getfilesystemtime(struct timeval *tv)
64+
{/*{{{*/
65+
FILETIME ft;
66+
unsigned __int64 ff = 0;
67+
ULARGE_INTEGER fft;
68+
69+
- timefunc(&ft);
70+
+ GetSystemTimePreciseAsFileTime(&ft);
71+
72+
/*
73+
* Do not cast a pointer to a FILETIME structure to either a
74+
diff --git a/win32/time.h b/win32/time.h
75+
index 51090ccf..77d1cbfd 100644
76+
--- a/win32/time.h
77+
+++ b/win32/time.h
78+
@@ -54,10 +54,4 @@ PHPAPI int nanosleep( const struct timespec * rqtp, struct timespec * rmtp );
79+
80+
PHPAPI int usleep(unsigned int useconds);
81+
82+
-#ifdef PHP_EXPORTS
83+
-/* This symbols are needed only for the DllMain, but should not be exported
84+
- or be available when used with PHP binaries. */
85+
-void php_win32_init_gettimeofday(void);
86+
-#endif
87+
-
88+
#endif

patches/win32_api_84.patch

Whitespace-only changes.

php_micro.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ BOOL php_win32_shutdown_random_bytes(void);
5454
#if PHP_VERSION_ID < 80500
5555
BOOL php_win32_ioutil_init(void);
5656
#endif
57-
#if PHP_VERSION_ID < 80400
58-
void php_win32_init_gettimeofday(void);
59-
#endif
6057
#else
6158
# define php_select(m, r, w, e, t) select(m, r, w, e, t)
6259
# include <fcntl.h>
@@ -593,9 +590,6 @@ int main(int argc, char *argv[])
593590
#if PHP_VERSION_ID < 80500
594591
php_win32_ioutil_init();
595592
#endif
596-
#if PHP_VERSION_ID < 80400
597-
php_win32_init_gettimeofday();
598-
#endif
599593

600594
_fmode = _O_BINARY; /* sets default for file streams to binary */
601595
setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */

php_micro.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ limitations under the License.
2525

2626
#define PHP_MICRO_VER_MAJ 0
2727
#define PHP_MICRO_VER_MIN 2
28-
#define PHP_MICRO_VER_PAT 1
28+
#define PHP_MICRO_VER_PAT 2
2929
// #define PHP_MICRO_VER_APP "nope"
3030
#ifdef PHP_MICRO_VER_APP
3131
# define PHP_MICRO_VER_STR \

0 commit comments

Comments
 (0)