Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Unified Diff: Modules/socketmodule.c

Issue 3871: cross and native build of python for mingw32 with distutils
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Modules/signalmodule.c ('k') | Modules/socketmodule.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Modules/socketmodule.c Thu Dec 27 23:52:36 2012 +0200
+++ b/Modules/socketmodule.c Thu Dec 27 17:35:12 2012 -0500
@@ -93,6 +93,15 @@
#endif
#include "Python.h"
+#ifndef HAVE_GETPEERNAME
+/* FIXME: see comments in configure.in. Also PC/pyconfig.h define it.
+ * Since only this module use getpeername why don't remove declaration
+ * from PC/pyconfig.h and define here if is defined MS_WIN32 ?
+ */
+#ifdef __MINGW32__
+# define HAVE_GETPEERNAME
+#endif
+#endif /* ndef HAVE_GETPEERNAME */
#include "structmember.h"
#undef MAX
@@ -324,6 +333,35 @@
/* Do not include addrinfo.h for MSVC7 or greater. 'addrinfo' and
* EAI_* constants are defined in (the already included) ws2tcpip.h.
*/
+#elif defined(__MINGW32__)
+/* FIXME: getaddrinfo(HAVE_GETADDRINFO) depend from WINVER
+ TODO: resolve later(see comments in pyport.h) */
+#if 0
+/* To use getaddrinfo/getnameinfo from runtime for version before 0x0501
+ we has to define those functions (see below).
+ In all cases mingw linker succeed to link binaries.
+ If you enable this code the load of module will fail on w2k
+ with message like this one:
+ "The specified procedure could not be found" */
+# if (_WIN32_WINNT < 0x0501)
+void WSAAPI freeaddrinfo (struct addrinfo*);
+int WSAAPI getaddrinfo (const char*,const char*,const struct addrinfo*,
+ struct addrinfo**);
+int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD,
+ char*,DWORD,int);
+# endif
+# define HAVE_GETADDRINFO
+# define HAVE_GETNAMEINFO
+#else
+# if (_WIN32_WINNT < 0x0501)
+ /* Internal implemetation that has to work on w2k and latest. */
+# define EAI_ADDRFAMILY
+# include "addrinfo.h"
+# else
+# define HAVE_GETADDRINFO
+# define HAVE_GETNAMEINFO
+# endif
+#endif
#else
# include "addrinfo.h"
#endif
@@ -361,6 +399,16 @@
#if !defined(HAVE_GETADDRINFO)
/* avoid clashes with the C library definition of the symbol. */
#define getaddrinfo fake_getaddrinfo
+#ifdef __MINGW32__
+#ifdef gai_strerror
+/* NOTE: Mingw w32api always define gai_strerror to gai_strerror{A|W}
+ but getaddrinfo is defined if _WIN32_WINNT >= 0x0501.
+ MSDN say that gai_strerror() exist for w95 and later and
+ getaddrinfo()/getnameinfo() for wxp and later.
+ Since we use fake function to suppress warnign we has to undef. */
+# undef gai_strerror
+#endif
+#endif /*def __MINGW32__*/
#define gai_strerror fake_gai_strerror
#define freeaddrinfo fake_freeaddrinfo
#include "getaddrinfo.c"
@@ -3730,7 +3778,31 @@
Shut down the reading side of the socket (flag == SHUT_RD), the writing side\n\
of the socket (flag == SHUT_WR), or both ends (flag == SHUT_RDWR).");
+#ifndef SIO_RCVALL
+#ifdef __MINGW32__
+/* MSDN: SIO_RCVALL defined on w2k and later */
+/* note "Separate SDKs" required for w2k */
+/* 0x98000001 = _WSAIOW(IOC_VENDOR,1) */
+# define SIO_RCVALL 0x98000001
+# define RCVALL_OFF 0
+# define RCVALL_ON 1
+ /* NOTE: MSDN - this feature is not implemented */
+# define RCVALL_SOCKETLEVELONLY 2
+
+/* 0x98000004 = _WSAIOW(IOC_VENDOR,4) */
+# define SIO_KEEPALIVE_VALS 0x98000004
+struct tcp_keepalive {
+ u_long onoff;
+ u_long keepalivetime;
+ u_long keepaliveinterval;
+};
+#endif /* def __MINGW32__ */
+#endif /* ndef SIO_RCVALL */
+
#if defined(MS_WINDOWS) && defined(SIO_RCVALL)
+/* If isn't defined test_socket.py fail with:
+AttributeError: type object '_socket.socket' has no attribute 'ioctl'
+*/
static PyObject*
sock_ioctl(PySocketSockObject *s, PyObject *arg)
{
@@ -4068,6 +4140,12 @@
socket_gethostname(PyObject *self, PyObject *unused)
{
#ifdef MS_WINDOWS
+# undef USE_UNCODE_gethostname
+# if (_WIN32_WINNT >= 0x0500)
+# define USE_UNCODE_gethostname
+# endif
+#endif
+#ifdef USE_UNCODE_gethostname
/* Don't use winsock's gethostname, as this returns the ANSI
version of the hostname, whereas we need a Unicode string.
Otherwise, gethostname apparently also returns the DNS name. */
« no previous file with comments | « Modules/signalmodule.c ('k') | Modules/socketmodule.h » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+