Skip to content

Commit ba28946

Browse files
authored
gh-152433: Allow posixmodule.c to build for Windows UWP (GH-152998)
1 parent 54976e1 commit ba28946

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

Include/internal/pycore_fileutils_windows.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ static inline BOOL _Py_GetFileInformationByName(
5555
static int GetFileInformationByName_init = -1;
5656

5757
if (GetFileInformationByName_init < 0) {
58+
#ifdef MS_WINDOWS_DESKTOP
5859
HMODULE hMod = LoadLibraryW(L"api-ms-win-core-file-l2-1-4");
60+
#else
61+
HMODULE hMod = LoadPackagedLibrary(L"api-ms-win-core-file-l2-1-4", 0);
62+
#endif
5963
GetFileInformationByName_init = 0;
6064
if (hMod) {
6165
GetFileInformationByName = (PGetFileInformationByName)GetProcAddress(

Modules/clinic/posixmodule.c.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/posixmodule.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5197,7 +5197,7 @@ os_listdrives_impl(PyObject *module)
51975197

51985198
#endif /* MS_WINDOWS_DESKTOP || MS_WINDOWS_SYSTEM */
51995199

5200-
#if defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)
5200+
#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
52015201

52025202
/*[clinic input]
52035203
os.listvolumes
@@ -5260,7 +5260,7 @@ os_listvolumes_impl(PyObject *module)
52605260
return result;
52615261
}
52625262

5263-
#endif /* MS_WINDOWS_APP || MS_WINDOWS_SYSTEM */
5263+
#endif /* MS_WINDOWS_DESKTOP || MS_WINDOWS_SYSTEM */
52645264

52655265
#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
52665266

@@ -9933,6 +9933,7 @@ os_setpgrp_impl(PyObject *module)
99339933
#include <winternl.h>
99349934
#include <ProcessSnapshot.h>
99359935

9936+
#ifdef MS_WINDOWS_DESKTOP
99369937
// The structure definition in winternl.h may be incomplete.
99379938
// This structure is the full version from the MSDN documentation.
99389939
typedef struct _PROCESS_BASIC_INFORMATION_FULL {
@@ -10005,6 +10006,7 @@ win32_getppid_fast(void)
1000510006
cached_ppid = (ULONG) basic_information.InheritedFromUniqueProcessId;
1000610007
return cached_ppid;
1000710008
}
10009+
#endif // MS_WINDOWS_DESKTOP
1000810010

1000910011
static PyObject*
1001010012
win32_getppid(void)
@@ -10013,12 +10015,13 @@ win32_getppid(void)
1001310015
PyObject* result = NULL;
1001410016
HANDLE process = GetCurrentProcess();
1001510017
HPSS snapshot = NULL;
10016-
ULONG pid;
1001710018

10018-
pid = win32_getppid_fast();
10019+
#ifdef MS_WINDOWS_DESKTOP
10020+
ULONG pid = win32_getppid_fast();
1001910021
if (pid != 0) {
1002010022
return PyLong_FromUnsignedLong(pid);
1002110023
}
10024+
#endif
1002210025

1002310026
// If failure occurs in win32_getppid_fast(), fall back to using the PSS API.
1002410027

0 commit comments

Comments
 (0)