forked from msys2/MINGW-packages
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python3: Bring XP support back to 3.5.0
- Loading branch information
1 parent
97cb820
commit 861c312
Showing
3 changed files
with
167 additions
and
1 deletion.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
mingw-w64-python3/0950-mingw-w64-XP3-compat-GetProcAddress-GetTickCount64.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- Python-3.5.0/Python/pytime.c.orig 2015-10-05 21:30:23.839918600 +0100 | ||
+++ Python-3.5.0/Python/pytime.c 2015-10-05 21:30:28.078842500 +0100 | ||
@@ -435,7 +435,7 @@ | ||
/* 11,644,473,600,000,000,000: number of nanoseconds between | ||
the 1st january 1601 and the 1st january 1970 (369 years + 89 leap | ||
days). */ | ||
- *tp = large.QuadPart * 100 - 11644473600000000000; | ||
+ *tp = large.QuadPart * 100 - 11644473600000000000ULL; | ||
if (info) { | ||
DWORD timeAdjustment, timeIncrement; | ||
BOOL isTimeAdjustmentDisabled, ok; | ||
@@ -529,6 +529,34 @@ | ||
return pygettimeofday_new(t, info, 1); | ||
} | ||
|
||
+#if defined(MS_WINDOWS) && _WIN32_WINNT < 0x0600 | ||
+/* GetTickCount64() is not available on XP. */ | ||
+ULONGLONG GetTickCount64 () | ||
+{ | ||
+ static ULONGLONG (CALLBACK *Py_GetTickCount64)() = (ULONGLONG (*)(void))-1; | ||
+ static DWORD last_ticks = 0; | ||
+ static DWORD n_overflow = 0; | ||
+ DWORD ticks = 0; | ||
+ HINSTANCE hKernel32; | ||
+ | ||
+ if (Py_GetTickCount64 == (void*)-1) | ||
+ { | ||
+ hKernel32 = GetModuleHandleW(L"KERNEL32"); | ||
+ Py_GetTickCount64 = *(ULONGLONG (*)(void))(GetProcAddress(hKernel32, | ||
+ "GetTickCount64")); | ||
+ } | ||
+ if (Py_GetTickCount64 != (void*)-1) | ||
+ { | ||
+ return Py_GetTickCount64(); | ||
+ } | ||
+ | ||
+ ticks = GetTickCount(); | ||
+ if (ticks < last_ticks) | ||
+ n_overflow++; | ||
+ last_ticks = ticks; | ||
+ return ((ULONGLONG)n_overflow << 32LL) + (ULONGLONG)GetTickCount(); | ||
+} | ||
+#endif | ||
|
||
static int | ||
pymonotonic_new(_PyTime_t *tp, _Py_clock_info_t *info, int raise) |
114 changes: 114 additions & 0 deletions
114
mingw-w64-python3/0960-mingw-w64-XP3-compat-GetProcAddress-GetFinalPathNameByHandleW.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
--- Python-3.5.0/Modules/posixmodule.c.orig 2015-10-05 21:34:15.284022500 +0100 | ||
+++ Python-3.5.0/Modules/posixmodule.c 2015-10-05 21:34:18.082536800 +0100 | ||
@@ -1462,6 +1462,31 @@ | ||
return TRUE; | ||
} | ||
|
||
+/* Grab GetFinalPathNameByHandle dynamically from kernel32 */ | ||
+static int has_GetFinalPathNameByHandle = -1; | ||
+static DWORD (CALLBACK *Py_GetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD, | ||
+ DWORD); | ||
+static int | ||
+check_GetFinalPathNameByHandle() | ||
+{ | ||
+ HINSTANCE hKernel32; | ||
+ DWORD (CALLBACK *Py_GetFinalPathNameByHandleA)(HANDLE, LPSTR, DWORD, | ||
+ DWORD); | ||
+ | ||
+ /* only recheck */ | ||
+ if (-1 == has_GetFinalPathNameByHandle) | ||
+ { | ||
+ hKernel32 = GetModuleHandleW(L"KERNEL32"); | ||
+ *(FARPROC*)&Py_GetFinalPathNameByHandleA = GetProcAddress(hKernel32, | ||
+ "GetFinalPathNameByHandleA"); | ||
+ *(FARPROC*)&Py_GetFinalPathNameByHandleW = GetProcAddress(hKernel32, | ||
+ "GetFinalPathNameByHandleW"); | ||
+ has_GetFinalPathNameByHandle = Py_GetFinalPathNameByHandleA && | ||
+ Py_GetFinalPathNameByHandleW; | ||
+ } | ||
+ return has_GetFinalPathNameByHandle; | ||
+} | ||
+ | ||
static BOOL | ||
get_target_path(HANDLE hdl, wchar_t **target_path) | ||
{ | ||
@@ -1470,8 +1495,8 @@ | ||
|
||
/* We have a good handle to the target, use it to determine | ||
the target path name (then we'll call lstat on it). */ | ||
- buf_size = GetFinalPathNameByHandleW(hdl, 0, 0, | ||
- VOLUME_NAME_DOS); | ||
+ buf_size = Py_GetFinalPathNameByHandleW(hdl, 0, 0, | ||
+ VOLUME_NAME_DOS); | ||
if(!buf_size) | ||
return FALSE; | ||
|
||
@@ -1481,7 +1506,7 @@ | ||
return FALSE; | ||
} | ||
|
||
- result_length = GetFinalPathNameByHandleW(hdl, | ||
+ result_length = Py_GetFinalPathNameByHandleW(hdl, | ||
buf, buf_size, VOLUME_NAME_DOS); | ||
|
||
if(!result_length) { | ||
@@ -1514,6 +1539,12 @@ | ||
wchar_t *target_path; | ||
const char *dot; | ||
|
||
+ if(!check_GetFinalPathNameByHandle()) { | ||
+ /* If the OS doesn't have GetFinalPathNameByHandle, don't | ||
+ traverse reparse point. */ | ||
+ traverse = FALSE; | ||
+ } | ||
+ | ||
hFile = CreateFileA( | ||
path, | ||
FILE_READ_ATTRIBUTES, /* desired access */ | ||
@@ -1604,6 +1635,12 @@ | ||
wchar_t *target_path; | ||
const wchar_t *dot; | ||
|
||
+ if(!check_GetFinalPathNameByHandle()) { | ||
+ /* If the OS doesn't have GetFinalPathNameByHandle, don't | ||
+ traverse reparse point. */ | ||
+ traverse = FALSE; | ||
+ } | ||
+ | ||
hFile = CreateFileW( | ||
path, | ||
FILE_READ_ATTRIBUTES, /* desired access */ | ||
@@ -3846,6 +3883,13 @@ | ||
if (path_wchar == NULL) | ||
return NULL; | ||
|
||
+ if(!check_GetFinalPathNameByHandle()) { | ||
+ /* If the OS doesn't have GetFinalPathNameByHandle, return a | ||
+ NotImplementedError. */ | ||
+ return PyErr_Format(PyExc_NotImplementedError, | ||
+ "GetFinalPathNameByHandle not available on this platform"); | ||
+ } | ||
+ | ||
hFile = CreateFileW( | ||
path_wchar, | ||
0, /* desired access */ | ||
@@ -3861,7 +3905,7 @@ | ||
|
||
/* We have a good handle to the target, use it to determine the | ||
target path name. */ | ||
- buf_size = GetFinalPathNameByHandleW(hFile, 0, 0, VOLUME_NAME_NT); | ||
+ buf_size = Py_GetFinalPathNameByHandleW(hFile, 0, 0, VOLUME_NAME_NT); | ||
|
||
if(!buf_size) | ||
return win32_error_object("GetFinalPathNameByHandle", path); | ||
@@ -3870,8 +3914,8 @@ | ||
if(!target_path) | ||
return PyErr_NoMemory(); | ||
|
||
- result_length = GetFinalPathNameByHandleW(hFile, target_path, | ||
- buf_size, VOLUME_NAME_DOS); | ||
+ result_length = Py_GetFinalPathNameByHandleW(hFile, target_path, | ||
+ buf_size, VOLUME_NAME_DOS); | ||
if(!result_length) | ||
return win32_error_object("GetFinalPathNamyByHandle", path); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters