Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow build :mod:`!_ctypes` for Universal Windows Platform.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``_winapi`` module: improve UWP compatibility
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow build ``ceval.c`` for Windows UWP.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow build :mod:`socket` module for Universal Windows Platform.
5 changes: 3 additions & 2 deletions Modules/_ctypes/callproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,8 +1082,7 @@ void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...)
}


#ifdef MS_WIN32

#ifdef MS_WINDOWS_DESKTOP
static PyObject *
GetComError(ctypes_state *st, HRESULT errcode, GUID *riid, IUnknown *pIunk)
{
Expand Down Expand Up @@ -1337,9 +1336,11 @@ PyObject *_ctypes_callproc(ctypes_state *st,

#ifdef MS_WIN32
if (iid && pIunk) {
#ifdef MS_WINDOWS_DESKTOP
if (*(int *)resbuf & 0x80000000)
retval = GetComError(st, *(HRESULT *)resbuf, iid, pIunk);
else
#endif
retval = PyLong_FromLong(*(int *)resbuf);
} else if (flags & FUNCFLAG_HRESULT) {
if (*(int *)resbuf & 0x80000000)
Expand Down
12 changes: 12 additions & 0 deletions Modules/_winapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,7 @@ gethandlelist(PyObject *mapping, const char *name, Py_ssize_t *size)
return ret;
}

#ifdef MS_WINDOWS_DESKTOP
typedef struct {
LPPROC_THREAD_ATTRIBUTE_LIST attribute_list;
LPHANDLE handle_list;
Expand Down Expand Up @@ -1322,6 +1323,7 @@ getattributelist(PyObject *obj, const char *name, AttributeList *attribute_list)

return ret;
}
#endif

/*[clinic input]
_winapi.CreateProcess
Expand Down Expand Up @@ -1355,6 +1357,9 @@ _winapi_CreateProcess_impl(PyObject *module, const wchar_t *application_name,
PyObject *startup_info)
/*[clinic end generated code: output=a25c8e49ea1d6427 input=84e2175279a3f5c2]*/
{
#ifndef MS_WINDOWS_DESKTOP
return NULL;
#else
PyObject *ret = NULL;
BOOL result;
PROCESS_INFORMATION pi;
Expand Down Expand Up @@ -1436,6 +1441,7 @@ _winapi_CreateProcess_impl(PyObject *module, const wchar_t *application_name,
freeattributelist(&attribute_list);

return ret;
#endif
}

/*[clinic input]
Expand Down Expand Up @@ -2591,7 +2597,9 @@ _winapi_BatchedWaitForMultipleObjects_impl(PyObject *module,
while (--thread_count >= 0) {
HANDLE t = thread_data[thread_count]->thread;
if (t) {
#ifdef MS_WINDOWS_DESKTOP
TerminateThread(t, WAIT_ABANDONED_0);
#endif
CloseHandle(t);
}
PyMem_Free((void *)thread_data[thread_count]);
Expand Down Expand Up @@ -2785,7 +2793,11 @@ static PyObject *
_winapi_GetOEMCP_impl(PyObject *module)
/*[clinic end generated code: output=4def5b07a8be1b3b input=e8caf4353a28e28e]*/
{
#ifndef MS_WINDOWS_DESKTOP
return NULL;
#else
return PyLong_FromUnsignedLong(GetOEMCP());
#endif
}

/*[clinic input]
Expand Down
14 changes: 7 additions & 7 deletions Modules/clinic/socketmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 23 additions & 13 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ shutdown(how) -- shut down traffic in one or both directions\n\
/* Helpers needed for AF_HYPERV */
# include <Rpc.h>

#ifndef RPC_S_OK
#define RPC_S_OK 0L
#endif

/* Macros based on the IPPROTO enum, see: https://bugs.python.org/issue29515 */
#define IPPROTO_ICMP IPPROTO_ICMP
#define IPPROTO_IGMP IPPROTO_IGMP
Expand Down Expand Up @@ -631,14 +635,14 @@ _PyLong_##NAME##_Converter(PyObject *obj, void *ptr) \
return 1; \
}

#if defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS)
#if defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
# ifdef MS_WINDOWS
UNSIGNED_INT_CONVERTER(NetIfindex, NET_IFINDEX)
# else
# define _PyLong_NetIfindex_Converter _PyLong_UnsignedInt_Converter
# define NET_IFINDEX unsigned int
# endif
#endif // defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS)
#endif // defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)

/*[python input]
class NET_IFINDEX_converter(CConverter):
Expand Down Expand Up @@ -5924,10 +5928,12 @@ _socket_gethostname_impl(PyObject *module)
Otherwise, gethostname apparently also returns the DNS name. */
wchar_t buf[MAX_COMPUTERNAME_LENGTH + 1];
DWORD size = Py_ARRAY_LENGTH(buf);
wchar_t *name;
PyObject *result;

#ifdef MS_WINDOWS_DESKTOP
if (GetComputerNameExW(ComputerNamePhysicalDnsHostname, buf, &size))
#else
if (GetComputerNameW(buf, &size))
#endif
return PyUnicode_FromWideChar(buf, size);

if (GetLastError() != ERROR_MORE_DATA)
Expand All @@ -5936,9 +5942,12 @@ _socket_gethostname_impl(PyObject *module)
if (size == 0)
return Py_GetConstant(Py_CONSTANT_EMPTY_STR);

#ifndef MS_WINDOWS_DESKTOP
return NULL;
#else
/* MSDN says ERROR_MORE_DATA may occur because DNS allows longer
names */
name = PyMem_New(wchar_t, size);
wchar_t* name = PyMem_New(wchar_t, size);
if (!name) {
PyErr_NoMemory();
return NULL;
Expand All @@ -5952,9 +5961,10 @@ _socket_gethostname_impl(PyObject *module)
return NULL;
}

result = PyUnicode_FromWideChar(name, size);
PyObject* result = PyUnicode_FromWideChar(name, size);
PyMem_Free(name);
return result;
#endif
#else
char buf[1024];
int res;
Expand Down Expand Up @@ -7321,7 +7331,7 @@ _socket_setdefaulttimeout(PyObject *module, PyObject *arg)
}


#if defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS)
#if defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS_DESKTOP)
/* Python API for getting interface indices and names */

/*[clinic input]
Expand Down Expand Up @@ -7412,9 +7422,9 @@ _socket_if_nameindex_impl(PyObject *module)
#endif
}

#endif // defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS)
#endif // defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS_DESKTOP)

#if defined(HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS)
#if defined(HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS_DESKTOP)

/*[clinic input]
_socket.if_nametoindex
Expand Down Expand Up @@ -7444,9 +7454,9 @@ _socket_if_nametoindex_impl(PyObject *module, PyObject *oname)
return PyLong_FromUnsignedLong(index);
}

#endif // defined(HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS)
#endif // defined(HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS_DESKTOP)

#if defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS)
#if defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)

/*[clinic input]
@permit_long_summary
Expand All @@ -7471,7 +7481,7 @@ _socket_if_indextoname_impl(PyObject *module, NET_IFINDEX index)
return PyUnicode_DecodeFSDefault(name);
}

#endif // defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS)
#endif // defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)


#ifdef CMSG_LEN
Expand Down Expand Up @@ -9374,7 +9384,7 @@ socket_exec(PyObject *m)
#endif
#endif /* _MSTCPIP_ */

#ifdef MS_WINDOWS
#ifdef MS_WINDOWS_DESKTOP
/* remove some flags on older version Windows during run-time */
if (remove_unusable_flags(m) < 0) {
goto error;
Expand Down
2 changes: 2 additions & 0 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ hardware_stack_limits(uintptr_t *base, uintptr_t *top, uintptr_t sp)
GetCurrentThreadStackLimits(&low, &high);
*top = (uintptr_t)high;
ULONG guarantee = 0;
#ifdef MS_WINDOWS_DESKTOP
SetThreadStackGuarantee(&guarantee);
#endif
*base = (uintptr_t)low + guarantee;
#elif defined(__APPLE__)
pthread_t this_thread = pthread_self();
Expand Down
Loading