[pypy-svn] pypy default: Fix the socket functions when compiled with mingw32

amauryfa commits-noreply at bitbucket.org
Mon Feb 7 15:30:07 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r41670:3494ee074c60
Date: 2011-02-07 15:28 +0100
http://bitbucket.org/pypy/pypy/changeset/3494ee074c60/

Log:	Fix the socket functions when compiled with mingw32

diff --git a/pypy/rlib/_rsocket_rffi.py b/pypy/rlib/_rsocket_rffi.py
--- a/pypy/rlib/_rsocket_rffi.py
+++ b/pypy/rlib/_rsocket_rffi.py
@@ -55,19 +55,32 @@
     header_lines = [
         '#include <WinSock2.h>',
         '#include <WS2tcpip.h>',
-        '#include <Mstcpip.h>',
         # winsock2 defines AF_UNIX, but not sockaddr_un
         '#undef AF_UNIX',
         ]
     if _MSVC:
         header_lines.extend([
+            '#include <Mstcpip.h>',
             # these types do not exist on microsoft compilers
             'typedef int ssize_t;',
             'typedef unsigned __int16 uint16_t;',
             'typedef unsigned __int32 uint32_t;',
             ])
-    else:
+    else: # MINGW
         includes = ('stdint.h',)
+        header_lines.extend([
+            '#define SIO_RCVALL             _WSAIOW(IOC_VENDOR,1)',
+            '#define SIO_KEEPALIVE_VALS     _WSAIOW(IOC_VENDOR,4)',
+            '#define RCVALL_OFF             0',
+            '#define RCVALL_ON              1',
+            '#define RCVALL_SOCKETLEVELONLY 2',
+            '''\
+            struct tcp_keepalive {
+                u_long  onoff;
+                u_long  keepalivetime;
+                u_long  keepaliveinterval;
+            };'''
+            ])
     HEADER = '\n'.join(header_lines)
     COND_HEADER = ''
 constants = {}
@@ -208,7 +221,7 @@
 
 if _WIN32:
     # some SDKs define these values with an enum, #ifdef won't work
-    for name in ('RCVALL_ON', 'RCVALL_OFF'):
+    for name in ('RCVALL_ON', 'RCVALL_OFF', 'RCVALL_SOCKETLEVELONLY'):
         setattr(CConfig, name, platform.ConstantInteger(name))
         constant_names.append(name)
 
@@ -418,7 +431,7 @@
 WIN32 = cConfig.WIN32
 assert WIN32 == _WIN32
 
-if WIN32:
+if _MSVC:
     def invalid_socket(fd):
         return fd == INVALID_SOCKET
     INVALID_SOCKET = cConfig.INVALID_SOCKET


More information about the Pypy-commit mailing list